I want to remap Capslock and I want this remap to work on both my machine with an X server and on machine without X. I also want this remap to be applied on a user level, not on a global level. This answer has a remap solution which works both with and without X. But the remap works globally and requires root permissions. Is it possible to remap a key locally and have it working with and without X?
1 Answer
Well bummers! I've done some research and discovered that changing the keymap to remap CAPSLOCK (for example) REQUIRES root access. I'm sorry.
In the spirit of information, I'll retain what I had been working on here:
You can set up user-only keyboard configurations by putting options in ~/.keyboard
, these will override the system-wide defaults set in /etc/default/keyboard
- NOTE: to get
setupcon
to read your~/.keyboard
, you MUST create~/.console-setup
, an empty file will suffice. The logic insetupcon
does not check for ~/.keyboard, it looks for ~/.console-setup and then reads both files. Tsk Tsk
You didn't specify what you'd like CAPSLOCK to be mapped to, so I'll give several examples.
You can use the /etc/default/keyboard
file as a template if you wish, something like one of these entries in ~/.keyboard
would probably work well for you:
(remember you really only need settings which override the system defaults in /etc/default/keyboard
)
XKBOPTIONS="ctrl:nocaps" # CAPSLOCK => CTRL
XKBOPTIONS="caps:escape" # CAPSLOCK => ESC
XKBOPTIONS="compose:caps" # CAPSLOCK => Compose (my favorite!)
There are (many!) more options available, have a look at the man page for setupcon
(1) and the contents of the file: /usr/share/X11/xkb/rules/xorg.lst
on your system.k
-
OH!
~/.keyboard
and/etc/default/keyboard
set up BOTH console and X settings, a twofer.. but it's a root-twofer (twofer-root? {shrug})– lornixJun 20, 2014 at 0:36 -
1Where are root permissions required if I put my configuration in
~/.keyboard
? Am I missing something? Jun 20, 2014 at 9:58 -
setupcon executes loadkeys, which seems to require root privileges to modify the keyboard mapping. Try
setupcon -k -v
with and without sudo to see errors. I didn't understand the root requirement either.– lornixJun 20, 2014 at 14:51