If you first remove the lock modifier from the Caps Lock key you should then be able to assign the key in Keyboard Shortcuts, use the command below to do that:
echo 'remove lock = Caps_Lock' | xmodmap -
1. add a new XKB partial file
sudo vi /usr/share/X11/xkb/symbols/altgr_vim
with this content:
partial keypad_keys
xkb_symbols "altgr-vim" {
# replace Caps with AltGr
key <CAPS> { [ ISO_Level3_Shift ] };
# Add vim cursor keys to be accessed with AltGr
key <AB02> { [ x, X, Delete, Delete ] };
key <AC02> { [ s, S, KP_Enter, KP_Enter ] };
key <AC03> { [ d, D, Next, Next ] };
key <AC04> { [ f, F, BackSpace, BackSpace ] };
key <AC06> { [ h, H , Left, Left ] };
key <AC07> { [ j, J, Down, Down ] };
key <AC08> { [ k, K, Up, Up ] };
key <AC09> { [ l, L, Right, Right ] };
key <AD07> { [ u, U, Prior, Prior ] };
key <AE03> { [ 3, section, Home, Home ] };
key <AE04> { [ 4, dollar, End, End ] };
};
2. include the partial in your language file
for example for german it is /usr/share/X11/xkb/symbols/de
(where /de
is your language) add this inside the first block (xkb_symbols "basic"
):
include "altgr_vim(altgr-vim)"
Note: This part has to be repeated after every distribution update
3. reload the window session
Press ALT+F2, enter "r" to reload the gnome session or just log out and in again. Now the new key compositions will be available
4. solve some problems
Some applications don't accept the settings, for example: sublime
which can be replaced by atom
.
Some applications need extra settings, e.g. in yakuake
the key-bindings are set to "XFree 4", if you set them to "Linux" or "Solaris", then the XKB settings works there also:
remaining problems:
- some apps still don't accept those settings
- after an upgrade, where the symbols file is updated, you have to repeat step 2
Best Answer
Install Xdotool
and CompizConfig Settings Manager
from Ubuntu Software Center
Disable Caps-Lock by opening Keyboard Preferences
System ▸ Preferences ▸ Keyboard
Goto tab
Layouts
then click the buttonOptions...
Change the key behaviour to CapsLock is disabled
Open CompizConfig Settings Manager
ccsm
Enable Commands plugin then add the following
Add
xdotool key alt+F2
to the first available command slotGoto 'Key Bindings' tab. In the same slot number assign Caps Lock key.
Note: It will show VoidSymbol as the button assigned but this is fine.