I have the same issue. From the doc, one could guess that the correct syntax would be something like that :
$ setxkbmap -I$HOME/.config/xkb -option mine:accent
Note : ~
doesn't work with the -I
option
with
~/.config/xkb/symbols/azerty_altgr
partial default
xkb_symbols "accent" {
include "level3(ralt_switch)"
key <AE02> { [ NoSymbol, NoSymbol, eacute, NoSymbol ] };
key <AE07> { [ NoSymbol, NoSymbol, egrave, NoSymbol ] };
key <AE09> { [ NoSymbol, NoSymbol, asciicircum, NoSymbol ] };
key <AE10> { [ NoSymbol, NoSymbol, agrave, NoSymbol ] };
};
or whatever symbole file you have and
~/.config/xkb/rules/evdev
! option = symbols
mine:accent = +azerty_altgr(accent)
Unfortunately, it doesn't work.
The only solution I found is the following :
Use the same files described above. Set all native option using setxkbmap -option caps:swapescape,whatever
. Then :
$ setxkbmap -print > tempfile.txt
and edit tempfile.txt
in order to add your custom option in the xkb_symbols
line :
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+fr:2+inet(evdev)+capslock(swapescape)+azerty_altgr(accent)" };
xkb_geometry { include "pc(pc104)" };
};
and finaly :
xkbcomp -I$HOME/.config/xkb tempfile.txt $DISPLAY
It can be generalised for any number of options.
This solution is deprecated according to Archlinux wiki.
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:
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.
Best Answer
XKB layouts are defined in a model called
RMLVO
: Rules, Model, Layout, Variant, Options. The system XKB database is usually in/usr/share/X11/xkb
:The
keycodes
directory will define keynames like<CAPS>
or<AC01>
from scancodes that the keys are actually generating.setxkbmap -query -verbose 10
will show you exactly what files are accessed to build your current keymap; when it sayskeycodes: evdev+aliases(qwerty)
, it's loading the../keycodes/evdev
file and theqwerty
stanza from the../keycodes/aliases
file. If you use tools likexev
to determine what keycode a key is generating, those files will show what keyname is mapped to that code.Your modifier question is tougher. I've only seen reference to 8 ISO levels, and I'm not sure if that's an XKB limitation or simply that no common layouts use more than that. (After examining this further, I'm pretty sure you'd have to alter XKB code to add additional
As you can see, in an 8-level layout there's only 2 keys that act as "new modifier" keys. See
/usr/share/X11/xkb/compat/level5
and/usr/share/X11/xkb/types/level5
, where level5 shift, latch, and lock behaviors are defined; these are then attached to keys by symbol options defined in/usr/share/X11/xkb/symbols/level5
.If you defined your own
level9
modifier, then, combining with existing levels would give you 8 more levels before you'd need another level modifier:As you can see, this is starting to be a lot of keys pressed at once. Using locks and latches instead of shifts would cut that down, but this would be a very complicated layout, and we've only imagined adding one level chooser. Each additional chooser would double the existing levels.
The "modifiers" you envision are probably selecting one specific level, which is why you think you need so many. You might be able to define selection actions like that, and put them on, say, level3 of those keys, so
level3+key9
gives you alevel14_latch
action, and then whatever key you press next will give you the 14th level of that key.Edit: Another question asked specifically about making an
ISO_Level4_{Shift,Latch,Lock}
, and I demonstrated a fakeISO_Level4_Latch
using existing XKB keysyms and actions. That method should be effective for levels 4, 6, 7 and 8.