You are not logged in.

#1 2010-09-15 18:15:29

vitoreiji
Member
Registered: 2009-09-04
Posts: 67

How to control keyboard LEDs via /proc

Hi, I'm trying to set up the led-notification plugin for pidgin in my box, but I don't know how to control my LEDs with "boolean" files.
The plugin works by setting a given file to 0 or 1 to turn the LED on or off, and the file defaults to /proc/acpi/asus/mled.
Problem is I don't have /proc/acpi/asus directory (makes sense, I don't have an ASUS motherboard). I've seen a solved post [1] in the forum but modprobe "asus-acpi" won't work for me. Either will xset, ledcontrol etc, because I need to control the LEDs via file.
I imagine this will be different for each hardware, but I don't know how to find out.

[1] https://bbs.archlinux.org/viewtopic.php?id=37437

EDIT: I had wrongly said that the plugin was called "led-notifier".

Last edited by vitoreiji (2010-09-15 20:04:05)

Offline

#2 2010-09-15 18:23:30

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: How to control keyboard LEDs via /proc

On my keyboard

xset led 3

turns on my scrolllock led
and

xset -led 3

turns it off

Last edited by skunktrader (2010-09-15 18:24:26)

Offline

#3 2010-09-15 18:38:31

codycarey
Member
Registered: 2009-08-21
Posts: 154

Re: How to control keyboard LEDs via /proc

I don't think he wants to use xset though. What type of laptop do you have vitoreiji and which LEDs specifically are you trying to control?

Offline

#4 2010-09-15 19:30:14

vitoreiji
Member
Registered: 2009-09-04
Posts: 67

Re: How to control keyboard LEDs via /proc

codycarey wrote:

I don't think he wants to use xset though. What type of laptop do you have vitoreiji and which LEDs specifically are you trying to control?

I have a Dell Vostro 1014, want to use the scroll lock led.
Thanks!

Offline

#5 2010-09-15 19:52:51

codycarey
Member
Registered: 2009-08-21
Posts: 154

Re: How to control keyboard LEDs via /proc

Can you give a little more context about what you're trying to do? The optimal choice in my opinion would be to use 'xset' as skunktrader pointed out.

Offline

#6 2010-09-15 20:02:07

vitoreiji
Member
Registered: 2009-09-04
Posts: 67

Re: How to control keyboard LEDs via /proc

codycarey wrote:

Can you give a little more context about what you're trying to do? The optimal choice in my opinion would be to use 'xset' as skunktrader pointed out.

There is this pidgin plugin called led-notification (not led-notifier like I said before) that wil cause a led to flash when you get a new message. This plugin controls the led by writing 1 or 0 to a file, like
echo 1 > /proc/acpi/asus/mled
to turn it on (and 0 for off)
But I don't know where in my system I can find the file that controls the leds.
I thought I could write a fuse filesystem that uses xset or ledcontrol to do this, but it sounds a little bit overkill, it would be easier to write another plugin.

Thanks for your dedication!

Offline

#7 2010-09-15 20:07:32

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: How to control keyboard LEDs via /proc

You could write a script that watched a file in your local directory, then issue the appropriate xset commands when pidgin writes a 1 or a 0

Offline

#8 2010-09-15 20:18:00

codycarey
Member
Registered: 2009-08-21
Posts: 154

Re: How to control keyboard LEDs via /proc

Actually it looks like there is another plugin called Command-notification that you can use instead with 'xset'. http://guysoft.wordpress.com/2010/02/14 … w-message/

Try using this plugin manually, and if it works out you should consider taking the AUR package for led-notification and modifying it for command-notification!

EDIT: Added links.

Last edited by codycarey (2010-09-15 20:20:10)

Offline

#9 2010-09-15 20:20:15

hidefromkgb
Member
Registered: 2009-08-03
Posts: 146

Re: How to control keyboard LEDs via /proc

I've modified this plugin a little, so that instead of writing to files, it runs scripts (defined by user, of course).
The script must be able to handle only one parameter that can be "0" or "1".

Can share my modified code if you want me to.

Offline

#10 2010-09-15 20:27:23

codycarey
Member
Registered: 2009-08-21
Posts: 154

Re: How to control keyboard LEDs via /proc

hidefromkgb wrote:

I've modified this plugin a little, so that instead of writing to files, it runs scripts (defined by user, of course).
The script must be able to handle only one parameter that can be "0" or "1".

Can share my modified code if you want me to.

In that case the script could be something like:

#!/bin/bash

if test $1 -eq 0; then
  xset -led named "Scroll Lock"
else
  xset led named "Scroll Lock"
fi

Last edited by codycarey (2010-09-15 20:36:19)

Offline

#11 2010-09-15 21:16:49

hidefromkgb
Member
Registered: 2009-08-03
Posts: 146

Re: How to control keyboard LEDs via /proc

http://paste.org/pastebin/view/22447
Here's the code.

The script, whose name the user himself has to enter, must be run with root privileges to be able to modify /proc, so you are to prepend it with sudo.
Don't forget to add it to the NOPASSWD list in /etc/sudoers.
Alternatively, you can just setuid it.
But remember: in both cases, you need to protect this script from unauthorized changing, because it is a potential security hole.

Last edited by hidefromkgb (2010-09-15 21:33:32)

Offline

#12 2010-09-15 21:35:36

vitoreiji
Member
Registered: 2009-09-04
Posts: 67

Re: How to control keyboard LEDs via /proc

Hey guys, thanks everybody for your help!
I installed command-notification here and it works, but not the way I imagined. It doesn't turn off the led when I focus/click/write in the conversation window.
I'll take a look at hidefromkgb's code later, but thank you again everyone!

Offline

Board footer

Powered by FluxBB