added compatibility with sway

This commit is contained in:
Jürg Hallenbarter
2026-02-09 11:42:36 +00:00
parent 91b07e4589
commit 1a8b6dc83b
12 changed files with 341 additions and 132 deletions

9
scripts/display-tool.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
if [ -n "$SWAYSOCK" ]; then
# Sway
wdisplays
else
# i3
arandr
fi

10
scripts/keyboard-setup.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
if [ -n "$SWAYSOCK" ]; then
# Sway
swaymsg input "*" xkb_layout "ch"
swaymsg input "*" xkb_variant "de"
else
# i3
setxkbmap -layout ch -variant de
fi

22
scripts/layout-toggle.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Toggle between CH and US layouts
if [ -n "$SWAYSOCK" ]; then
# Sway: get current layout and toggle
current=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_name' | head -1)
if [ "$current" = "Swiss" ] || [ "$current" = "ch" ]; then
swaymsg input "*" xkb_layout "us"
swaymsg input "*" xkb_variant "workman"
else
swaymsg input "*" xkb_layout "ch"
swaymsg input "*" xkb_variant "de"
fi
else
# i3: get current layout and toggle
current=$(setxkbmap -query | grep layout | awk '{print $2}')
if [ "$current" = "ch" ]; then
setxkbmap -layout us -variant workman
else
setxkbmap -layout ch -variant de
fi
fi

9
scripts/lock.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
if [ -n "$SWAYSOCK" ]; then
# Sway
swaylock
else
# i3
i3lock
fi

9
scripts/screenshot.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
if [ -n "$SWAYSOCK" ]; then
# Sway
grim -g "$(slurp)" - | wl-copy
else
# i3
maim -s | xclip -selection clipboard -t image/png
fi

12
scripts/startup.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
if [ -n "$SWAYSOCK" ]; then
# Sway startup commands
# Set cursor (optional, Sway handles this differently)
# For Sway, output configuration should be in the config file, not here
echo "Running Sway startup"
else
# i3 startup commands
xsetroot -cursor_name left_ptr
xrandr --output HDMI-1 --auto --left-of DP-2 --output DP-2 --auto
fi