Skip to content

Keyboard layout switching

r0adrunner edited this page Sep 21, 2012 · 6 revisions

If you need to change the keyboard layout, here is a script to do that:

This one changes the KB between the brazilian and american layout every time it is run:

#!/bin/sh
if [ "`setxkbmap -query | awk 'END{print $2}' | grep us`" ]; then
    setxkbmap -layout br
else
    setxkbmap -layout us
fi

# Put here your custom xmodmap config, if any
#${HOME}/.xmodmap.sh

origmap=$(xmodmap -pke | grep -E "^keycode[[:blank:]]*?65")
newmap=$(echo ${origmap} | perl -pe "s/ space/ Control_L/g")
xmodmap -e "$newmap"
xmodmap -e "keycode 255 = space VoidSymbol VoidSymbol VoidSymbol VoidSymbol"
xmodmap -e "add control = Control_L Control_R"
exit 0
Clone this wiki locally