From 100f6d3a9a018b52cc229b119ff979ab42d6da9d Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 17 Apr 2026 10:53:57 +0100 Subject: 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 --- home/.config/sway/display-toggle.sh | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 home/.config/sway/display-toggle.sh (limited to 'home/.config/sway/display-toggle.sh') 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 -- cgit v1.2.3-70-g09d2