dotfiles/scripts/setxkbmap-next
tavo-wasd fd69ecbbe6 init
2023-05-08 20:39:39 -06:00

25 lines
667 B
Bash
Executable file

#!/bin/sh
# Switch between keyboard layouts
# Add whatever layouts you want
set -- us latam
# Get current layout, and total
current=$(setxkbmap -query | grep layout | cut -d " " -f 6)
total=$(counter=0 ; for layout in "$@" ; do : $((counter+=1)) ; done ; echo "$counter")
index=1
# For each layout, find whichever is currently
# selected, and apply the next one
for layout in "$@" ; do
if [ "$layout" = "$current" ] ; then
: $((index+=1))
[ "$index" -gt "$total" ] && index=1
setxkbmap $(eval "echo \${${index}}")
break
fi
: $((index+=1))
done
# Restart statusbar module (dwm & dwmblocks)
kill -46 "$(pidof dwmblocks)"