You are not logged in.

#1 2021-04-16 10:16:29

thetoric
Member
Registered: 2018-06-03
Posts: 8

[Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Ive gotten pretty used to using my caps lock as a second ctrl key on my desktop, and recently acquired a new (to me, actually more like 5 years old) laptop.

Problem is, I cant use xmodmap as I am running the laptop x-less for battery life reasons (as well as the fact I can do 90% of things I need to do from tmux, so why install x?) Referencing https://wiki.archlinux.org/index.php/Li … r_examples, I made a file ctrl.map containing

keycode 58 = Control

and load it with loadkeys
It makes caps lock to a second control, however, when I press caps lock, it never releases, and ctrl stays stuck on until I reboot the machine, making the keyboard unusable.

Ive found a couple resources on this, including https://askubuntu.com/questio … than-gnome that says I should add

XKBOPTIONS="ctrl:swapcaps"

to

/etc/default/keyboard

, as that file is shared by both X and the tty, but wont XKBOTIONS be ignored by the tty as it is an X specific option? or is xkb agnostic to X itself? (archwiki only mentions it in respect to X, so I assume not.) Also, from further reading and some exploration on my system, this seems to be debian specific, and /etc/default/keyboard does not exist on arch systems.

The only other posts about this issue is https://bbs.archlinux.org/viewtopic.php?id=241906, which never got any replies.

Last edited by thetoric (2021-04-21 00:09:54)

Offline

#2 2021-04-16 16:26:50

seth
Member
Registered: 2012-09-03
Posts: 50,012

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Sounds like you somehow ran into

man 5 keymaps wrote:

       Note  that you should be very careful when binding the modifier keys, otherwise you can end up with an unusable keyboard mapping. If you for example define a key to have Control in its first column and leave the rest of the
       columns to be VoidSymbols, you're in trouble. This is because pressing the key puts Control modifier in effect and the following actions are looked up from the fifth column (see the table above). So, when  you  release  the
       key,  the  action  from the fifth column is taken. It has VoidSymbol in it, so nothing happens. This means that the Control modifier is still in effect, although you have released the key.  Re-pressing and releasing the key
       has no effect. To avoid this, you should always define all the columns to have the same modifier symbol. There is a handy short-hand notation for this, see below.

Offline

#3 2021-04-16 20:08:46

thetoric
Member
Registered: 2018-06-03
Posts: 8

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

man 5 keymaps, just a few lines down wrote:

For  added convenience, you can usually get off with still more terse definitions. If you enter a key definition line with only and exactly one action code after the equals sign,
       it has a special meaning. If the code (numeric or symbolic) is not an ASCII letter, it means the code is implicitly replicated through all columns  being  defined.

Does that mean that this line is not accurate? the 'Control' code should be replicated throughout every column...

Im gonna need to edit the archwiki page when this is done, as the contents of the custom file are taken directly from there...

Offline

#4 2021-04-17 06:58:28

seth
Member
Registered: 2012-09-03
Posts: 50,012

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

I would assume it is - thus "somehow".
From your OP I assume you're just augmenting an existing keymap? Not sure whether that still holds or whether there's maybe a stray blank or whatever.
Did you try a full line?

Offline

#5 2021-04-17 15:30:42

thetoric
Member
Registered: 2018-06-03
Posts: 8

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

putting Control in 16 times (tab seperated) works. (I decided not to put it in 256 times, as I dont think my current keymap uses the left/right specific modifiers.)

The bug (I assume its a bug, even the man page gives the swap caps lock and ctrl example) seems to exist on both of my machines... Would this be something to report to arch maintainers, or upstream?

Offline

#6 2021-04-17 15:35:10

seth
Member
Registered: 2012-09-03
Posts: 50,012

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Upstream.

seth wrote:

I assume you're just augmenting an existing keymap?

Or did you copy your main keymap and edit and loaded that?

Offline

#7 2021-04-17 19:13:01

thetoric
Member
Registered: 2018-06-03
Posts: 8

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Just augmenting the existing keymap. Apart from comments, the only line is

keycode 58 = Control     Control         Control         Control         Control     Control  Control         Control         Control         Control         Control     Control  Control         Control         Control         Control

Offline

#8 2021-04-17 20:22:22

seth
Member
Registered: 2012-09-03
Posts: 50,012

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Do you get the same behavior when copying & editing your main layout?
(idk whether this is a bug but feel that this could be a relevant distiction that's gonna be thrown into your face. also curiosity ;-)

Offline

#9 2021-04-17 22:11:03

thetoric
Member
Registered: 2018-06-03
Posts: 8

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Works correctly when I copy and edit us.map.

Seems like it does not expand single entries when they are overwriting the default keymap.

Offline

#10 2021-04-17 22:16:16

seth
Member
Registered: 2012-09-03
Posts: 50,012

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

It's either a bug in loadkeys or the manpage is incomplete ;-)

Offline

#11 2021-04-17 22:50:56

thetoric
Member
Registered: 2018-06-03
Posts: 8

Re: [Solved] Setting caps lock to ctrl with loadkeys locks ctrl on.

Either way, im working on a bug report. I can only assume something like this is an upstream bug, not something I should report on the distro bug tracker... Looks like loadkeys is provided by the kbd package. Ill try to get something on thier mailing list in the next few days... Bug or incomplete manpage, still upstreams wheelhouse. Thanks for guiding me to a workaround.

Offline

Board footer

Powered by FluxBB