Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I light up the Caps Lock light with xset?

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.

like image 498
user903115 Avatar asked Oct 09 '11 04:10

user903115


Video Answer


2 Answers

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
like image 143
Zibri Avatar answered Sep 20 '22 04:09

Zibri


Execute under root:

setleds -D +caps < /dev/console

Hackish, but works for me :)

like image 41
dragonroot Avatar answered Sep 21 '22 04:09

dragonroot