Skip to content

Commit 3058157

Browse files
committed
add option to start swayidle in locked state
1 parent aa11c41 commit 3058157

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

main.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ enum log_importance {
6868

6969
static enum log_importance verbosity = LOG_INFO;
7070

71+
static bool lock_on_start = false;
72+
7173
static void swayidle_log(enum log_importance importance, const char *fmt, ...) {
7274
if (importance < verbosity) {
7375
return;
@@ -780,7 +782,7 @@ static int parse_idlehint(int argc, char **argv) {
780782

781783
static int parse_args(int argc, char *argv[], char **config_path) {
782784
int c;
783-
while ((c = getopt(argc, argv, "C:hdwS:")) != -1) {
785+
while ((c = getopt(argc, argv, "C:hdwlS:")) != -1) {
784786
switch (c) {
785787
case 'C':
786788
*config_path = strdup(optarg);
@@ -794,6 +796,9 @@ static int parse_args(int argc, char *argv[], char **config_path) {
794796
case 'S':
795797
state.seat_name = strdup(optarg);
796798
break;
799+
case 'l':
800+
lock_on_start = true;
801+
break;
797802
case 'h':
798803
case '?':
799804
printf("Usage: %s [OPTIONS]\n", argv[0]);
@@ -1067,6 +1072,11 @@ int main(int argc, char *argv[]) {
10671072
display_event, NULL);
10681073
wl_event_source_check(source);
10691074

1075+
1076+
if (lock_on_start) {
1077+
kill(getpid(), SIGUSR1);
1078+
}
1079+
10701080
while (wl_event_loop_dispatch(state.event_loop, -1) != 1) {
10711081
// This space intentionally left blank
10721082
}

swayidle.1.scd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ swayidle - Idle manager for Wayland
3030
*-S* <seat-name>
3131
Specify which seat to use. By default, if no name is specified, an arbitrary seat will be picked instead.
3232

33+
*-l*
34+
Lock the screen when swayidle starts. Useful in case of auto-login, when we want the wayland session
35+
automatically started, but locked.
36+
3337
# DESCRIPTION
3438

3539
swayidle listens for idle activity on your Wayland compositor and executes tasks

0 commit comments

Comments
 (0)