From 7d2a0100e9db47d376cdd9fea25127048ef984a1 Mon Sep 17 00:00:00 2001 From: Jeena Date: Wed, 19 Aug 2026 14:24:37 +0900 Subject: [PATCH] fix: handle multiple Hyprland sockets in recovery/wake scripts Both scripts used ls | head -1 to find the socket, which picks the wrong (dead) session when old socket dirs linger. Now iterates over all sockets and picks the one that actually responds. --- hypr/scripts/unstick-display.sh | 18 ++++++++++++------ hypr/scripts/wake-display.sh | 10 ++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/hypr/scripts/unstick-display.sh b/hypr/scripts/unstick-display.sh index 67db667..68438f8 100755 --- a/hypr/scripts/unstick-display.sh +++ b/hypr/scripts/unstick-display.sh @@ -5,16 +5,22 @@ export XDG_RUNTIME_DIR=/run/user/$(id -u) -# Find the Hyprland instance signature from the socket directory -SIGNATURE=$(ls "$XDG_RUNTIME_DIR/hypr/" 2>/dev/null | head -1) +# Find the active Hyprland instance by trying each socket until one responds +for SIG in "$XDG_RUNTIME_DIR/hypr"/*/; do + [ -d "$SIG" ] || continue + SIGNAME=$(basename "$SIG") + export HYPRLAND_INSTANCE_SIGNATURE=$SIGNAME + if hyprctl monitors >/dev/null 2>&1; then + FOUND=1 + break + fi +done -if [ -z "$SIGNATURE" ]; then - echo "Could not find Hyprland socket. Is Hyprland running?" +if [ -z "$FOUND" ]; then + echo "Could not find active Hyprland socket. Is Hyprland running?" exit 1 fi -export HYPRLAND_INSTANCE_SIGNATURE=$SIGNATURE - echo "Resetting display pipeline..." pkill hyprlock 2>/dev/null diff --git a/hypr/scripts/wake-display.sh b/hypr/scripts/wake-display.sh index 3bd789e..0930018 100755 --- a/hypr/scripts/wake-display.sh +++ b/hypr/scripts/wake-display.sh @@ -3,10 +3,16 @@ # Cycles DPMS only if the display was actually turned off (avoids flicker # when the user returns before step 3 fires). -SIGNATURE=$(ls "$XDG_RUNTIME_DIR/hypr/" 2>/dev/null | head -1) -export HYPRLAND_INSTANCE_SIGNATURE=$SIGNATURE export XDG_RUNTIME_DIR=/run/user/$(id -u) +# Find the active Hyprland socket (not old/stale ones) +for SIG in "$XDG_RUNTIME_DIR/hypr"/*/; do + [ -d "$SIG" ] || continue + SIGNAME=$(basename "$SIG") + export HYPRLAND_INSTANCE_SIGNATURE=$SIGNAME + hyprctl monitors >/dev/null 2>&1 && break +done + DPMS=$(hyprctl monitors 2>/dev/null | grep dpmsStatus | awk '{print $2}') if [ "$DPMS" = "0" ]; then