Hi All,

First of all, thank you for your help.

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

This works, thanks.

However, I have found a different solution to the problem, and I would like
to share it with you, in case you are interested.

Instead of relying on eudev to do all the work of calling the script, I
used for what it is best: Creating device nodes (and symlinks to them).
So the rules are:

KERNEL=="event20", SUBSYSTEM=="input", ATTRS{name}=="USBPS2",
ACTION=="add", GROUP="plugdev", MODE="0660", SYMLINK+="input/ext_usb/usbps2"
# force the directory to be persist
SUBSYSTEM=="input", RUN="/bin/mkdir -p /dev/input/ext_usb"


And then I used inotify to detect the creation of the symlink and to launch
the script from userspace:

#!/bin/bash
apply_xmodmap () {
  /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"
}

while true ; do

  EVENT=$(inotifywait -q -e create -e delete --exclude '.*tmp.*'
/dev/input/ext_usb/)

  if echo "$EVENT" | grep -qe CREATE ; then
    apply_xmodmap
  fi

done


It works just fine, I don't have an idea on the overheads in terms of cpu
time, although I didn't notice any difference on my michine.
If some of you has some opinion on this, please share it!

Once again thank you for your help.

Antonio

On Mon, Aug 6, 2018 at 12:10 PM Antonio Trkdz.tab <[email protected]>
wrote:

> Hi,
>
> Thanks for your help.
>
>> How are you running the echo command from the udev rule?
>
> ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="XXXX", ACTION=="add",
> RUN+="/bin/echo 'message' >> /full/path_to/log_file.log"
>
> they do not have the DISPLAY variable initialized and do not have the
>> appropriate session Xauthority cookies set.
>
> I have tried this also with:
> DISPLAY=":0.0"
> HOME=/home/antoniotrkdz
> XAUTHORITY=$HOME/.Xauthority
> export DISPLAY XAUTHORITY HOME
> in the script, I don't know if they are correct, however it didn't work.
>
> A
>
_______________________________________________
Dng mailing list
[email protected]
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to