forge
Explore
Log in

Don't you dare go Hollow

Drop monitor wake watcher

Browse files at this commit

2bd5e3fbdc50efdb9a4d0dd498ed7e6210e3b104Ahmet Kaan GümüşParent: 0ce4537
  • refactor
    • drop monitor wake watcher
Show full message
refactor(niri): drop monitor wake watcher

power-off-monitors makes HDMI drop its link, so niri sees a disconnect and
destroys the output's empty workspaces; focus then falls to the first one
holding a window. A watcher keyed on the quiet gap between link drops did
restore workspace 1 on wake, but a background process for this is not worth
it — reverted to plain power-off-monitors.

show_desktop.sh keeps the Mod+X jump to workspace 1 on both outputs.
.config/scripts/niri/show_desktop.shmodified+2 -1
@@ -3,7 +3,8 @@ set -euo pipefail
33
44 source "$(dirname "$0")/monitors.sh"
55
6-# workspace 1 is the empty-workspace-above-first slot, so it is always free
6+# workspace 1 is the empty-workspace-above-first slot: opening a window there
7+# pushes a fresh empty one above it, so it is always free
78 niri msg action focus-monitor "$RIGHT_MONITOR" >/dev/null
89 niri msg action focus-workspace 1 >/dev/null
910 niri msg action focus-monitor "$LEFT_MONITOR" >/dev/null
.config/scripts/niri/toggle_monitors.shmodified+0 -20
@@ -2,32 +2,12 @@
22
33 source "$(dirname "$0")/monitors.sh"
44
5-# DPMS off makes the display drop its link, so niri sees a disconnect and
6-# destroys that output's empty workspaces. On reconnect the active workspace
7-# falls back to the first surviving one. Just put every output back on its
8-# first workspace once the outputs return.
9-reset_workspaces() {
10- for _ in $(seq 1 600); do
11- niri msg -j workspaces 2>/dev/null |
12- jq -e --arg l "$LEFT_MONITOR" --arg r "$RIGHT_MONITOR" \
13- 'any(.[]; .output == $l) and any(.[]; .output == $r)' >/dev/null && break
14- sleep 1
15- done
16- sleep 1
17- "$(dirname "$0")/show_desktop.sh" >/dev/null 2>&1
18-}
19-
205 case "${1:-menu}" in
21- --reset)
22- reset_workspaces
23- exit 0
24- ;;
256 menu)
267 menu=$(echo -e "🖥️ All Monitors Off\n🖥️ $LEFT_MONITOR Off\n🖥️ $RIGHT_MONITOR Off\n💡 All Monitors On\n💡 $LEFT_MONITOR On\n💡 $RIGHT_MONITOR On\n❌ Cancel" | rofi -dmenu -p "Monitors" -i)
278
289 case "$menu" in
2910 "🖥️ All Monitors Off")
30- setsid nohup "$0" --reset >/dev/null 2>&1 &
3111 niri msg action power-off-monitors
3212 ;;
3313 "🖥️ $LEFT_MONITOR Off")