Add a wait period (just for demonstration purposes)

master
LEdoian 4 weeks ago
parent ed838b50b6
commit 02ed30a7c1

@ -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!

@ -0,0 +1,2 @@
//#define CONFIG_WAIT_PERIOD 2
#undef CONFIG_WAIT_PERIOD

@ -1,4 +1,6 @@
// Just random stdlib (and POSIX) so I don't have to think about these
#include "config.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@ -9,6 +11,10 @@
#include <errno.h>
#include <sys/mman.h>
#ifdef CONFIG_WAIT_PERIOD
#include <time.h>
#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 {

Loading…
Cancel
Save