From 3058157cbe86dcac4c2e79539be899a07fd35ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Mon, 5 Oct 2020 12:25:49 +0200 Subject: [PATCH] add option to start swayidle in locked state --- main.c | 12 +++++++++++- swayidle.1.scd | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 52c79171..6dfce14f 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]); @@ -1067,6 +1072,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