You are not logged in.

#1 2011-07-24 18:05:37

Troubadix
Member
Registered: 2011-06-25
Posts: 8

[solved] use "echo" via keybindings in openbox

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_backlight

But 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

#2 2011-07-24 18:36:33

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [solved] use "echo" via keybindings in openbox

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

#3 2011-07-24 19:00:45

Troubadix
Member
Registered: 2011-06-25
Posts: 8

Re: [solved] use "echo" via keybindings in openbox

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

#4 2011-07-24 19:36:49

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [solved] use "echo" via keybindings in openbox

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

#5 2011-07-24 20:58:32

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: [solved] use "echo" via keybindings in openbox

You should try writing a udev rule: http://www.reactivated.net/writing_udev … #ownership.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#6 2011-07-25 00:02:25

Troubadix
Member
Registered: 2011-06-25
Posts: 8

Re: [solved] use "echo" via keybindings in openbox

hbekel wrote:

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

Board footer

Powered by FluxBB