aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config')
-rw-r--r--dot_config/sway/config2
-rwxr-xr-xdot_config/sway/executable_display-toggle.sh23
-rw-r--r--dot_config/systemd/user/swayidle.service1
3 files changed, 14 insertions, 12 deletions
diff --git a/dot_config/sway/config b/dot_config/sway/config
index 1e2cc5f..73283c9 100644
--- a/dot_config/sway/config
+++ b/dot_config/sway/config
@@ -238,7 +238,7 @@ bindsym $mod+t exec ~/.config/sway/tb-toggle.sh
# ── Autostart ─────────────────────────────────────────────────────────────────
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE XDG_SESSION_DESKTOP PASSWORD_STORE_DIR
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE XDG_SESSION_DESKTOP PASSWORD_STORE_DIR
-exec "sleep 2 && ~/.config/sway/display-toggle.sh init"
+exec_always "sleep 2 && ~/.config/sway/display-toggle.sh apply"
exec systemctl --user start sway-session.target
exec ~/.config/sway/tb-autostart.sh
diff --git a/dot_config/sway/executable_display-toggle.sh b/dot_config/sway/executable_display-toggle.sh
index 66747fb..08481dc 100755
--- a/dot_config/sway/executable_display-toggle.sh
+++ b/dot_config/sway/executable_display-toggle.sh
@@ -1,10 +1,13 @@
#!/bin/sh
# 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).
+# apply re-apply whatever is in the state file. Used by sway's
+# exec_always at startup and on every config reload (sway
+# reload re-enables all outputs side-by-side by default;
+# this restores the user's chosen layout). First boot
+# defaults to laptop-off when no state file exists.
+# init force laptop-off; used by the hotplug watcher when a
+# newly-plugged external should preempt whatever was saved.
STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/display-mode"
@@ -19,7 +22,7 @@ if [ -z "$EXTERNAL" ]; then
swaymsg output "$LAPTOP" enable pos 0 0 || true
echo "laptop-only" >"$STATE_FILE"
fi
- [ -z "$1" ] && notify-send "Display" "No external display connected"
+ [ -z "${1:-}" ] && notify-send "Display" "No external display connected"
exit 0
fi
@@ -28,10 +31,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
- NEXT="laptop-off"
-elif [ "${1:-}" = "apply" ]; then
+if [ "${1:-}" = "apply" ]; then
NEXT=$(cat "$STATE_FILE" 2>/dev/null || echo "laptop-off")
+elif [ "${1:-}" = "init" ]; then
+ NEXT="laptop-off"
else
CURRENT=$(cat "$STATE_FILE" 2>/dev/null || echo "laptop-off")
case "$CURRENT" in
@@ -46,12 +49,12 @@ case "$NEXT" in
swaymsg output "$EXTERNAL" enable || true
swaymsg workspace number 1 || true
echo "laptop-off" >"$STATE_FILE"
- [ -z "$1" ] && notify-send "Display" "Laptop screen off"
+ [ -z "${1:-}" ] && notify-send "Display" "Laptop screen off"
;;
side-by-side)
swaymsg output "$LAPTOP" enable pos 0 0 || true
swaymsg output "$EXTERNAL" enable pos "$LAPTOP_WIDTH" 0 || true
echo "side-by-side" >"$STATE_FILE"
- [ -z "$1" ] && notify-send "Display" "Side by side"
+ [ -z "${1:-}" ] && notify-send "Display" "Side by side"
;;
esac
diff --git a/dot_config/systemd/user/swayidle.service b/dot_config/systemd/user/swayidle.service
index a3a5a7e..478c8f8 100644
--- a/dot_config/systemd/user/swayidle.service
+++ b/dot_config/systemd/user/swayidle.service
@@ -11,7 +11,6 @@ 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