aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/sway/executable_display-toggle.sh
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:37 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:37 +0100
commit9ed9bf58e5f21ab9295c306ac390e8873a771bee (patch)
tree70f67fa581987dbbda6d6442fb5246ab773ec0ce /dot_config/sway/executable_display-toggle.sh
parentf84adbf727add98e33135d6ef9a793e8d79b6e6b (diff)
downloaddotfiles-9ed9bf58e5f21ab9295c306ac390e8873a771bee.tar.gz
dotfiles-9ed9bf58e5f21ab9295c306ac390e8873a771bee.tar.bz2
dotfiles-9ed9bf58e5f21ab9295c306ac390e8873a771bee.zip
fix(sway): re-apply display layout on resume
After resume from suspend sway resets output config to defaults (both monitors enabled side-by-side), so a laptop-off mode set before suspend silently snapped back to side-by-side on wake. The display-watcher script only reacts to changes in the count of connected externals, so it doesn't notice this. - Add an 'apply' mode to display-toggle.sh that reads the saved state and applies it (no toggle, no notification). - Wire it into swayidle's after-resume directive.
Diffstat (limited to 'dot_config/sway/executable_display-toggle.sh')
-rwxr-xr-xdot_config/sway/executable_display-toggle.sh12
1 files changed, 9 insertions, 3 deletions
diff --git a/dot_config/sway/executable_display-toggle.sh b/dot_config/sway/executable_display-toggle.sh
index 265ab6b..66747fb 100755
--- a/dot_config/sway/executable_display-toggle.sh
+++ b/dot_config/sway/executable_display-toggle.sh
@@ -1,6 +1,10 @@
#!/bin/sh
-# Toggle display mode: laptop-off ↔ side-by-side
-# Bound to F7 in sway config; also runs at startup with "init"
+# Display mode manager: laptop-off ↔ side-by-side.
+# (no arg) toggle between modes (F7 / Super+x d).
+# init force laptop-off on session start / external plugged in.
+# apply re-apply whatever is in the state file (used after resume,
+# since sway resets output config on wake → both monitors
+# come back enabled side-by-side regardless of saved state).
STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/display-mode"
@@ -24,8 +28,10 @@ fi
LAPTOP_WIDTH=$(echo "$OUTPUTS" | jq -r ".[] | select(.name == \"$LAPTOP\") | .current_mode.width // .modes[0].width")
[ -z "$LAPTOP_WIDTH" ] && LAPTOP_WIDTH=1920
-if [ "$1" = "init" ]; then
+if [ "${1:-}" = "init" ]; then
NEXT="laptop-off"
+elif [ "${1:-}" = "apply" ]; then
+ NEXT=$(cat "$STATE_FILE" 2>/dev/null || echo "laptop-off")
else
CURRENT=$(cat "$STATE_FILE" 2>/dev/null || echo "laptop-off")
case "$CURRENT" in