Skip to content

Commit

Permalink
add option to start swayidle in locked state
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamjan committed Sep 18, 2022
1 parent 87103aa commit 24276fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ static const char *verbosity_colors[] = {
[LOG_DEBUG ] = "\x1B[1;30m",
};

static bool lock_on_start = false;

static enum log_importance log_importance = LOG_INFO;

void swayidle_log_init(enum log_importance verbosity) {
Expand Down Expand Up @@ -827,7 +829,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':
free(*config_path);
Expand All @@ -842,6 +844,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]);
Expand Down Expand Up @@ -1118,6 +1123,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
}
Expand Down
4 changes: 4 additions & 0 deletions swayidle.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ swayidle - Idle manager for Wayland
*-S* <seat-name>
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
Expand Down

0 comments on commit 24276fe

Please sign in to comment.