Friday, July 10, 2009

Switching Keyboard Layout from the Command Line

I use two keyboard layouts: us (American English) and il (Hebrew), with us being the default. I use a key combination (<SHIFT>-<CAPS>) to switch between them.

I needed a way to make sure that, when a certain application is launched, the keyboard layout is pre-selected to be il. My first attempt was to do the following with setxkbmap:
setxkbmap il ; application
I was rather amused to find that I couldn't get back to the us layout...

Here's how I do it now, that I've learned my lesson:
setxkbmap "il+us:2" ; application ; setxkbmap "us+il:2"

No comments:

Post a Comment