Topic: Switching Keyboard Layouts - the EASY way!
I was frustrated at how I had to bind a different keybinding to each layout I wanted to switch to. So I came up with a simple script which simply checks a file and changes the keyboard layout accordingly. I needed to switch between US and US International, so those are the two layouts my script checks for. However, this can easily be adapted for more than two layouts.
Here's the script:
#!/bin/bash
KEYBOARD=`cat ~/.keyboard`
test "$KEYBOARD" = "us"
RETURN=$?
if [[ $RETURN -eq 0 ]]
then
setxkbmap us intl
echo "us intl" > ~/.keyboard
exit
fi
if [[ $RETURN -eq 1 ]]
then
setxkbmap us
echo "us" > ~/.keyboard
exit
fiTo use this, you need to create the .keyboard file. So open up a terminal and type in
echo "us" > .keyboardThat's it!
To use this for more than two layouts, you would add another RETURN variable (like RETURN2) and test for equality with another of your keymaps. Then, you'd add some more test statements checking first if RETURN is true, and then if RETURN2 is true. If neither is true, you should switch to the third layout.
Now just bind this script to a keyboard shortcut in Openbox and you're good to go! ![]()
Last edited by chaanakya (2011-01-10 21:34:23)
Join SpiderOak using this link and get an extra 1 GB free: https://spideroak.com/download/referral 660e787ff1