Check terminal support once and bound the window wait overall
An unsupported terminal notified once per monitor and each monitor paid a wasted wait; check before the loop instead. The per-read timeout also let a chatty event stream extend the wait indefinitely, so spend the 5 seconds against one deadline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
6ecb1dbb56
commit
26630a9796
@@ -17,6 +17,14 @@ fi
|
||||
focused=$(omarchy-hyprland-monitor-focused)
|
||||
terminal=$(xdg-terminal-exec --print-id)
|
||||
|
||||
case $terminal in
|
||||
*Alacritty* | *ghostty* | *foot* | *kitty*) ;;
|
||||
*)
|
||||
omarchy-notification-send -g ✋ "Screensaver only runs in Alacritty, Foot, Ghostty, or Kitty"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
hypr_focus_monitor() {
|
||||
hyprctl dispatch "hl.dsp.focus({ monitor = \"$1\" })" >/dev/null 2>&1 || hyprctl dispatch focusmonitor "$1" >/dev/null
|
||||
}
|
||||
@@ -37,10 +45,10 @@ 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.
|
||||
# The deadline 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
|
||||
local line deadline=$((SECONDS + 5))
|
||||
while ((SECONDS < deadline)) && IFS= read -r -t $((deadline - SECONDS)) -u "$events" line; do
|
||||
[[ $line == openwindow\>\>*,org.omarchy.screensaver,* ]] && return 0
|
||||
done
|
||||
}
|
||||
@@ -61,10 +69,6 @@ for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
|
||||
*kitty*)
|
||||
hypr_exec kitty --class=org.omarchy.screensaver --override font_size=18 --override window_padding_width=0 -e omarchy-screensaver
|
||||
;;
|
||||
*)
|
||||
omarchy-notification-send -g ✋ "Screensaver only runs in Alacritty, Foot, Ghostty, or Kitty"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
wait_for_screensaver_window
|
||||
|
||||
Reference in New Issue
Block a user