You are not logged in.
Hi all,
is there a possibility to use the "echo" command via a keybind in openbox? If I edit the rc.xml with these lines:
<keybind key="Help">
<action name="Execute">
<execute>echo 1 | sudo tee -a /sys/devices/platform/sony-laptop/kbd_backlight</execute>
</action>
</keybind>I just get in the openbox-terminal the output
1 | sudo tee -a /sys/devices/platform/sony-laptop/kbd_backlightBut of course that´s not what I want. I want to be written "1" into the file. Out of a terminal it works fine, but with keybind obviously you need to do something different.
Using <action> instead of <execute> I get the same result.
Anybody may help me?
Saludos
Last edited by Troubadix (2011-07-25 09:09:22)
Offline
This happens because openbox doesn't use a shell to execute commands. In your case, it simply calls /bin/echo and passes the rest of the line as arguments to echo (including the |). You'll have to explicitly tell openbox to use a shell, e.g.
<execute>/bin/sh -c 'echo 1 | sudo tee -a /sys/devices/platform/sony-laptop/kbd_backlight'</execute>Offline
Thank you, now it works, the "1" is written into the correct file and my keyboard-backlight turns on.
That makes it by far much easier for me. Only thing: still have to write the sudo password in the terminal where I openbox started. Is there a possibility to avoid that and write the pw automatically?
Thanks for your help.
Offline
Hmm, to be honest I didn't really look at the command itself.
The proper way to do this is to create a script to switch the backlight, and then allow passwordless execution of this script via sudo for certain users only (see man sudo). Then those users may run "sudo script" without having to enter the password.
Alternatively you might avoid sudo completely by simply doing a 'chmod 666 /sys/devices/platform/sony-laptop/kbd_backlight' during startup (e.g. from rc.local). This will allow any user to switch the backlight by writing a 1 to this file, which shouldn't be much of a security issue (but that's up to you to decide).
Offline
You should try writing a udev rule: http://www.reactivated.net/writing_udev … #ownership.
Offline
Alternatively you might avoid sudo completely by simply doing a 'chmod 666 /sys/devices/platform/sony-laptop/kbd_backlight' during startup (e.g. from rc.local). This will allow any user to switch the backlight by writing a 1 to this file, which shouldn't be much of a security issue (but that's up to you to decide).
Yes, I think that´s the way I´ll do it. I´m the only user and it´s just the keyboard-backlight, so no, no security-problems.
vielen Dank
Offline