Run the screensaver on every monitor, not just the last one
omarchy-launch-screensaver loops over the monitors, focusing each and spawning a terminal on it -- but the spawn is asynchronous. Slow-starting terminals mapped their windows after focus had already moved to the next monitor, so every screensaver landed on the last-focused monitor and the others got none (and the fullscreen rule applied inconsistently when two windows mapped at once). Listen on Hyprland's event socket and wait for each monitor's screensaver window to open before moving focus to the next one, so there is exactly one screensaver per monitor. The stream is opened before spawning so a fast-mapping window can't be missed, with a read timeout as a safety net. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2c8639ffbd
commit
6ecb1dbb56
@@ -28,6 +28,23 @@ hypr_exec() {
|
||||
hyprctl dispatch "hl.dsp.exec_cmd([[$command]])" >/dev/null 2>&1 || hyprctl dispatch exec -- bash -lc "$command" >/dev/null
|
||||
}
|
||||
|
||||
SOCKET="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
|
||||
|
||||
# Open Hyprland's event stream before spawning anything, so a terminal that maps
|
||||
# quickly can't emit its openwindow event before we are listening for it.
|
||||
exec {events}< <(socat -U - "UNIX-CONNECT:$SOCKET")
|
||||
|
||||
# hypr_exec is async and a new window maps on whatever monitor is focused at that
|
||||
# moment. Block until this monitor's screensaver actually opens before moving
|
||||
# focus on -- otherwise slow-starting terminals all pile onto the last monitor.
|
||||
# The read timeout is a safety net in case the window never appears.
|
||||
wait_for_screensaver_window() {
|
||||
local line
|
||||
while IFS= read -r -t 5 -u "$events" line; do
|
||||
[[ $line == openwindow\>\>*,org.omarchy.screensaver,* ]] && return 0
|
||||
done
|
||||
}
|
||||
|
||||
for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
|
||||
hypr_focus_monitor "$m"
|
||||
|
||||
@@ -46,8 +63,11 @@ for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
|
||||
;;
|
||||
*)
|
||||
omarchy-notification-send -g ✋ "Screensaver only runs in Alacritty, Foot, Ghostty, or Kitty"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
wait_for_screensaver_window
|
||||
done
|
||||
|
||||
hypr_focus_monitor "$focused"
|
||||
|
||||
Reference in New Issue
Block a user