From 146965e7fb9dd9667595dfc3e167052d8c19f8c0 Mon Sep 17 00:00:00 2001 From: WindyDay <49394090+singer233@users.noreply.github.com> Date: Mon, 26 Feb 2024 01:08:12 +1100 Subject: [PATCH] core: unlock on sigusr1 (#82) * Add SIGUSR1 to unlock * minor style improvements --------- Co-authored-by: Vaxry --- src/core/hyprlock.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index 8740f09..564783e 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -286,6 +286,13 @@ void CHyprlock::onGlobalRemoved(void* data, struct wl_registry* registry, uint32 // end wl_registry +static void handleUnlockSignal(int sig) { + if (sig == SIGUSR1) { + Debug::log(LOG, "Unlocking with a SIGUSR1"); + g_pHyprlock->unlockSession(); + } +} + void CHyprlock::run() { m_sWaylandState.registry = wl_display_get_registry(m_sWaylandState.display); @@ -305,6 +312,8 @@ void CHyprlock::run() { lockSession(); + signal(SIGUSR1, handleUnlockSignal); + pollfd pollfds[] = { { .fd = wl_display_get_fd(m_sWaylandState.display),