Score:1

How do I map caps and control to control

ru flag

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 avatar
ru flag
@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 avatar
ru flag
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.
Gunnar Hjalmarsson avatar
uz flag
It probably propagated to your user level settings: `gsettings get org.gnome.desktop.input-sources xkb-options`
ruffin avatar
ru flag
@GunnarHjalmarsson That gives `['caps:ctrl_modifier']`, fwiw, which is what we'd expect, I believe.
Gunnar Hjalmarsson avatar
uz flag
Yes, and to reset it you can simply do: `gsettings reset org.gnome.desktop.input-sources xkb-options`
ruffin avatar
ru flag
@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.
Gunnar Hjalmarsson avatar
uz flag
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.
Score:1
in flag

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)

Score:1
uz flag
  • 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.
ruffin avatar
ru flag
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?
Gunnar Hjalmarsson avatar
uz flag
@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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.