aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/sway/display-toggle.sh
diff options
context:
space:
mode:
authorLibravatar sommerfeld <[email protected]>2026-04-17 10:53:57 +0100
committerLibravatar sommerfeld <[email protected]>2026-04-17 10:53:57 +0100
commit100f6d3a9a018b52cc229b119ff979ab42d6da9d (patch)
tree0ae86f51774b9a46039766d087aefa8146f8276d /home/.config/sway/display-toggle.sh
parent54008f6c0160f987bac294fce71ba6ad1f86b141 (diff)
downloaddotfiles-100f6d3a9a018b52cc229b119ff979ab42d6da9d.tar.gz
dotfiles-100f6d3a9a018b52cc229b119ff979ab42d6da9d.tar.bz2
dotfiles-100f6d3a9a018b52cc229b119ff979ab42d6da9d.zip
feat: add sway wayland compositor config
- Full sway config with vanilla defaults + personal keybinds - Gruvbox dark theme, pixel borders, caps:escape, vim navigation - Window rules (feh/imv floating via class/app_id) - Session env import for systemd/dbus portals - Display mode toggle script (F7): mirror/laptop-off/side-by-side - Dynamic output positioning based on laptop panel width
Diffstat (limited to 'home/.config/sway/display-toggle.sh')
-rwxr-xr-xhome/.config/sway/display-toggle.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/home/.config/sway/display-toggle.sh b/home/.config/sway/display-toggle.sh
new file mode 100755
index 0000000..882a122
--- /dev/null
+++ b/home/.config/sway/display-toggle.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Cycle display mode: mirror → laptop-off → side-by-side
+# Bound to F7 in sway config
+
+STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/display-mode"
+CURRENT=$(cat "$STATE_FILE" 2>/dev/null || echo "mirror")
+
+LAPTOP=$(swaymsg -t get_outputs -r | jq -r '.[] | select(.name | test("eDP")) | .name')
+EXTERNAL=$(swaymsg -t get_outputs -r | jq -r '[.[] | select(.name | test("eDP") | not) | .name] | first // empty')
+
+if [ -z "$EXTERNAL" ]; then
+ notify-send "Display" "No external display connected"
+ exit 0
+fi
+
+# Get laptop panel width for side-by-side positioning
+LAPTOP_WIDTH=$(swaymsg -t get_outputs -r | jq -r ".[] | select(.name == \"$LAPTOP\") | .rect.width")
+[ -z "$LAPTOP_WIDTH" ] && LAPTOP_WIDTH=1920
+
+case "$CURRENT" in
+ mirror)
+ swaymsg output "$LAPTOP" disable
+ echo "laptop-off" > "$STATE_FILE"
+ notify-send "Display" "Laptop screen off"
+ ;;
+ laptop-off)
+ swaymsg output "$LAPTOP" enable pos 0 0
+ swaymsg output "$EXTERNAL" pos "$LAPTOP_WIDTH" 0
+ echo "side-by-side" > "$STATE_FILE"
+ notify-send "Display" "Side by side"
+ ;;
+ side-by-side|*)
+ swaymsg output "$LAPTOP" enable pos 0 0
+ swaymsg output "$EXTERNAL" pos 0 0
+ echo "mirror" > "$STATE_FILE"
+ notify-send "Display" "Mirror mode"
+ ;;
+esac