Xubuntu: Easily Switch Keyboard Layout
Xubuntu (Ubuntu Linux’s XFCE based flavor) does not come with any graphical utility to switch keyboard layouts. There is a little XKB plugin that you can add to your XFCE panel but it only shows the layout in use. It does not provide an interface to add keyboard layouts neither it allows you to set keyboard shortcuts for switching between layouts. It doesn’t mean that you can not use different keyboard layouts in Xubuntu; the functionality is there waiting for someone to build a tool around it. Untill then, we will have to manually set our keyboard layouts and here is how to do this.
Create a file in /usr/bin/
gksudo "mousepad /usr/bin/fixkeyboard"
Add following lines in this file. I am using US and PK layouts in this example, please change it to the keyboard layouts you want to use. Also note that this example sets xkb option to change groups when both alt keys are pressed together.
#!/bin/bash
setxkbmap -option grp:switch,grp:alts_toggle us,pk
Save the file and exit.
Go to Applications > Settings > Autostarted Applications and click the Add button. In the Name feild type fixkeyboard and in the Command feild type /usr/bin/fixkeyboard press OK and then Close.
You are done. Now whenever you log on to your XFCE session you will be able to switch keyboard layouts by pressing both Alt keys together. If you don’t like the both Alt keys combination then you can try other group switch combinations. Replace alts_toggle in fixkeyboard file with one of the following options:
alt_shift_toggle
ctrl_shift_toggle
ctrls_toggle
Country flags for XFCE xkb plugin are located in /usr/share/xfce4/xkb/flags/. If your country’s flag is missing you can add it there, the file should be in png format and 60 x 40 pixels.


