1
0
Fork 0
dotfiles/.local/bin/remaps

36 lines
1015 B
Plaintext
Raw Normal View History

2022-07-04 21:36:33 +02:00
#!/bin/sh
2022-10-27 09:36:59 +02:00
index() {
2023-02-07 17:19:53 +01:00
echo "$groups" | cut -d ' ' -f "$1"
2022-10-27 09:36:59 +02:00
}
2023-02-06 22:51:32 +01:00
if [ "$1" = "-n" ]; then
2023-02-07 17:19:53 +01:00
newgroup="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
elif [ "$1" = "" ]; then
groups="us:dvorak de:nodeadkeys"
current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
i=1
while [ ! "$found" ]; do
group=$(index $i)
if [ "$group" = "$current" ]; then
newgroup=$(index $((i + 1)))
[ -z "$newgroup" ] && newgroup=$(index 1)
found=true
elif [ -z "$group" ]; then
newgroup=$(index 1)
found=true
fi
i=$((i + 1))
done
2023-02-06 22:51:32 +01:00
else
2023-02-07 17:19:53 +01:00
newgroup="$1"
2023-02-06 22:51:32 +01:00
fi
2022-10-27 09:36:59 +02:00
2023-02-06 22:51:32 +01:00
setxkbmap -layout "$(echo "$newgroup" | cut -d ':' -f1)" -variant "$(echo "$newgroup" | cut -d ':' -f2)" -option caps:super -option terminate:ctrl_alt_bksp 1>/dev/null 2>&1 || echo "Unkown keyboard layout"
2022-07-04 21:36:33 +02:00
xset r rate 300 50
2023-02-07 17:19:53 +01:00
killall xcape 2>/dev/null
xcape -e 'Super_L=Escape'
2022-07-04 21:36:33 +02:00
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
2022-10-27 09:36:59 +02:00
sleep 0.03
2023-02-09 14:51:03 +01:00
[ "$1" != "-n" ] && pkill -RTMIN+15 dwmblocks