Can i turn off capslock on my keyboard without using the physical button?

AFTER INSTALLING A COLEMAK-BASED KEYBOARD LAYOUT TO XKB CONFIGURATION FILES MY CAPSLOCK WAS REMAPPED TO BACKSPACE. DUE TO SOME GLITCH IT AFFECTED ALL KEYBOARD LAYOUTS. WAS NOT A HUGE PROBLEM, I’M LIVING WITH THAT FOR A WHILE.

NOW IDK WHAT HAPPENED, BUT CAPSLOCK STATE WAS ACTIVATED AND I CAN NOT TURN IF OFF. IS THERE SOME COMMAND I MAY SEND IN ORDER TO TURN IT OFF? IT SHOULD NOT BE JUST “PRESS <CAPS> BUTTON” COMMAND BECAUSE IT IS REMAPPED AND WILL REGISTER AS <BKSP>. IT SHOULD SEND THE CAPSLOCK COMMAND.

Typing one more sentence painstakingly holding shift because it won’t let me post otherwise.

2 Likes

The following worked for me:

$ sudo dnf install go libxkbcommon-devel scdoc
$ git clone https://git.sr.ht/~geb/dotool
$ cd dotool
$ ./build.sh && sudo ./build.sh install
$ sudo udevadm control --reload && sudo udevadm trigger
$ echo key capslock | dotool
$ # HELLO WORLD
$ echo key capslock | dotool
$ # hello world
$ 

source: ~geb/dotool - Command to simulate input anywhere (X11, Wayland, TTYs) - sourcehut git

1 Like
# CapsLock toggle
sudo dnf install ydotool
sudo systemctl restart ydotool.service
sudo YDOTOOL_SOCKET="/tmp/.ydotool_socket" ydotool key 58:1 58:0

# CapsLock LED toggle
echo 1 | sudo tee /sys/class/leds/input*::capslock/brightness > /dev/null
echo 0 | sudo tee /sys/class/leds/input*::capslock/brightness > /dev/null

# Hardware check
sudo libinput debug-events --show-keycodes
1 Like

LED TOGGLE WORKS, BUT THE FIRST PART DOES NOTHINg.

I RAN IT MANY TIMES. IS YOUR CAPSLOCK REMAPPED TO SOMETHING THROUGH XKB? MAYBE IT REGISTERS AS BACKSPACe?

NO, DOES NOT WORK. MAYBE IT ACTIVATES BACKSPACE, CAN’T CHECK WITH XEv.

OUTPUT WITH BARTHOLOMEW’S SOLUTION:

Failed to open /dev/input/event22 (No such file or directory)
Failed to open /dev/input/event23 (No such file or directory)
Failed to open /dev/input/event24 (No such file or directory)

WITH YOUR SOLUTION:

 event3   KEYBOARD_KEY                +10.937s	KEY_ENTER (28) pressed
-event21  KEYBOARD_KEY                +11.063s	KEY_CAPSLOCK (58) pressed
 event21  KEYBOARD_KEY                +11.075s	KEY_CAPSLOCK (58) released
-event3   KEYBOARD_KEY                +11.095s	KEY_ENTER (28) released

IT REGISTERS AS CAPSLOCK PRESS, BUT DOES NO EFFECT. I WILL TRY TO REBOOT THE SYSTEM.

Fixed it. A simple logout/login was sufficient to reset the capslock state.

1 Like

Just for the record, the man page states that you might need to add your user to the input group.

PERMISSION
       dotool requires write permission to /dev/uinput, which is granted to users in group input by a udev rule.

       You can test:

           echo type hello | dotool

       and if need be, you could add your user to group input with:

           groupadd -f input
           usermod -a -G input $USER

       and then it's foolproof to reboot to make the group and rule effective.