Programmatic way to install xkb keyboard layout

keyboard-layoutxkbxorg

I have a new keyboard layout that is working so far. I want to ship this to users who most probably will have minimal knowledge of Linux. Trouble is to install this layout I have to do a lot of copy paste inside the files in /usr/share/X11/xkb directory. Here are the steps that I am needing to perform.

  • Add the keyboard layout to /usr/share/X11/xkb/symbols/in
  • Add the language to base.xml
  • Add the language to evdev.xml
  • Add the layout to base.lst

How do I make it so that user double clicks on the layout file and it is installed.

I am familiar with shell scripting, so I could do some file manipulation using awk or sed. But, I am not sure I should be doing that.

Best Answer

Can't your user just click on icon which will run xkbcomp or xmodmap which will load the layout?

Edit:

I believe it's not so simple task. You will need to prepare a method of deploying files in places that only root user can access. Probably preparing a system software package (like .deb or .rpm) is best idea. I would use puppet ;-) It would add xkb keyboard layout then you have to add new layout to users' configuration. I can't help you with KDE but in gnome there is a simple tool to get/set settings of dconf – gnome setting store. It is gsettings and it can set up xkb input sources.

Example:

read input sources:

`gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'pl'), ('xkb', 'us')]

setup new keyboard layoyts:

gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'pl'),('xkb','us'),('xkb', 'de+mac')]"`

and there will be an input-sources applet in "systray" user can choose from: enter image description here

But it is for one user only. To make such settings system wide you need to prepare a schema in /etc/dconf/db/localxkb:

[org/gnome/desktop/input-sources]
sources="[('xkb', 'pl'),('xkb','us'),('xkb', 'de+mac')]"

One single software package, which will be installed by user using software management software would do the thing.