October 13th, 2006 at 5:23 am
This stuff just shows us that xubuntu ain’t getting any attention from developers. hell, what can I say about a distro that won’t install in *vmware* (bug reported, sits there for the latest three alpha / beta relases)? simple: they just didn’t test it… they throwed it out just for the name… no one should be expecting any nice features for xubuntu, a distro that its developers forgot about.
you would be better off with a distro that likes xfce. vector linux maybe. not xubuntu.. for now, it’s just trash that doesn’t smell yet.
October 13th, 2006 at 11:19 am
Towsonu2003 you are right. It is not getting attention of developers and it is not as polished as kubuntu or ubuntu.
October 21st, 2006 at 3:22 pm
[...] My Ubuntu Blog Tips and Advise From a Non-Expert « Xubuntu: Easily Switch Keyboard Layout [...]
October 23rd, 2006 at 7:12 pm
Right-click on a panel, select add item and add the keyboard layout switcher.
(of course
xfce4-xkb-plugin - xkb layout switch plugin for the Xfce4 panel
must be installed and you need to add the desired layout in /etc/X11/xorg.conf, e.g.
Option “XkbLayout” “us, de, fr,ru”
in the keyboard section lets me (and you too?) switch between these layouts)
October 23rd, 2006 at 9:48 pm
Caspar you are right it does let you switch between keyboard layouts. But you will have to click on it to change the layout. The method described in this post tells how to change keyboard layout using keyboard shortcuts, a more usable and accessible approach.
November 24th, 2006 at 1:18 pm
Nice tip Noumaan. Based on what you posted, I tried editing /etc/X11/xorg.conf directly, and I found that adding a line Option “XkbOptions” “grp:switch,grp:alt_shift_toggle” right after Option “XkbLayout” “us,el” works fine, without the need to create a new file. See if it works for you too.
March 15th, 2007 at 12:48 am
ЗдравÑтвуйте
ПодÑкажите,какой вид рекламы Ñффективнее и почему? раÑкрутить нужно Ñайт и объÑвление Ñ Ñ‚ÐµÐ»ÐµÑ„Ð¾Ð½Ð°Ð¼Ð¸ Менеджеров по продажу.Плизз,помогите Ñоветом!!!
Заранее ÑпаÑибо вÑем кто ответит
March 28th, 2007 at 2:01 am
Option “XkbLayout†“us,si,csâ€
Doesn’t work for me…
After I add another us, or remove one of the three it works out…
In the former case flag dissapears in one of the layouts.
Why this happens?
September 4th, 2007 at 5:49 pm
Great keyboard layout trick, it worked for me. Just one question: I used alt_shift_toggle instead of alts_toggle, and only left shift-alt works - right keys combination does nothing. Any idea? Thanks
October 22nd, 2007 at 4:02 am
i used the xfce4-xkb-plugin with a french keyboard and always [left-shift][right-shift] just before logging in a xfce session.
reason for french keyboard: it was free.
March 27th, 2008 at 3:51 pm
You forgot to mention that the file has to be set executable. Thanks for the tip. I now need to swap my control and Win keys to have this machine behaving correctly…
April 19th, 2008 at 9:37 pm
And why is editing /etc/X11/xorg.conf not considered an option? You can just easily add the same line there and won’t have to bother with any autostart items…
April 28th, 2008 at 11:51 am
Still curious: in xubuntu /etc/X11/xorg.conf seems to recognize either keyboard toggle option or keyboard variant:
XkbLayout us,ru
XkbOptions grp:alts_toggle
works (I can switch layouts)
XkbLayout us,ru
XkbVariant us,winkeys
works (I can see correct variant in keyboard settings window)
XkbLayout us,ru
XkbVariant us,winkeys
XkbOptions grp:alts_toggle
does not work (cannot switch layouts but can see variant in keybosrd settings).
All I need is winkey variant or russian keyboard, cannot get it in xubuntu…
Any suggestions?
April 28th, 2008 at 12:08 pm
oops, my previous post - found the problem: there is no such thing - “us” variant of “us” layout. Leaving variant blank for us layout resolved everything.
But it took me couple of hours to figure that out…
June 18th, 2008 at 7:00 pm
There is another way to fix it:
1. Open /etc/X11/xorg.conf or XF86Config.
2. Find lines Section “InputDevice”
Identifier “Keyboard0″ …
3. Add into this keyboard section this line:
Option “XkbOptions” “grp:alt_shift_toggle”
4. Also you can add additional languages into line: Option “XkbLayout” “us,ru,lt”. just separate them with comma.
For Example my keyboard section.
Section “InputDevice”
# generated from default
Identifier “Keyboard0″
Driver “kbd”
Option “XkbModel” “pc105″
Option “XkbLayout” “lt,us,ru”
Option “XkbOptions” “grp:alt_shift_toggle”
EndSection
By the way, yuo can use:
ctrl_shift_toggle
ctrls_toggle
June 18th, 2008 at 7:01 pm
There is another way to fix it:
1. Open /etc/X11/xorg.conf or XF86Config.
2. Find lines Section “InputDevice”
Identifier “Keyboard0″ …
3. Add into this keyboard section this line:
Option “XkbOptions” “grp:alt_shift_toggle”
4. Also you can add additional languages into line: Option “XkbLayout” “us,ru,lt”. just separate them with comma.
For Example my keyboard section.
Section “InputDevice”
# generated from default
Identifier “Keyboard0″
Driver “kbd”
Option “XkbModel” “pc105″
Option “XkbLayout” “lt,us,ru”
Option “XkbOptions” “grp:alt_shift_toggle”
EndSection
By the way, yuo can use:
ctrl_shift_toggle,
ctrls_toggle.
June 27th, 2008 at 2:09 pm
[...] http://ubuntu.sabza.org/2006/10/13/xubuntu-easily-switch-keyboard-layout/ [...]
November 13th, 2008 at 10:26 am
In Ubuntu Intrepid Ibex (8.10), go to System > Preferences > Keyboard.
In the Keyboard Preferences window, select the Layouts tab, press Other Options button and go to the last entry of the popup window, “Layout Switching” and choose from the thousands (grin) of possible combinations. However, the default “Both Alt” intermittently fails on me, so I added “Ctrl-Shift”.
Hope this helps…