- Change the behaviour of Ctrl+Left to do Home (instead of previous word), systemwide or at least for all X programs: not possible.
- Change Alt+Left to do Ctrl+Left systemwide: not possible.
Possible and not too difficult with XKB, the standard X11 keyboard layout mechanism. You just need an apropriate key "type", and a "Redirect action"
As it's not too difficult, you can probably show us how to do that?
- Change the behaviour of Fn+Left to do Home: not possible either (the Fn key could be the left Windows key or CapsLock for example).
Something like this already part of the Neo 2 and AdNW layout that ship with the standard layouts (just that Home is on Fn+A, and Fn is called ISO_Level5_Shift). It would work more robustly with a Redirect action in additon.
Can show us how to do that?
For Redirect actions and types, see an example in the following post:
https://geekhack.org/index.php?topic=53137.msg1184091#msg1184091
For a "Fn" key, see the neo layout in symbols/de of your local xkeyboard-config installation. For combining this with Redirect actions for better robustness, see the modified xkeyboard-config here:
http://adnw.de/uploads/Main/Downloads/AdNW-xkc.tar.gz
Here, have a look at the file compat/misc for definitions of keysyms that do a redirection, and at symbols/de and symbols/adnw for their use.
I have tried what you have suggested in the GeekHack post you have linked to above, and I'm running into problems.
My first step has been to remap Control+arrow to Home, End, PgUp and PgDn.
For example, Ctrl+Up is supposed to do PgUp.
In my ".xkb" file, created from my default configuration with "xkbcomp :0 my.xkb", I have found that I already have a "type" for Control, which is called "PC_CONTROL_LEVEL2".
Here it is:
type "PC_CONTROL_LEVEL2" {
modifiers= Control;
map[Control]= Level2;
level_name[Level1]= "Base";
level_name[Level2]= "Control";
};
So I just use this "type" to remap the UP key, exactly as you suggested:
key <UP> {
type="PC_CONTROL_LEVEL2",
symbols[Group1] = [ Up, NoSymbol ],
actions[Group1] = [ NoAction(), RedirectKey(key=<PGUP>,clearMods=Control) ]
};
I then feed xkbcomp with "my.xkb":
xkbcomp my.xkb :0
This worked fine in Firefox and OpenOffice. I thought it was great.
Then I discovered that the remapping did not work in some other programs. For example, it does not work in gedit.
What happens in these programs is that when I press Ctrl-Up they believe that Ctrl-PgUp has been pressed. The "clearMods" stuff is not working.
I'm using Ubuntu 12.04, but it appears to be a known problem in others versions of Ubuntu, and probably other versions of Linux:
https://bugs.freedesktop.org/show_bug.cgi?format=multiple&id=78661Apparently, client programs are free to ignore the "clearMods" thing, which means that remapping is actually not transparent. It is somehow exposed to the client programs, which defeats the purpose of remapping and leaves open the possibility of programs not behaving according to the remapping.
The other way to remap, with:
key <UP> {
type="PC_CONTROL_LEVEL2",
symbols[Group1] = [ Up, Prior ]
};
...exhibits exactly the same problem, but in reverse. It works in gedit but does not in Firefox or OpenOffice.
This version does not work either:
key <UP> {
type="PC_CONTROL_LEVEL2",
symbols[Group1] = [ Up, Prior ],
actions[Group1] = [ NoAction(), RedirectKey(key=<PGUP>,clearMods=Control) ]
};
I have tried a few others without success: clearMods=Control+LControl+RControl, clearMods=all...
Do you have a solution for this? Did I do something wrong?
I'm actually wondering if you are yourself using (or tried) remapping the way you have described it, and if so why you are not affected by this problem.
The main problem is that XRecord/XTest won't let you remove key events from the queue.
I agree, and I handle this in the same way as you do. There might be an alternative to XRecord, described here:
http://lists.freedesktop.org/archives/xorg/2010-September/051098.html
But it is complicated and unproven.
It looks like they are doing it in a similar way as we do it: to "own" Control you are going to associate it with an unused keycode.
This will suffer from the problem I have described: this will prevent Ctrl-Alt-Backspace and Ctrl-Alt-Fx to work as they should.
- Change Shift so a single press on Shift does "persistent Shift", like on a mobile phone, to capitalize only the next letter: GTFO.
It's called "Latch" in XKB. Simple.
Can you tell me how to activate it?
There is a keysym called 'ISO_Level2_Latch'. You map it like you would map a shift key. In xmodmap syntax:
keycode 62 = ISO_Level2_Latch
add shift = ISO_Level2_Latch
(Note I cannot test this, as my xkeyboard-config is too much customized to make this meaningful). You can also latch modifiers other than shift, even multiple modifiers at the same time. There are predefined ISO_Level3_Latch and ISO_Level5_Latch keysyms, for other stuff you have go a bit deeper. To see a predefined layout using latches, see the T3 layout in symbols/de of xkeyboard-config.
Thank you, this works.