:: Re: [DNG] running script on eudev e…
Pàgina inicial
Delete this message
Reply to this message
Autor: aitor_czr
Data:  
A: dng
Assumpte: Re: [DNG] running script on eudev event
Hi,

El 05/08/18 a las 22:03, Alessandro Selli escribió:
> n 05/08/2018 at 20:44, Antony Stone wrote:
>
>> On Sunday 05 August 2018 at 20:24:30, Alessandro Selli wrote:
>>
>>> On 05/08/2018 at 16:29, Antonio Trkdz.tab wrote:
>>>> Dear All,
>>>>
>>>> I am struggling to understand how to run a script automatically upon
>>>> plugging a USB keyboard.
>>>> I know this issue is not directly related to Devuan, but I will
>>>> certainly appreciate a little help.
>>>>
>>>> I created the following rule as /etc/udev/rules.d/90-usb-keyboard.rules:
>>>> ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="XXXX", ACTION=="add",
>>>> RUN+="/full/path_to/restore_space_as_modifier.sh"
>>>> and reloaded eudev (I am on ASCII).
>>>>
>>>> The script essentially has to do this:
>>>>
>>>> #!/bin/bash
>>>> /usr/bin/xmodmap -e "keycode 65=Super_L"
>>>> /usr/bin/xmodmap -e "keycode any=space"
>>>> /usr/bin/pkill xcape
>>>> /usr/bin/xcape -e "Super_L=space"
>>>    I think the problem lies in the x* from the commands: they are X11
>>> commands, i.e. they interact with a running Xorg.  But, as they are run
>>> by udevd, i.e. by a system daemon, they do not have the DISPLAY variable
>>> initialized and do not have the appropriate session Xauthority cookies
>>> set.  Thus they fail.
>> That sounds plausible, but doesn't explain:

>>
>>>> it is not working, nothing happens, not even a simple echo something to a
>>>> file, the only command I have got working is touching a file with
>>>> 'RUN+="/usr/bin/touch path_to/filename"
>   How are you running the echo command from the udev rule?


Maybe you should log the message, something like this?

|ACTION=="add", RUN+="/bin/sh -c 'echo "message" >> log_file

Cheers,

  Aitor.



|