Linux – How to turn on/off leds by terminal

keyboardledlinux terminalterminal

I would like turn on/turn off some of my leds running a command on linux.

I use Ubuntu 12.04 LTS.

I tried

xset led named "Scroll Lock"
xset led named "Num Lock"
xset led 2             (this is the number of Scroll Lock as `xset q` says)
xset led 1

but nothing works.

Tried

setleds +num
setleds +scroll

but I got a error message saying Error reading the current settings of flags. Maybe you're not on the console? (I was in a terminal).

So, how can I perform this?

Best Answer

xdotool key Num_Lock

Is the an answer (the easiest you're likely to find); inverting the state, it also provides a path to search (xinput and modifying a slave keyboard state) if you really just want to set an led status.

I too ran across my Num Lock keyboard LED and X11 state differing recently (happens with remote desktops, games, etc)

This reference explains what's going on, and almost has the complete solution (but it has a case-typo, you need Num_Lock not Num_lock).

http://blog.ssokolow.com/archives/2013/04/18/how-to-invert-your-x11-numlock-led/

Related Question