6

I am one of those people who uses CAPS LOCK to capitalize text, so the issue is quite annoying on Linux distros where there is a delay. I had found a fix for this, which included changing the key<CAPS> data in a keyboard map and reloading the keyboard map to my keyboard. This fix no longer works in Ubuntu 21.04. Here's what I was doing before:

// Create keyboard map
xkbcomp -xkb $DISPLAY myxkbmap
nano myxkbmap

// Replace the part that says key<CAPS> with this:

key <CAPS> {     repeat=no,     type[group1]="ALPHABETIC",     symbols[group1]=[ Caps_Lock, Caps_Lock ],     actions[group1]=[ LockMods(modifiers=Lock), Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]   };

// Reload the file
xkbcomp myxkbmap $DISPLAY

It should be noted that this is not a perfect fix. When typing quickly you'll notice that the word I'm will result in I"m. This is a major improvement over I'M nonetheless.

This works in almost every distro and has historically worked for me in every Ubuntu version to date. When I attempt this in 21.04, it doesn't work and I'm greeted with this warning after creating the keyboard file:

Warning: Could not load keyboard geometry for :0 BadName (named color or font does not exist) Resulting keymap file will not describe geometry

This is the only difference that I noticed between creating the fix on 20.10 and 21.04, yet when I make the changes and reload the file it doesn't fix the issue.

Any ideas on how to fix this? I'm not going to start using shift haha I would rather use Windows. Clearly, they changed something between 20.10 and 21.04 that's affecting this.

3 Answers 3

3

UPDATE Solution is here: Fix CAps LOck delay in Ubuntu 21.04

Ubuntu 21.04 uses Wayland as its default display server, not Xorg. Xorg-specific configuration and tweak tools (which xkbcomp is) will not work on Wayland.

As a temporary measure, I would recommend to just not use Wayland until it's ready and has a considerable user base. Without an active user base, there is always way too many bugs and no one to fix them.

To switch to Xorg:

  1. Log out.

  2. Click on your profile.

  3. On the bottom right corner a display server selection button will appear. Click on it and select Ubuntu on Xorg.

    Display server choice

  4. Now log back in and everything should work.

3

In case anyone still is waiting for answer, there is a solution for both Wayland and Xorg.

Solution: https://forum.manjaro.org/t/caps-lock-behaviour-wayland/79868/8

You will have to edit root file. Would recommend nautilus-admin if using nautilus file manager (nautilus-admin does not work properly on Ubuntu 21.10, other versions are fine), but regular chmod will do the trick.

Instructions

Open your file/folder manager. Navigate yourself to /usr/share/X11/xkb/symbols/ (Ctrl + L). The file you are looking for is called capslock, but before you can edit it, rights for that file need to be changed. Right click in that folder and choose Open in Temrinal.

Enter command: sudo chmod 777 capslock

Now open file capslock with your preferred text editor (You might want to make backup of that file just in case).

Replace

// This changes the <CAPS> key to become a Control modifier,
// but it will still produce the Caps_Lock keysym.
hidden partial modifier_keys
xkb_symbols "ctrl_modifier" {
    replace key <CAPS> {
        type[Group1] = "ONE_LEVEL",
        symbols[Group1] = [ Caps_Lock ],
        actions[Group1] = [ SetMods(modifiers=Control) ]
    };
    modifier_map Control { <CAPS> };
};

with

// This changes the <CAPS> key to become a Control modifier,
// but it will still produce the Caps_Lock keysym.
hidden partial modifier_keys
xkb_symbols "ctrl_modifier" {
          key <CAPS> {
              type="ALPHABETIC",
              repeat=No,
              symbols[Group1]= [ Caps_Lock, Caps_Lock ],
              actions[Group1]= [ LockMods(modifiers=Lock),
                                 LockMods(modifiers=Shift+Lock,affect=unlock) ]
          };
};

Save your changes. Restore file original rights by entering sudo chmod 644 capslock into terminal.

Now install GNOME Tweaks from your software store if you dont have it installed already or sudo apt install gnome-tweaks.

Open GNOME Tweaks. Navigate to Keyboard & Mouse tab. Click Additional Layout Options and open Caps Lock behavior dropdown. Choose Caps Lock is also a Ctrl.

enter image description here

Reboot your Ubuntu and it should work now. You dont need to keep GNOME Tweaks installed, if you wish you could delete it.

1

For Linux Mint 21.1 Cinnamon based on Ubuntu 22.04. Thanks for your answers: https://askubuntu.com/a/1396550/1673413, but I tried gnome-tweaks and it didn't work here, so on Mint 21.1 Cinnamon, after replacing some code on capslock file (/usr/share/X11/xkb/symbols/), we need to activate "Caps lock is also a Ctrl" from "layout keyboard options". placed in: System settings -> Keyboard -> Layouts -> Options... -> check Make Caps Lock an additional Ctrl item in the list.

image additional keyboard setting on Linux Mint 21.1 Cinnamon

edited: note: someone might think LM is not Ubuntu, yeah, LM is not Ubuntu. but, LM is based from Ubuntu.

I put this answer here because there is a similarity of the linux base (ubuntu). whereas the CApslock DElay keyboard fix for LM itself I've never found that really helps other than the 2 answers before me on this question.

but in these 2 answers, there is something that doesn't work for LM.

that's why I'm trying to add an answer.

5
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 16, 2023 at 7:05
  • This answer is unrelated to Ubuntu. As you may or may not know, LM is not Ubuntu. Commented Feb 17, 2023 at 20:36
  • @mikewhatever : yup, LM is not Ubuntu. but, LM is based from Ubuntu. I put this answer here because there is a similarity of the linux base (ubuntu). whereas the CApslock DElay keyboard fix for LM itself I've never found that really helps other than the 2 answers before me on this question. but in these 2 answers there is something that doesn't work for LM, that's why I'm trying to add an answer. Commented Mar 8, 2023 at 9:03
  • Well, many distros are based on Ubuntu. If it makes you happier, all of them are off topic here. Commented Mar 8, 2023 at 12:05
  • After i used code from this comment askubuntu.com/a/1396550/1711808 and used the screenshot steps from this comment askubuntu.com/a/1455166/1711808 it worked perfectly for me in LM <3 thanks a lot Commented Jul 11, 2023 at 5:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .