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

"Jóhann B. Guðmundsson" johannbg at gmail.com
Wed Mar 26 07:55:55 PDT 2014


On 03/26/2014 01:50 PM, Kai Hendry wrote:
> Thanks Michael for answering, :)
>
> On 26 March 2014 18:59, Michael Biebl <mbiebl at gmail.com> wrote:
>> 2014-03-26 3:56 GMT+01:00 Kai Hendry <hendry at webconverger.com>:
>> If your daemon is not functional if the hardware is not present, I'd
>> probably start it via a udev rule and SYSTEMD_WANTS.
> Do you have an example for this please?
>
> I don't quite understand why I can't I just name the device in the
> service file. Why does it have to be so confusing. Still don't
> understand the need for escaping... is there a need?

The reason is when your hardware becomes available you activate the 
service.

My udev foo is a bit rusty but you can try something along the lines of...

/etc/udev/rules.d/98-shk-local.rules

SUBSYSTEM=="input", ENV{ID_INPUT_KEYBOARD}=="?*", 
ENV{.INPUT_CLASS}="kbd", TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="shkd@%p.service"

/etc/systemd/system/shkd at .service

[Unit]
Description=Simple HotKey Daemon

[Service]
ExecStart=/usr/local/bin/shkd %I
Restart=always

[Install]
WantedBy=multi-user.target



More information about the systemd-devel mailing list