From 02ed30a7c1df2ed70064c49f73f7aae478b42da5 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Mon, 27 Jan 2025 17:20:36 +0100 Subject: [PATCH] Add a wait period (just for demonstration purposes) --- Makefile | 2 +- config.h | 2 ++ unlocker.c | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 config.h diff --git a/Makefile b/Makefile index e31a0fb..715dcec 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ LDFLAGS:=-lwayland-client wl_unlocker: unlocker.o session-lock.o gcc -o wl_unlocker unlocker.o session-lock.o $(LDFLAGS) -unlocker.o: unlocker.c session-lock.h +unlocker.o: unlocker.c session-lock.h config.h session-lock.h: # FIXME: don't hardcode path! diff --git a/config.h b/config.h new file mode 100644 index 0000000..b36e786 --- /dev/null +++ b/config.h @@ -0,0 +1,2 @@ +//#define CONFIG_WAIT_PERIOD 2 +#undef CONFIG_WAIT_PERIOD diff --git a/unlocker.c b/unlocker.c index 3dfbbeb..8276a34 100644 --- a/unlocker.c +++ b/unlocker.c @@ -1,4 +1,6 @@ // Just random stdlib (and POSIX) so I don't have to think about these +#include "config.h" + #include #include #include @@ -9,6 +11,10 @@ #include #include +#ifdef CONFIG_WAIT_PERIOD +#include +#endif + // Wayland includes #include "wayland-client.h" #include "session-lock.h" @@ -97,6 +103,10 @@ int main(void) { // nothing to do, just destroy stuff ext_session_lock_v1_destroy(lock); } else if (lock_state == LOCKED) { +#ifdef CONFIG_WAIT_PERIOD + printf("Waiting %d s before unlocking…\n", CONFIG_WAIT_PERIOD); + sleep(CONFIG_WAIT_PERIOD); +#endif printf("Unlocking…\n"); ext_session_lock_v1_unlock_and_destroy(lock); } else {