Interacting with keyboard LEDs

C

Chris Lasher

Is there a way to interact with keyboard LEDs (for Caps/Scroll/Num
Lock) in Python? I'd like to achieve an effect similar to the *NIX
command "setleds -L", but I'm not sure where to start, but I figured
someone out there would have an idea or maybe experience with something
similar. Thanks very much in advance for your help!

Chris
 
J

Jonathan Curran

Is there a way to interact with keyboard LEDs (for Caps/Scroll/Num
Lock) in Python? I'd like to achieve an effect similar to the *NIX
command "setleds -L", but I'm not sure where to start, but I figured
someone out there would have an idea or maybe experience with something
similar. Thanks very much in advance for your help!

Chris

Spur of the moment answer: call setleds program from within your program

better answer (fox X11):
http://python-xlib.sourceforge.net/doc/html/python-xlib_16.html

Take a look at get_keyboard_control() and change_keyboard_control(). As far as
knowing how to properly invoke them, I have no idea, maybe you could google
for examples or take a look at the setleds source?

- Jonathan
 
C

Chris Lasher

Jonathan said:
Spur of the moment answer: call setleds program from within your program

better answer (fox X11):
http://python-xlib.sourceforge.net/doc/html/python-xlib_16.html

Take a look at get_keyboard_control() and change_keyboard_control(). As far as
knowing how to properly invoke them, I have no idea, maybe you could google
for examples or take a look at the setleds source?

- Jonathan

Thanks for your reply, Jonathan. The difficulty with setleds is that
only works from a virtual console (e.g., tty, CTRL+ALT+F1 through F6,
etc.), not from a terminal emulator inside X (e.g., pts, Xterm, Gnome
Terminal, Konsole, etc.), which is the environment where I'd like to
interact with the LEDs. The xlib package looks promising, though. One
thing I don't understand is the 32-bit mask. How does this represent
the LED states? I profess my ignorance.

Thanks!
Chris
 
H

Hendrik van Rooyen

8<-------------------------------
interact with the LEDs. The xlib package looks promising, though. One
thing I don't understand is the 32-bit mask. How does this represent
the LED states? I profess my ignorance.

not sure if this will be of any use - but when you talk to the keyboard, then on
the wire, the bits are in a byte as follows:

LEDS EQU GBITS1 ;LEDS FOR OUTPUT TO KEYBOARD

SCROLL_LOCK_BIT EQU LEDS.0 ; - least significant bit
NUM_LOCK_BIT EQU LEDS.1 ; - bit 1
CAPS_LOCK_BIT EQU LEDS.2 ; - bit 2

They are set following a mode indicator command to the keyboard which is 0xED
I just happen to know this because we made a funny keyboard wedge box once.

Haven't a clue about how xlib achieves this, though...

- Hendrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top