Change the status of the keyboard leds, from within an X session, without root access
In principle, you should be able to do it with the venerable xset
command.
xset led named 'Caps Lock'
or xset led 4
to set LED number 4, if your system doesn't recognize the LEDs by name.
However, this doesn't seem to work reliably. On my machine, I can only set Scroll Lock this way, and I'm not the only one. This seems to be a matter of XKB configuration.
The following user-level work-around should work (for the most part):
Extract your current xkb configuration:
xkbcomp $DISPLAY myconf.xkb
Edit the file
myconf.xkb
, replacing!allowExplicit
withallowExplicit
in the relevant blocks:indicator "Caps Lock" { allowExplicit; whichModState= locked; modifiers= Lock; }; indicator "Num Lock" { allowExplicit; whichModState= locked; modifiers= NumLock; };
Load the new file
xkbcomp myconf.xkb $DISPLAY
Now setting the leds on and off with xset
should work. According to the bug report, you will not be able to switch the leds off when they are supposed to be on (for example if CapsLock is enabled).