You are not logged in.

#1 2025-08-10 10:28:48

jpka
Member
Registered: 2024-12-04
Posts: 7

ShiftLock for Spacebar key using CapsLock LED

Hello.

I need to make Spacebar key to "just" issue Shift+Spacebar+UnShift codes, but only when Caps Lock LED is lit, else Spacebar should work as usual.

1. I need not to just Caps Lock as modifier, but Caps Lock LED. No one manual/web page refer to exactly LED state when mentioned Caps Lock.
2. Altering of CapsLock button behaviour (normal LED control) is not allowed, but some background script can be added to this button press, if need.
3. I need not to just to issue one code (as it, unlike Shift+letters, is not defined for Shift+Spacebar?), but, need to issue Shift press, Spacebar, Shift release, and it should be very fast: way faster than xdotool key --delay 0 allows.
4. I need to alter only Spacebar behaviour, but not any others.

Large amount articles were studied, and attempts (and reboots) were made, like xkbset sticky -twokey -latchlock, xbindkeys, xmodmap -e "keycode 66 = Shift_Lock", setxkbmap -option caps:shiftlock, etc, and all of these are not work as i need.

Example: .xbindkeysrc

keystate_capslock = enable
"xdotool key --delay 0 shift+space"
  Caps_Lock + space

then

xbindkeys

gives just non working Spacebar key, and can be recovered by reboot only, afaik.

I know that simple things are often hard under Linux (just as insanely complex tasks are quite easy with it), but this one looks impossible. Keyboard processing was fundamentally changed several times, not easy to find currently supported solutions, articles/commands are can be outdated... Are there chances to make it work?

I use classic X11 and XFCE, US-only kbd layout.

Thanks!

P.S. I've read Archwiki Keyboard section, but no luck, currently.

Offline

#2 2025-08-20 17:57:50

mesaprotector
Member
Registered: 2024-03-03
Posts: 182

Re: ShiftLock for Spacebar key using CapsLock LED

Can you not just rely on reading the LED status in /sys? This would vary by hardware, the below will not work on your system as-is, but it works for me:

cat /sys/devices/pci0000:00/0000:00:14.0/usb1/1-9/1-9:1.0/0003:048D:C986.0001/input/input4/input4::capslock/brightness
1

Offline

#3 2025-08-21 08:03:57

jpka
Member
Registered: 2024-12-04
Posts: 7

Re: ShiftLock for Spacebar key using CapsLock LED

Thanks! It works well in my case:

cat /sys/class/leds/input3\:\:capslock/brightness

It makes me feel one step closer to solution.

However, ultimate problem is a bit more complex. I need not to just issue keycode, but keycodes combination/chord. All solutions i've seen so far, are can be quite smart in analysis, but anyway results in only one keycode issued per trigger. However, i've found xremap which offer "even to a key sequence" remapping. I've asked about my problem: https://github.com/xremap/xremap/discussions/726 and, together with this LED access, it looks possible.

Thanks again.

EDITED: Example. xkeyboard-config says: "caps:shiftlock Caps Lock toggles Shift Lock (affects all keys)". Can't be used due to, for example, cursor keys also "shift'ed" then. If only another option can be possible, like

setxkbmap -option caps:shiftlock_space

Or (makes way more sense for other users, yet perfectly fine for me)

setxkbmap -option caps:shiftlock_letters_and_space

It would be solution.

Last edited by jpka (2025-08-21 09:27:38)

Offline

Board footer

Powered by FluxBB