bin: script to loop through defined xkbmap

master
Guillaume Dott 2012-11-06 23:11:22 +01:00
parent 9f56049a8a
commit 1599871ca9
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#!/bin/sh
#
# Usage: setxkbmap-toggle layout[:variant] [layout[:variant]]...
layout=`setxkbmap -query | sed -n "s/^layout:\s\+//p"`
variant=`setxkbmap -query | sed -n "s/^variant:\s\+//p"`
[ "$variant" = "" ] && CURRENT="$layout" || CURRENT="$layout:$variant"
next=$1
while [ $# -gt 0 ]
do
keymap=$1
shift
if [ "$keymap" = "$CURRENT" ]
then
if [ $# -gt 0 ]
then
next=$1
shift
fi
fi
done
echo "$next" | grep ":" >/dev/null
if [ $? -eq 0 ]
then
layout=`echo $next | cut -f1 -d:`
variant=`echo $next | cut -f2 -d:`
else
layout=$next
variant=""
fi
setxkbmap "$layout" "$variant"
[ "$variant" = "" ] && CURRENT="$layout" || CURRENT="$layout:$variant"
echo $CURRENT