Skip to content

Commit 11164cf

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

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

main.c

Lines changed: 12 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,13 +796,17 @@ 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]);
800805
printf(" -h\tthis help menu\n");
801806
printf(" -C\tpath to config file\n");
802807
printf(" -d\tdebug\n");
803808
printf(" -w\twait for command to finish\n");
809+
printf(" -l\tstart locked\n");
804810
printf(" -S\tpick the seat to work with\n");
805811
return 1;
806812
default:
@@ -1067,6 +1073,11 @@ int main(int argc, char *argv[]) {
10671073
display_event, NULL);
10681074
wl_event_source_check(source);
10691075

1076+
1077+
if (lock_on_start) {
1078+
kill(getpid(), SIGUSR1);
1079+
}
1080+
10701081
while (wl_event_loop_dispatch(state.event_loop, -1) != 1) {
10711082
// This space intentionally left blank
10721083
}

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)