Author Topic: Command line LED control?  (Read 7158 times)

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Command line LED control?
« on: December 21, 2011, 07:03:16 PM »
I'd like to be able to control my LEDs (num/caps/scroll.. a couple of others on a laptop, if possible) using the command line. xset seems to be used for this, but AFAICT depends on X (which i don't need). Alternatively, 'actkbd' is able to control a couple of the lights when a key is pressed. I'm not aware of any way to invoke this with a command?. Can anyone suggest a suitable program / solution? (+ If anyone is aware how to control more than just the keyboard LEDs that would also be great.)

Edit: It seems also 'setleds' is another option.. which is part of the 'kbd' pacakage(?)..  but AFAICT there is no package for this in tinycore?
« Last Edit: December 21, 2011, 07:50:48 PM by mb »

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #1 on: December 23, 2011, 06:09:14 AM »
if no one knows anything to control the leds, then how about a program that invokes a key press from cli?


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #2 on: December 23, 2011, 10:58:14 AM »
Hi mb
You could try installing  Xorg-7.5-bin.tcz, (size ~300K). According to the Info tab:
Quote
All binaries from Xorg that don't have dependencies.
See if  xset  works for you. If it does, backup  /usr/local/bin/xset  and then remove the extension.

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #3 on: December 24, 2011, 09:54:35 AM »
I get 'error while loading shared libraries: libXmuu.so.1: cannot open shared object file: no such file or directory' after installing that and running xset.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #4 on: December 25, 2011, 10:37:30 AM »
Hi mb
OK, that was a dumb idea, I see now that  xset  depends on about 5 X libraries. So I decided to try
to make it up to you. Download the two attached files and install the  compiletc.tcz  extension.
Then do the following:
Code: [Select]
chmod 744 compileledcontrol
./compileledcontrol
./ledcontrol ?
That should give you most of what you are looking for. The CapsLock and ScrollLock LED functions
seem to work well. The NumLock works well on my desktop machine but does not play nice with
my laptop. On that it disables the u,i,o,p, etc. keys until you turn the LED off again. Merry Christmas

           [EDIT]: This is for a non X environment.
« Last Edit: December 25, 2011, 10:42:24 AM by Rich »

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #5 on: December 26, 2011, 05:17:05 AM »
Thanks very much!! i'll try and have a go at this today. Merry Xmas, hope you had a good one!

I found the same about no num-lock support with actkbd.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #6 on: December 26, 2011, 07:41:20 AM »
Hi mb
You are welcome. By the way, I neglected to include this in the help text, but if you run the program
with no command line parameters, it will return a number (0-7) representing the current state of
the LEDs. This may come in handy if you plan on doing any scripting with it.
Quote
I found the same about no num-lock support with actkbd.
Although I don't know why, I see now what's happening. The keys that are used to emulate a numeric
keypad on the laptop are behaving like a numeric keypad with NumLock turned off. The J behaves
like a left arrow, 8 behaves like an up arrow, etc. When I have the program turn the LED off, the keys
go back to their normal functions. When I tested, I did it by switching from X to a tty with Ctrl+Alt+F1,
so it's possible there may be a driver in the background getting in the way.
Please try running  ./ledcontrol N  and let me know if it effects those keys on your keyboard.

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #7 on: December 26, 2011, 10:28:40 AM »
i get 'error while loading shared libraries: libmpc.so.2: cannot open object file: No file or directory.' when i run '. ./compileledcontrol'.
[..also it doesn't matter what directory this is all in does it??]

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #8 on: December 26, 2011, 10:58:28 AM »
Hi mb
That is a library for complex numbers which is not used by my program. I compiled under 3.x and
under 4.x and both worked. The one thing I noticed is that compiletc under 4.x now relies on mpc.tcz
which used to be called libmpc.tcx in the 3.x repository. Check if mpc.tcz is installed.

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #9 on: December 26, 2011, 04:01:48 PM »
ok.. i installed mpc [i had a different mpc.tcz installed -music player controller- which i renamed, which might have prevented that complex numbers one installing].

Anyway, now when i run . ./compileledcontrol i get;
'gcc: not found', 'strip: not found'. Both mpc.tcz (as per repository) and compiletc.tcz are in my onboot.lst

edit: a re-run of tce-load -i compiletc in ..../tce/optional seemed to fix that.

edit2: now i get 'syntax error: unexpected "(", with the last command.

e3: when i run './ledcontrol ?' (note, no space) it returns 'Get LEDs failed: Invalid arguement' (--help works but nothing else seems to.. either returns invalid argument or shows the help and doesn't change the LED state)
« Last Edit: December 26, 2011, 04:24:03 PM by mb »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #10 on: December 26, 2011, 05:07:53 PM »
Hi mb
Quote
Get LEDs failed: Invalid arguement
That error will show up if you try to run the program in an X environment, such as from a terminal
like xterm or aterm. Tinycore runs X, Microcore does not. Which are you running?
Quote
ok.. i installed mpc [i had a different mpc.tcz installed -music player controller- which i renamed, which might have prevented that complex numbers one installing].
That was due to a name change of libmpc.tcz to mpc.tcz.
« Last Edit: May 03, 2012, 05:25:02 PM by Rich »

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #11 on: December 26, 2011, 05:41:11 PM »
i'm using microcore.

re: mpc; i know i was just giving full disclosure in case anything was relevant

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #12 on: December 26, 2011, 06:19:46 PM »
Hi mb
I just booted my desktop machine into Microcore and it runs fine. Run the following:
Code: [Select]
ps > ps.txtand attach that file to your next post.

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #13 on: December 26, 2011, 06:24:54 PM »
here we are...

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11295
Re: Command line LED control?
« Reply #14 on: December 26, 2011, 06:43:52 PM »
Hi mb
Can you try it without the actkbd extension loaded?