46

Normally I have caps lock to be a control key.

setxkbmap -option ctrl:nocaps

makes that happen, but I can't remember where I got it from or find any docs (man setxkbmap is singularly unhelpful )

Can anyone tell me the command to put it back to how it normally is, or at least point me at the docs that tell me what -option ctrl:nocaps actually does?

2
  • 11
    To put it back to how it normally is, just setxkbmap -option works for me. Commented Sep 8, 2014 at 19:29
  • Kinda funny when a question is actually the answer of my search. Hehe, thanks! :)
    – raphaklaus
    Commented Jan 25, 2023 at 10:19

2 Answers 2

34

When you have already set something, you might need to clear before setting something new.

To unset:

To put it back to how it normally is, just setxkbmap -option works for me. – Emanuele Natale Sep 8 '14 at 19:29

Example: I was using setxkbmap -option ctrl:swapcaps so that I could deal with (i.e. unset) caps lock after it got set by random quirks. Today I wanted nocaps, but could not set it because the other setting was still active. I used the command above and then I was able to use setxkbmap -option ctrl:nocaps

1
  • 2
    You may want to setxkbmap -print first, to see your existing options. If you have several options set and are only looking to drop one you won't have to guess at what they were. Also, if (like me) you're trying to unset capslock that "randomly" turned on you might notice that you have shift:both_capslock set and realize how it got turned on.
    – Dogmatixed
    Commented Jan 13, 2017 at 1:22
23

Would be really nice to find a complete, readable documentation where is explained how the keyboard mechanism works in Ubuntu and how to locally override it (and how it interacts with layout switching).

I am under the suspicion that there is really few people really understanding it (I remember a famous quote of Stephen Hawkings, methinks, about time); I have collected a bit of links in another answer but still, no general how-to.

Basically you should chase all the definitions for your keyboard starting from /usr/share/X11/xkb/symbols/us --- if your keyboard is us, substitute as needed; there are a lot of options and includes in it, it seems that most of the modifiers keys are in /usr/share/X11/xkb/rules/base, where you can find:

caps:none             =       +capslock(none)
caps:ctrl_modifier    =       +capslock(ctrl_modifier)
ctrl:nocaps           =       +ctrl(nocaps)
ctrl:lctrl_meta       =       +ctrl(lctrl_meta)
ctrl:swapcaps         =       +ctrl(swapcaps)

and in xorg.lst:

ctrl:nocaps    Caps Lock as Ctrl 
...
caps:capslock        Caps Lock toggles normal capitalization of alphabetic characters

among gazillion other things. So what that mean, and what other options you have, are probably dependent on your layout, but you can try to guess something looking there. For example I would try

setxkbmap -option caps:capslock 

to revert it.

Now, what they exactly mean, how do you enable it (via control center -> keyboard or language, via gnome-tweak-tool, command line, init scripts), how to make them impervious to a layout switch, if they work or not (I am unable to disable caps-lock and make it so across layout switches), is another matter.

If anyone can fill in the answer, please do that. I was used to tweak my keyboard with xmodmap, I understand this is superceded, but would it be really nice to have an howto to how to tweak your keyboard...

4
  • 3
    Despite all the upvotes, this actually doesn't work. Previously set options seem to override later options, and you can set multiple conflicting options without the earlier one being deleted.
    – pydsigner
    Commented Jul 7, 2016 at 18:51
  • 2
    @pydsigner sorry --- It worked for me when I posted this, but again, I wouldn't be surprised if something changed. I gave up on having multiple layouts, and I still think that xkb configuration is black magic in general and sheer luck in Ubuntu...
    – Rmano
    Commented Jul 7, 2016 at 19:31
  • 'xbd' in the paths above is a typo and should be xkb Commented Jun 27, 2017 at 22:56
  • 2
    @AaronSkomra, thanks, I think I fixed it. You can also edit the post yourself, no problem!
    – Rmano
    Commented Jun 28, 2017 at 7:14

You must log in to answer this question.

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