diff --git a/main.c b/main.c index 52c79171..b2725c4e 100644 --- a/main.c +++ b/main.c @@ -68,6 +68,8 @@ enum log_importance { static enum log_importance verbosity = LOG_INFO; +static bool lock_on_start = false; + static void swayidle_log(enum log_importance importance, const char *fmt, ...) { if (importance < verbosity) { return; @@ -780,7 +782,7 @@ static int parse_idlehint(int argc, char **argv) { static int parse_args(int argc, char *argv[], char **config_path) { int c; - while ((c = getopt(argc, argv, "C:hdwS:")) != -1) { + while ((c = getopt(argc, argv, "C:hdwlS:")) != -1) { switch (c) { case 'C': *config_path = strdup(optarg); @@ -794,6 +796,9 @@ static int parse_args(int argc, char *argv[], char **config_path) { case 'S': state.seat_name = strdup(optarg); break; + case 'l': + lock_on_start = true; + break; case 'h': case '?': printf("Usage: %s [OPTIONS]\n", argv[0]); @@ -801,6 +806,7 @@ static int parse_args(int argc, char *argv[], char **config_path) { printf(" -C\tpath to config file\n"); printf(" -d\tdebug\n"); printf(" -w\twait for command to finish\n"); + printf(" -l\tstart locked\n"); printf(" -S\tpick the seat to work with\n"); return 1; default: @@ -1067,6 +1073,11 @@ int main(int argc, char *argv[]) { display_event, NULL); wl_event_source_check(source); + + if (lock_on_start) { + kill(getpid(), SIGUSR1); + } + while (wl_event_loop_dispatch(state.event_loop, -1) != 1) { // This space intentionally left blank } diff --git a/swayidle.1.scd b/swayidle.1.scd index 60c21e23..139a859e 100644 --- a/swayidle.1.scd +++ b/swayidle.1.scd @@ -30,6 +30,10 @@ swayidle - Idle manager for Wayland *-S* Specify which seat to use. By default, if no name is specified, an arbitrary seat will be picked instead. +*-l* + Lock the screen when swayidle starts. Useful in case of auto-login, when we want the wayland session + automatically started, but locked. + # DESCRIPTION swayidle listens for idle activity on your Wayland compositor and executes tasks