RUN{type}
Add a program to the list of programs to be executed after
processing all the rules for a specific event, depending on "type":
"program"
Execute an external program specified as the assigned value. If
no absolute path is given, the program is expected to live in
/lib/udev; otherwise, the absolute path must be specified.
This is the default if no type is specified.
"builtin"
As program, but use one of the built-in programs rather than an
external one.
The program name and following arguments are separated by spaces.
Single quotes can be used to specify arguments with spaces.
This can only be used for very short-running foreground tasks.
Running an event process for a long period of time may block all
further events for this or a dependent device.
Starting daemons or other long-running processes is not appropriate
for udev; the forked processes, detached or not, will be
unconditionally killed after the event handling has finished.
在udev手册页中,请特别注意最后两段。
我猜,你已经发现了无条件杀戮的部分
1年后编辑:
在有人投票通过后,我重新讨论了这个问题,这些问题是,root(谁在运行这个进程)没有一个X终端条目,对于某些事情,比如notify-send或启动一个Gui程序,仍然存在进程被杀死的情况,如前所述。
当插入usb设备时,下面的命令向终端发送通知并启动wxpythongui程序。在
剧本:
^{pr2}$
通过定义DISPLAY,我们可以解决root用户的no X term entry问题
通过将要运行的命令传递给at程序,并使用立即运行它的指令,我们可以避免udev杀死进程。在
/lib/udev/rules.d/10-usbinsert.规则文件:KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/usr/bin/sudo -u rolf /home/rolf/script.sh &"
我希望这能帮助你或者让你朝着正确的方向前进。在