Drop monitor wake watcher
Browse files at this commit2bd5e3fbdc50efdb9a4d0dd498ed7e6210e3b104Parent: 0ce4537- refactor
- drop monitor wake watcher
2 changed files +2 -21
.config/scripts/niri/show_desktop.shmodified+2 -1
| @@ -3,7 +3,8 @@ set -euo pipefail | |||
| 3 | 3 | ||
| 4 | source "$(dirname "$0")/monitors.sh" | 4 | source "$(dirname "$0")/monitors.sh" |
| 5 | 5 | ||
| 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 | ||
| 7 | niri msg action focus-monitor "$RIGHT_MONITOR" >/dev/null | 8 | niri msg action focus-monitor "$RIGHT_MONITOR" >/dev/null |
| 8 | niri msg action focus-workspace 1 >/dev/null | 9 | niri msg action focus-workspace 1 >/dev/null |
| 9 | niri msg action focus-monitor "$LEFT_MONITOR" >/dev/null | 10 | niri msg action focus-monitor "$LEFT_MONITOR" >/dev/null |
.config/scripts/niri/toggle_monitors.shmodified+0 -20
| @@ -2,32 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | source "$(dirname "$0")/monitors.sh" | 3 | source "$(dirname "$0")/monitors.sh" |
| 4 | 4 | ||
| 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 | - | ||
| 20 | case "${1:-menu}" in | 5 | case "${1:-menu}" in |
| 21 | - --reset) | ||
| 22 | - reset_workspaces | ||
| 23 | - exit 0 | ||
| 24 | - ;; | ||
| 25 | menu) | 6 | menu) |
| 26 | 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) | 7 | 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) |
| 27 | 8 | ||
| 28 | case "$menu" in | 9 | case "$menu" in |
| 29 | "🖥️ All Monitors Off") | 10 | "🖥️ All Monitors Off") |
| 30 | - setsid nohup "$0" --reset >/dev/null 2>&1 & | ||
| 31 | niri msg action power-off-monitors | 11 | niri msg action power-off-monitors |
| 32 | ;; | 12 | ;; |
| 33 | "🖥️ $LEFT_MONITOR Off") | 13 | "🖥️ $LEFT_MONITOR Off") |