11

I wrote a little fetchmail script that checks the remote server and plays an audio file when I have new mail. I also wanted to also light up one of my keyboard lights when the mail was available but I ran into a problem. I am able to light up the scroll lock light with this:

/usr/bin/xset led named "Scroll Lock"

But I can't light up the Caps Lock in the same way:

/usr/bin/xset led named "Caps Lock"

I tried specifying the key with a number (1-6) but despite changing the mysterious 'LED mask' (visible with 'xset q') I saw no change to the lights.

Is this broken because I've mapped my Caps Lock key as another Ctrl?

In ~/.Xmodmap I've got:

keycode 66 = Control_L
clear Lock
add Control = Control_L

I don't want to toggle caps lock, just the light. Is there a way to do this?

Further Explanation

This is on a x86 kubuntu lucid machine but I will migrate to debian later. I'm running the script as a unprivileged user in a python daemon. Running the same script as root won't work because fetchmail is configured for myself as a user. And finally, this is all run in a tmux session.

When I began this process I read about setleds but it seems to be restricted to terminals in non x sessions.

Logging in as root and running 'setleds -D +caps < /dev/tty7' works but running 'sudo setleds -D +caps < /dev/tty7' gives me a permission denied error.

The xset command seems perfect for my application, it just refuses to change the Caps Lock light.

user903115
  • 133
  • 1
  • 6
  • Describe your configuration: OS, machine, etc. – Foo Bah Oct 09 '11 at 04:09
  • Well, my caps lock is still caps lock, and running `xset led on` or `xset -led on` doesn't turn it on, even though the documentation says it should turn on all LEDs. So we can probably rule key remapping out. –  Oct 09 '11 at 04:09
  • 3
    You're sudo command is failing because you are not enclosing the shell redirect with the sudo. This will work... $ sudo sh -c 'setleds -D +caps < /dev/tty7' – John Eikenberry May 12 '13 at 19:53

4 Answers4

13

Execute under root:

setleds -D +caps < /dev/console

Hackish, but works for me :)

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
dragonroot
  • 5,653
  • 3
  • 38
  • 63
1

Caps Lock led (not the functionality) OFF

for a in `ls -d /sys/class/leds/*caps*`;do echo 0 >$a/brightness;done

Caps Lock led (not the functionality) ON

for a in `ls -d /sys/class/leds/*caps*`;do echo 1 >$a/brightness;done
Zibri
  • 9,096
  • 3
  • 52
  • 44
1

Does it need to be xset? Have you ever used setleds?

setleds -D +caps
setleds -D -caps

Brief overview: Linux / Unix Command: setleds

Adam Eberlin
  • 14,005
  • 5
  • 37
  • 49
0

xset without root privileges

Edit /usr/share/X11/xkb/compat/ledcaps once using sed. This change remains permanent, regardless of any reboots.

$ sudo sed -i 's|\!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps

After logging out and in again, the Caps Lock LED can now be controlled without any root privileges using the commands:

$ xset led named 'Caps Lock'
$ xset -led named 'Caps Lock'
Community
  • 1
  • 1
Serge Stroobandt
  • 28,495
  • 9
  • 107
  • 102