I have a user-space daemon, call it
maxwell, that executes various actions based on D-bus signals from another application, call it
room. I would like to run
maxwell as soon as the user starts
room, and stop it when
I think a launcher script like this would result in the desired behaviour:
#!/bin/sh systemctl --user start maxwell room systemctl --user stop maxwell
but is there a better / standard way to do it, e.g. via systemd itself?
Update: It seems like the functionality I'm looking for is similar to what
upstart used to provide with its dbus event. The closest thing that can be achieved with
systemd appears to be auto-starting a service which "owns" a certain D-bus name when that name is first used, as per Stephen Kitt's answer; unfortunately, in this case it is
room that "owns" the name.
Note: I don't think that this is the same as systemd requires="some non-systemd process"? or, at least, that the answer provided therein works in this case. As far as I understand, using
ExecStartPre would simply mark the
maxwell unit as failed if
room wasn't already running.