1

I tried the solution here to remap Caps Lock to Control.

Open the following for editing:

sudo vi /etc/default/keyboard

And edit XKBOPTIONS="ctrl:swapcaps"

Then, reconfigure:

sudo dpkg-reconfigure keyboard-configuration

I started with exactly that not to get too crazy. It worked. But now I can't get it to go back.

I edited the keyboard file back to its original contents...

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

... but even after rebooting, caps is still control and control is still caps.

Where should I look to set things back?

What should I do to get both Control and Caps to invoke Control?

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy
ruffin
  • 111
  • 3
  • @guiverc I did both. Edited and rebooted, then edited, ran `sudo dpkg-reconfigure keyboard-configuration` and then rebooted. In the reconfigure flow, I just accepted every default -- not sure if there was something else I needed to do, but I think that was right. – ruffin Feb 21 '23 at 02:17
  • So I've [followed this guide](https://fostips.com/remap-keys-ubuntu-22-04/) and set everything up with Tweaks, which does work. It even saw that I had Caps Lock and Control swapped. I'm not sure what file it edited to get that working, though, as the `keyboard` file still has the contents I pasted, above. – ruffin Feb 21 '23 at 02:57
  • It probably propagated to your user level settings: `gsettings get org.gnome.desktop.input-sources xkb-options` – Gunnar Hjalmarsson Feb 21 '23 at 12:19
  • @GunnarHjalmarsson That gives `['caps:ctrl_modifier']`, fwiw, which is what we'd expect, I believe. – ruffin Feb 25 '23 at 16:29
  • Yes, and to reset it you can simply do: `gsettings reset org.gnome.desktop.input-sources xkb-options` – Gunnar Hjalmarsson Feb 25 '23 at 16:49
  • @GunnarHjalmarsson Appreciate the help. Seems to be a disconnect here; my apologies. For instance, "_but even after rebooting, caps is still control and control is still caps_"; what did I do incorrectly? You don't mention `sudo dpkg-reconfigure keyboard-configuration` specifically. Is that required or a red herring? etc My assumption is that the steps above didn't work (b/c they didn't for me -- could be PIBKAC, could be instructions; trying to find out which). What are the right ones? etc etc Thanks again. – ruffin Feb 25 '23 at 17:04
  • When you first added a value to `XKBOPTIONS` in `/etc/default/keyboard`, that value automatically was added to your user settings at next login. When you changed `/etc/default/keyboard` back to its original content, the value was still kept in your user settings. You you should have run the reset command too, as I mentioned above, to also drop the value from your user settings. Alternatively you could have dropped it using Tweaks. – Gunnar Hjalmarsson Feb 25 '23 at 17:50

2 Answers2

1
  • Install the gnome-tweaks package, if it's not already installed.
  • Open Tweaks -> Keyboard & Mouse -> Additional Layout Options -> Ctrl position
  • Uncheck the "Swap Ctrl and Caps Lock" option.
  • Check the "Caps Lock as Ctrl" option.
Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94
  • So, as [I mentioned](https://askubuntu.com/questions/1455915/how-do-i-map-caps-and-control-to-control/1455998#comment2545019_1455915), I tried that and it worked, but I wanted to figure out what and how it solved the problem. If the secret is to get `['caps:ctrl_modifier']` in there, what did I do wrong initially and how should I edit that outside of Tweaks? – ruffin Feb 25 '23 at 16:31
  • @ruffin: I thought those questions were answered implicitly. What you need to keep in mind is that there are two levels for setting XKB options: system wide (in `/etc/default/keyboard`) and per user via Tweaks or the `gsettings` command. – Gunnar Hjalmarsson Feb 25 '23 at 16:56
1

You can use the remapper deamon keyd for this purpose. See this answer for installation, usage and tips.

After installation, use the config below.

[ids]

*

[main]

capslock = layer(control)

Rasmus
  • 8,115
  • 11
  • 45
  • 72