Toggle CAPS LOCK when you press the key

HOw do I turn off the CAPS LOCK when the key is pressed?

it's currently set to turn off on release

4

1 Answer

tl;dr, untested automated way:

xkbcomp -xkb $DISPLAY $HOME/keyboardKeys
sed -iE 's/^key <CAPS> \{[^\n]+/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) ] };/' "$HOME/keyboardKeys"
xkbcomp $HOME/keyboardKeys $DISPLAY
echo 'xkbcomp $HOME/keyboardKeys $DISPLAY' >> .profile

Otherwise, read on.

See if this helps:

Open the terminal and execute:

xkbcomp -xkb $DISPLAY $HOME/keyboardKeys

This will export the current keyboard settings.

Then open the text file, search for a line with:
key <CAPS> {
Replace it with:
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) ] };

Save and close the file.

Now, to temporarily apply that change run this command:

xkbcomp $HOME/keyboardKeys $DISPLAY


I don't know any way to apply this permanently but you may reapply this file change very time your session starts. For that, you can, for example, add that command to the .profile file in your $HOME directory, for example, like so:

echo 'xkbcomp $HOME/keyboardKeys $DISPLAY' >> .profile

Source:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like