Thursday, June 7, 2012

How to add and switch keyboard layout LXDE - Lubuntu 12.04

After all, I ended up on LXDE shipped by Lubuntu 12.04. It looks really nice, the default theme is perfect (unlike that of Xubuntu).

One tricky thing is though how to add a keyboard layout on Lubuntu 12.04 (if you didn't specify an additional language at installation). Basically, I consider a lack of a working GUI (lxkeymap returns an error) to configure keyboard layouts a big flaw of LXDE (there are other ways to configure this aspect of LXDE of course, I'm just saying no GUI is bad).

So here is what I did to add a new keyboard layout.

1) Add a layout indicator to the panel - right click on the panel - Add / remove panel items - Panel Applets  - Add - Keyboard Layout Switcher.
A switcher will be added to the panel, in Panel Applets you can choose the position for the switcher you like.

2) Next is to add a new layout. For example, I need Russian. This will be done by editing a configuration file. Run:


gksu leafpad /etc/xdg/lxsession/LXDE/autostart

Enter your administrative password to open up the document with root privileges. Then find the line @lxpanel --profile Lubuntu and add the following:

@setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,ru
Save file. Logout, login.
Press alt+shift to see whether the layout changes or not. It should change :)

By the way, there are more ways to add a layout on LXDE. They're nicely listed in this document:
https://wiki.archlinux.org/index.php/LXDE#Keyboard_layout

How to change layout switch shortcut on Lubuntu 12.04

Examine the line - @setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,ru
What you need is "grp:alt_shift_toggle". Replace alt_shift with alt_ctrl, for example.

4 comments:

  1. Thank you, it worked well!
    Also, I didn't have LXDE folder in lxsession. Instead I found Lubuntu folder, which had autostart file, which was needed to be edited.

    ReplyDelete
  2. You don't need to relogin your linux session just execute from terminal window same code without "@"

    ReplyDelete
  3. Thank you, noobish-nix. Solved a problem during a minute.

    ReplyDelete
  4. thank you very much, the only difference is, that my path to autostart file was: "/etc/xdg/lxsession/Lubuntu-Netbook/autostart" and another one "/etc/xdg/lxsession/Lubuntu/autostart"

    ReplyDelete