xset led named "Scroll Lock" xset -led named "Scroll Lock"
xsetwon’t cause the system to forget or mismatch the organic state of the LED. Turning an LED “off” with
xsetjust returns it to it’s organic state so if it was originally on before turning it “on” then it’ll stay on.
xsetdoesn’t activate the mode the LED is associated with. *
So what about the other LEDs?? This command will turn them all on…
# 1. Turn on the Christmas Tree! xset led on # 2. Express disappointment # 3. Check if it did anything xset q
Keyboard Control: auto repeat: on key click percent: 0 LED mask: ffffe7fc XKB indicators: 00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: on 03: Compose: on 04: Kana: on 05: Sleep: on 06: Suspend: on 07: Mute: on 08: Misc: on 09: Mail: on 10: Charging: on 11: Shift Lock: off 12: Group 2: off 13: Mouse Keys: on
# 4. Switch LEDs off xset led off
* It turns out most distros consider Caps Lock and Num Lock LEDs forbidden fruit and for good reason. Below is a guide to allow you to use them but (at least on my machine) they reliably produce unpredictable keyboard results such as the Enter key being held down, Shift being held down, being totally locked out of the numlock keys and sometimes all of these behaviors stick around even after the LEDs are turned off.
Scroll lock appears to be the only “safe” LED compared to the fore-mentioned. Caps Lock is usually ok and Num Lock opens the door to the chaos dimension.
# Enabling Caps Lock and Num Lock LEDs (caution, see above ^) # Guide applies to: Debian, Ubuntu, Fedora and CentOS # === Option 1. Manually adjust: === # Caps Lock: sudo nano /usr/share/X11/xkb/compat/ledcaps # Change: !allowExplicit; to allowExplicit; # Num Lock: sudo nano /usr/share/X11/xkb/compat/lednum # Change: !allowExplicit; to allowExplicit; # === Option 2. Auto-adjust: === # Caps Lock: sudo sed -i 's|\!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps # Num Lock: sudo sed -i 's|\!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/lednum # Logout and back in # Test xset led named "Caps Lock" xset -led named "Caps Lock" xset led named "Num Lock" xset -led named "Num Lock"
cd /usr/local/bin sudo touch ./sl-alarm sudo chmod 755 ./sl-alarm sudo nano ./sl-alarm # Paste the following:
#!/usr/bin/env sh # If the application is terminated, set Scroll Lock LED off trap 'xset -led named "Scroll Lock"' EXIT while true; do xset led named "Scroll Lock" sleep 0.4 xset -led named "Scroll Lock" sleep 0.4 done
# Save & quit # Run sl-alarm # Ctrl + c to quit
You can also activate LEDs using their id from
xset q + 1
# Example: xset led 1 # Caps Lock xset led 2 # Num Lock xset led 3 # Scroll Lock