From 011dba73c31ecb1d47d288de8133328198422988 Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Tue, 8 Jan 2019 11:57:59 +0000 Subject: [PATCH] swayidle: release sleep lock immediately --- swayidle/main.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/swayidle/main.c b/swayidle/main.c index 41eecc41a..bdafb02ff 100644 --- a/swayidle/main.c +++ b/swayidle/main.c @@ -75,18 +75,8 @@ static void cmd_exec(char *param) { #if HAVE_SYSTEMD || HAVE_ELOGIND static int lock_fd = -1; -static int ongoing_fd = -1; static struct sd_bus *bus = NULL; -static int release_lock(void *data) { - wlr_log(WLR_INFO, "Releasing sleep lock %d", ongoing_fd); - if (ongoing_fd >= 0) { - close(ongoing_fd); - } - ongoing_fd = -1; - return 0; -} - static void acquire_sleep_lock(void) { sd_bus_message *msg = NULL; sd_bus_error error = SD_BUS_ERROR_NULL; @@ -139,19 +129,17 @@ static int prepare_for_sleep(sd_bus_message *msg, void *userdata, return 0; } - ongoing_fd = lock_fd; - if (state.lock_cmd) { cmd_exec(state.lock_cmd); } - - if (ongoing_fd >= 0) { - struct wl_event_source *source = - wl_event_loop_add_timer(state.event_loop, release_lock, NULL); - wl_event_source_timer_update(source, 1000); - } - wlr_log(WLR_DEBUG, "Prepare for sleep done"); + + wlr_log(WLR_INFO, "Releasing sleep lock %d", lock_fd); + if (lock_fd >= 0) { + close(lock_fd); + } + lock_fd = -1; + return 0; }