From 30bc46a7d09e47bfb45b82130c56f4e6f57c0e17 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 5 Dec 2021 15:16:00 +0500 Subject: [PATCH] Configure screen locker --- config/2-conditionals-bsd.mk | 7 +++++ config/2-conditionals-gnu.mk | 7 +++++ configure | 54 ++++++++++++++++++++++++++++++++++ polytreewm.1 | 3 ++ src/spawn.c | 57 ++++++++++++++++++++++++++++++++---- 5 files changed, 122 insertions(+), 6 deletions(-) diff --git a/config/2-conditionals-bsd.mk b/config/2-conditionals-bsd.mk index ab6cf5f..ab9d5b1 100644 --- a/config/2-conditionals-bsd.mk +++ b/config/2-conditionals-bsd.mk @@ -3,6 +3,13 @@ CPPFLAGS += -DENABLE_XINERAMA PKGS += xinerama .endif +.if "$(WITH_LOCKER)" == "i3lock" +CPPFLAGS += -DWITH_LOCKER -DWITH_LOCKER_I3LOCK +.endif +.if "$(WITH_LOCKER)" == "i3lock-color" +CPPFLAGS += -DWITH_LOCKER -DWITH_LOCKER_I3LOCK_COLOR +.endif + .if "$(WITH_TERMINAL)" == "alacritty" CPPFLAGS += -DWITH_TERMINAL -DWITH_TERMINAL_ALACRITTY .endif diff --git a/config/2-conditionals-gnu.mk b/config/2-conditionals-gnu.mk index 3ca899f..e8d9aa8 100644 --- a/config/2-conditionals-gnu.mk +++ b/config/2-conditionals-gnu.mk @@ -3,6 +3,13 @@ CPPFLAGS += -DENABLE_XINERAMA PKGS += xinerama endif +ifeq (i3lock,$(WITH_LOCKER)) +CPPFLAGS += -DWITH_LOCKER -DWITH_LOCKER_I3LOCK +endif +ifeq (i3lock-color,$(WITH_LOCKER)) +CPPFLAGS += -DWITH_LOCKER -DWITH_LOCKER_I3LOCK_COLOR +endif + ifeq (alacritty,$(WITH_TERMINAL)) CPPFLAGS += -DWITH_TERMINAL -DWITH_TERMINAL_ALACRITTY endif diff --git a/configure b/configure index b1a9eed..29b5669 100755 --- a/configure +++ b/configure @@ -45,6 +45,9 @@ Optional Features: Optional Packages: --with-PACKAGE[ ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE no) + --with-locker [i3lock|i3lock-color] + use ARG as screen locker [i3lock] + --without-locker do not use screen locker at all --with-terminal [alacritty|gnome|st|xterm] use ARG as terminal [alacritty] --without-terminal do not use terminal at all @@ -58,6 +61,7 @@ bindir='' datarootdir='' mandir='' enable_xinerama='' +with_locker='' with_terminal='' while [ $# -gt 0 ]; do @@ -90,6 +94,13 @@ while [ $# -gt 0 ]; do --disable-xinerama) enable_xinerama='no' ;; + --without-locker) + if [ "$with_locker" = '' ]; then + with_locker='no' + elif [ "$with_locker" != 'no' ]; then + usage + fi + ;; --without-terminal) if [ "$with_terminal" = '' ]; then with_terminal='no' @@ -97,6 +108,43 @@ while [ $# -gt 0 ]; do usage fi ;; + --with-locker) + shift + + case "$1" in + yes) + if [ "$with_locker" = '' ]; then + with_locker='yes' + elif [ "$with_locker" != 'yes' ]; then + usage + fi + ;; + no) + if [ "$with_locker" = '' ]; then + with_locker='no' + elif [ "$with_locker" != 'no' ]; then + usage + fi + ;; + i3lock) + if [ "$with_locker" = '' ]; then + with_locker='i3lock' + elif [ "$with_locker" != 'i3lock' ]; then + usage + fi + ;; + i3lock-color) + if [ "$with_locker" = '' ]; then + with_locker='i3lock-color' + elif [ "$with_locker" != 'i3lock-color' ]; then + usage + fi + ;; + *) + do_shift='no' + ;; + esac + ;; --with-terminal) shift @@ -176,6 +224,10 @@ if [ "$enable_xinerama" = '' ]; then enable_xinerama='yes' fi +if [ "$with_locker" = '' -o "$with_locker" = 'yes' ]; then + with_locker='i3lock' +fi + if [ "$with_terminal" = '' -o "$with_terminal" = 'yes' ]; then with_terminal='alacritty' fi @@ -186,6 +238,7 @@ echo "BINDIR = $bindir" echo "DATAROOTDIR = $datarootdir" echo "MANDIR = $mandir" echo "ENABLE_XINERAMA = $enable_xinerama" +echo "WITH_LOCKER = $with_locker" echo "WITH_TERMINAL = $with_terminal" cat > 'config/1-generated.mk' << MAKE @@ -195,6 +248,7 @@ BINDIR = $bindir DATAROOTDIR = $datarootdir MANDIR = $mandir ENABLE_XINERAMA = $enable_xinerama +WITH_LOCKER = $with_locker WITH_TERMINAL = $with_terminal MAKE diff --git a/polytreewm.1 b/polytreewm.1 index afb8a73..3c60c83 100644 --- a/polytreewm.1 +++ b/polytreewm.1 @@ -33,6 +33,9 @@ for launching other programs. .B Mod1\-Shift\-/ Start terminal. .TP +.B Mod1\-z +Lock screen. +.TP .B Mod1\-, Focus previous screen, if any. .TP diff --git a/src/spawn.c b/src/spawn.c index f7e31be..d8d776d 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -6,10 +6,19 @@ #include #include -#define MAX_ARGS_COUNT 20 +#define MAX_ARGS_COUNT 25 #define ARGS_SIZE (MAX_ARGS_COUNT + 1) #define MON_ARG_SIZE 2 +#ifdef WITH_LOCKER_I3LOCK_COLOR +#define COLOR_BLANK "#00000000" +#define COLOR_CLEAR "#ffffff22" +#define COLOR_DEFAULT "#ff00ffcc" +#define COLOR_TEXT "#ee00eeee" +#define COLOR_WRONG "#880000bb" +#define COLOR_VERIFYING "#bb00bbbb" +#endif // WITH_LOCKER_I3LOCK_COLOR + struct Command { const char *name; size_t monitor_arg_index; @@ -17,11 +26,47 @@ struct Command { }; static struct Command commands[] = { +#ifdef WITH_LOCKER { .name = "lock", .monitor_arg_index = 0, +#ifdef WITH_LOCKER_I3LOCK .args = { "i3lock", NULL }, +#endif // WITH_LOCKER_I3LOCK +#ifdef WITH_LOCKER_I3LOCK_COLOR + .args = { + "i3lock", + "--insidever-color="COLOR_CLEAR, + "--ringver-color="COLOR_VERIFYING, + + "--insidewrong-color="COLOR_CLEAR, + "--ringwrong-color="COLOR_WRONG, + + "--inside-color="COLOR_BLANK, + "--ring-color="COLOR_DEFAULT, + "--line-color="COLOR_BLANK, + "--separator-color="COLOR_DEFAULT, + + "--verif-color="COLOR_TEXT, + "--wrong-color="COLOR_TEXT, + "--time-color="COLOR_TEXT, + "--date-color="COLOR_TEXT, + "--layout-color="COLOR_TEXT, + "--keyhl-color="COLOR_WRONG, + "--bshl-color="COLOR_WRONG, + + "--screen=1", + "--blur=5", + "--clock", + "--indicator", + "--time-str=%H:%M:%S", + "--date-str=%a, %e %b %Y", + "--keylayout=1", + NULL, + }, +#endif // WITH_LOCKER_I3LOCK_COLOR }, +#endif // WITH_LOCKER { .name = "menu", .monitor_arg_index = 6, @@ -43,18 +88,18 @@ static struct Command commands[] = { .monitor_arg_index = 0, #ifdef WITH_TERMINAL_ALACRITTY .args = { "alacritty", NULL }, -#endif +#endif // WITH_TERMINAL_ALACRITTY #ifdef WITH_TERMINAL_GNOME .args = { "gnome-terminal", "--wait", NULL }, -#endif +#endif // WITH_TERMINAL_GNOME #ifdef WITH_TERMINAL_ST .args = { "st", NULL }, -#endif +#endif // WITH_TERMINAL_ST #ifdef WITH_TERMINAL_XTERM .args = { "xterm", NULL }, -#endif +#endif // WITH_TERMINAL_XTERM }, -#endif +#endif // WITH_TERMINAL { .name = "firefox", .monitor_arg_index = 0,