[systemd-devel] Requiring hardware device and escaping device names

Andrey Borzenkov arvidjaar at gmail.com
Sun Mar 30 10:00:33 PDT 2014


В Sun, 30 Mar 2014 23:48:11 +0800
Kai Hendry <hendry at webconverger.com> пишет:

> On 26 March 2014 22:55, "Jóhann B. Guðmundsson" <johannbg at gmail.com> wrote:
> > SUBSYSTEM=="input", ENV{ID_INPUT_KEYBOARD}=="?*", ENV{.INPUT_CLASS}="kbd",
> > TAG+="systemd", ENV{SYSTEMD_WANTS}+="shkd@%p.service"
> 
...
> Trying to teach myself how to fish here. How did you know it would
> match this particular device?
> 
> $ udevadm monitor

udevadm monitor --env would be more useful, it also shows device
attributes after event is processed.

...
> 
> Anyway, it doesn't seem to work.
> 
> [hendry at alarmpi ~]$ systemctl | grep shk
> shkd at -devices-platform-bcm2708_usb-usb1-1-1-1-1.2-1-1.2.2-1-1.2.2:1.0-input-input0-event0.service
>                               loaded failed     failed       Simple
> HotKey Daemon


That's right. You really want %N ($devnode), not %p in the rule. %p
refers to path in /sys, while your daemon apparently needs real device
path in /dev.

To filter those paths that generate device nodes you could check for
DEVNAME or NAME not being empty. If you need more specific match, you
need to check attributes for your device.

SUBSYSTEM=="input", ENV{ID_INPUT_KEYBOARD}=="?*", ENV{DEVNAME}=="?*", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="shkd@%N.service"


More information about the systemd-devel mailing list