dotfiles/scripts/setxkbmap-next
2024-12-28 14:36:59 -06:00

24 lines
490 B
Bash
Executable file

#!/bin/sh
# Switch between keyboard layouts
# Add whatever layouts you want
set -- us latam
current=$(setxkbmap -query | awk '/layout/{ print $2 }')
total="$#"
index=1
for l in "$@" ; do
if [ "$l" = "$current" ] ; then
: $((index+=1))
[ "$index" -gt "$total" ] && index=1
setxkbmap $(eval "echo \${${index}}")
break
fi
: $((index+=1))
done
DWMBLOCKS="$(pidof dwmblocks)"
if [ -n "$DWMBLOCKS" ] ; then
kill -46 "$DWMBLOCKS" 2>/dev/null
fi