[xmonad] keyboard layout change

wagnerdm at seas.upenn.edu wagnerdm at seas.upenn.edu
Thu Sep 22 14:57:48 CEST 2011

The setxkbmap command has options allowing you to switch between  
layouts with a keystroke. For example, I switch between US Dvorak  
("us(dvorak)" layout) and Farsi ("ir" layout) by hitting shift+esc,  
showing the current layout via the scroll lock light on my keyboard.  
To do this, I have this command in .xinitrc:

setxkbmap -option "" -layout "us(dvorak),ir" -option  
grp:shift_caps_toggle -option grp_led:scroll :2

The -option "" at the beginning resets to defaults, and is more  
defensive than actually necessary -- but it's been handy the few times  
I've had to copy and paste that line from .xinitrc because I messed up  
my keyboard mapping in some way.

Good luck!

Quoting "G. Nikiforov" <g_nikiforov at hotmail.com>:

> Hello, I have a question regarding setting a shortcut for changing  
> the keyboard layout in Xmonad. In Gnome there is a graphical utility  
> for this and in FVWM I've done this by using the setxkbmap command  
> in the .fvwmrc file.
> First using the setxkbmap command from the command line works,  
> however one of the layouts that I'm using is Cyrillic, so once I'm  
> in it, there's no way I can go back to a Latin keyboard layout. So I  
> looked up the following website:
> http://www.xfree86.org/current/XKB-Config2.html#5
> and following the advice there created a custom-kbl.conf file in the  
> xorg.conf.d directory. However when I restarted X, all that did was  
> make both my mouse and keyboard inoperational, so I had to reboot  
> using LiveCD and delete the xorg.conf.d directory which I had created.
> Any idea what I should do? Btw, I'm using ubuntu 10.04 and had  
> installed xmonad via the synaptic package manager.
> Thanks a lot in advance.

More information about the xmonad mailing list