0

I tried to follow https://www.emacswiki.org/emacs/MovingTheCtrlKey which says this can be done this way:

On Debian and derivatives (Ubuntu, Mint etc.)

To make Caps Lock another Ctrl key, edit the file /etc/default/keyboard and change the line which reads

 XKBOPTIONS=""

to

 XKBOPTIONS="ctrl:nocaps"      #
Some people prefer "ctrl:swapcaps"

and then run:

 $ sudo dpkg-reconfigure -phigh console-setup

After I've done this if I click on "Show keyboard layout" it looks like it works: screenshots but it actually doesn't, this remapped capslock key cannot be used in any combos, like Ctrl+A to select all, etc.

What is missing here to remap it properly?

Also I know about Gnome tweak tool, but it can only affect applications that run on top of Gnome, so anything running in Wine for example doesn't receive Ctrl key when I press CapsLock, and I need to do the remap globally. Like AutoHotkey on Windows can do, or like macOS can do with built in setting.

Also tried:

  • editing /usr/share/X11/xkb/keycodes/evdev to let <CAPS> have the same number as <LCTL> (setxkbmap -print -verbose 10 says that these keycodes are being used if I understand it correctly)
  • editing /usr/share/X11/xkb/symbols/pc (changing that line to key <LCTL> { [ Control_L ] };)

both attempts did not work at all.
P.S. after each of these attempts I also did a complete reboot

Complete output of setxkbmap -print -verbose 10:

$ setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us,ru,us
variant:    ,,
options:    grp_led:scroll
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete+ledscroll(group_lock)
symbols:    pc+us+ru:2+us:3+inet(evdev)
geometry:   pc(pc105)
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete+ledscroll(group_lock)"    };
    xkb_symbols   { include "pc+us+ru:2+us:3+inet(evdev)"   };
    xkb_geometry  { include "pc(pc105)" };
};

Complete content of /etc/default/keyboard after editing:

XKBLAYOUT="us,ru"
XKBVARIANT=","
BACKSPACE="guess"
XKBMODEL="pc105"
XKBOPTIONS="grp_led:scroll,ctrl:nocaps"

I have no idea what is "grp_led:scroll" so I thought it'd be safer to leave it there

Update:
Complete output of gsettings get org.gnome.desktop.input-sources xkb-options:

['grp_led:scroll', 'ctrl:nocaps', 'grp:alt_shift_toggle']
  • Can you please edit your question again and show us the output of the command gsettings get org.gnome.desktop.input-sources xkb-options – Gunnar Hjalmarsson Oct 29 '18 at 2:12
  • @GunnarHjalmarsson done – Sarge Borsch Oct 29 '18 at 12:35
  • Thanks. My thought was that there might be some conflict between the desktop settings and the system wide settings in /etc/default/keyboard, but I don't see such a conflict. – Gunnar Hjalmarsson Oct 29 '18 at 16:20
0

I still don't know the correct solution, but it seems that the XKBOPTIONS and changes to files in xkb directory affect everything except Gnome, so if I use it in addition to gnome tweaks then it works in both situations.

  • That's probably it. Settings in Tweaks (i.e. the output from the command I asked you to show) overrides the system wide settings in /etc/default/keyboard as regards the desktop behavior. – Gunnar Hjalmarsson Oct 29 '18 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.