.dotfiles/sway/toggle_keyboard_layout.sh

10 lines
297 B
Bash
Executable file

#!/bin/zsh
# Toggle between US (0) and Swedish (1) layouts
current=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_index' | head -n 1)
if [ "$current" -eq 0 ]; then
swaymsg input '*' xkb_switch_layout 1
else
swaymsg input '*' xkb_switch_layout 0
fi