Tiny Core Linux
Tiny Core Extensions => TCE Q&A Forum => Topic started by: mb on December 21, 2011, 10: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?
-
if no one knows anything to control the leds, then how about a program that invokes a key press from cli?
-
Hi mb
You could try installing Xorg-7.5-bin.tcz, (size ~300K). According to the Info tab:
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.
-
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.
-
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:
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.
-
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.
-
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.
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.
-
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??]
-
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.
-
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)
-
Hi mb
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?
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.
-
i'm using microcore.
re: mpc; i know i was just giving full disclosure in case anything was relevant
-
Hi mb
I just booted my desktop machine into Microcore and it runs fine. Run the following:
ps > ps.txt
and attach that file to your next post.
-
here we are...
-
Hi mb
Can you try it without the actkbd extension loaded?
-
just tried that -- no change.
-
Hi mb
This would be a lot easier if I could reproduce the symptoms at my end.
After running ./ledcontrol do any new messages show up in dmesg?
Although it should not be necessary, does sudo ./ledcontrol make any difference?
If those two steps don't produce any answers, try the following:
Open the file ledcontrol.c
Change:
if((fd=open("/dev/tty", O_NOCTTY)) < 0)
to:
if((fd=open("/dev/console", O_NOCTTY)) < 0)
Save the file and run ./compileledcontrol again
You will need sudo after this change.
sudo ./ledcontrol
-
Thanks, changing to /dev/console worked!
now for the cleanup.. i just delete xorg-75-bin and remove it from onboot.lst right? and if i just remove mpc.tcz and compiletc from onboot.lst then none of their dependancies will load, right?.. (is there a quick way to check/remove all unused dependancies??)
((Shame about no num lock. Theres also an 'email alert' led that would have been nice to use.))
-
Hi mb
Thanks, changing to /dev/console worked!
Thanks for bearing with me in sorting this out. Removing the unwanted applications from onboot.lst
will prevent them from loading.
(is there a quick way to check/remove all unused dependancies??)
I'm afraid I don't know how to do that in Microcore.
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.
Does your keyboard behave the same way?
-
I had to connect a display which is why i didn't answer that before. my behavior is similar.. but a little different.
ledcontrol N/n does effectively nothing on its own. HOWEVER, while i press the Fn key after running 'ledcontrol N', then both the LED comes on, and the relevant area works like a num pad. Release Fn key and it is back to normal. I'd love a fix if you are able.
What i'd really like to do is have one of them act as a wifi status LED. Could you suggest something here?? ..all i can think of is running ping on a script every few seconds, which seems a pretty awful solution.
And thank you :)
-
Hi mb
Try running this periodically in a script (replace eth0 with your adapter):
cat /sys/class/net/eth0/operstate
This will return up, down, or unknown for link status. Turn the LED on for up and off for down. If it
comes back as unknown, use the Toggle function for that LED and it will blink at the same rate that
the script is called.
I'd love a fix if you are able.
If I knew how and why the NumLock on a laptop behaved differently, I'd try to fix it.
-
Ok i've had a go but i'm a bit of a noob with shell scripting and it's not working right...
#!/bin/sh
cat /sys/class/net/eth1/operstate | while read line
do
if [ $line == "up" ]; then
sudo /opt/ledcontrol S
else
sudo /opt/ledcontrol s
fi
sleep 2
done
i ran this by adding '/opt/script.sh &' at the end of the dhcp.sh
-
#!/bin/sh
while read line
do
if [ $line == "up" ]; then
sudo /opt/ledcontrol S
else
sudo /opt/ledcontrol s
fi
sleep 2
done < /sys/class/net/eth1/operstate
Please get a book. This is not Linux 101.
-
well, it still doesn't work. I got pretty close, and its not like i opened a new thread about it either.
-
Then try:
#!/bin/sh
while true
do
read line < /sys/class/net/eth1/operstate
if [ $line == "up" ]; then
sudo /opt/ledcontrol S
else
sudo /opt/ledcontrol s
fi
sleep 2
done
-
Thank you, this works.