aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config')
-rwxr-xr-xdot_config/sway/executable_display-toggle.sh12
-rw-r--r--dot_config/systemd/user/swayidle.service1
2 files changed, 10 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
diff --git a/dot_config/systemd/user/swayidle.service b/dot_config/systemd/user/swayidle.service
index 478c8f8..a3a5a7e 100644
--- a/dot_config/systemd/user/swayidle.service
+++ b/dot_config/systemd/user/swayidle.service
@@ -11,6 +11,7 @@ ExecStart=/usr/bin/swayidle -w \
resume 'swaymsg "output * power on"' \
timeout 330 'swaylock -f -e -c 000000' \
before-sleep 'playerctl -a pause; swaylock -f -e -c 000000' \
+ after-resume '%h/.config/sway/display-toggle.sh apply' \
lock 'swaylock -f -e -c 000000'
Restart=on-failure
RestartSec=2s