473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Interacting with keyboard LEDs

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

Dec 9 '06 #1
4 3371
On Friday 08 December 2006 23:18, Chris Lasher wrote:
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/d...n-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
Dec 9 '06 #2
Jonathan Curran wrote:
Spur of the moment answer: call setleds program from within your program

better answer (fox X11):
http://python-xlib.sourceforge.net/d...n-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

Dec 9 '06 #3
Chris,
I googled for {xlib caps led} and the first link was to a forum post:
http://forums.whirlpool.net.au/forum...fm/619126.html

The third post down, the guy made a program to set the LED of his scroll lock
key. The C source is at http://members.optusnet.com.au/foonly/hddled.c

If you can manage to convert his code into python w/python-xlib you will be
set. When you do, e-mail me the snippet will you ;)

- Jonathan
Dec 9 '06 #4
"Chris Lasher" <ch**********@gmail.comwrote:
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

Dec 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: skearney | last post by:
When I was in boy scouts, as part of learning Morse code, I was told that the inventor of the typewriter originally put the letter 'e' under the left middle finger, just below its present position....
13
by: Steve Jorgensen | last post by:
Well, it seems that Microsoft, or whatever powers that be have decided it's time for us to have yet another standard keyboard layout change. I think I see that the point of this one was to reduce...
23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
7
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it...
0
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as...
2
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as...
4
by: Melson | last post by:
Hi Can anyone help. I would like to replace the keys on the PC keyboard. For example, when I press Q button it displays A on the screen in any programs (MS Words, Note, Lotus....). And also when...
1
by: yanz | last post by:
Hi everyone. Hope you guys can help me. Attached below are VB6 codes for a hand phone to call to a modem. When the action is executed, a message box will pop out ‘Ring Ring’. I just want to know is...
331
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.