Files
dotfiles/.config/xmobar/kbd_cycle.sh
T
Daniele Fucini cc8eaebd5f Switch keyboard layout by clicking the xmobar indicator
Left-click cycles it -> us -> sk(qwerty), right-click cycles backwards, via a
new kbd_cycle.sh that calls setxkbmap like the M-i/M-u/M-s keys.
2026-10-30 21:25:57 +01:00

25 lines
527 B
Bash
Executable File

#!/bin/bash
# Cycle keyboard layout it -> us -> sk(qwerty); "prev" cycles backwards.
current=$(setxkbmap -query | awk '/^layout:/ {split($2, a, ","); print a[1]}')
if [[ "$1" == "prev" ]]; then
case "$current" in
it) next=sk ;;
us) next=it ;;
*) next=us ;;
esac
else
case "$current" in
it) next=us ;;
us) next=sk ;;
*) next=it ;;
esac
fi
if [[ "$next" == "sk" ]]; then
setxkbmap -layout sk -variant qwerty
else
setxkbmap -layout "$next" -variant ""
fi