1

I used to run Synergy via an Upstart script that included:

start on (login-session-start
          ...
          or drm-device-added
          or drm-device-changed
          or drm-device-removed
          or graphics-device-added
          or graphics-device-changed
          or graphics-device-removed
          ...)

stop on (drm-device-added
         or drm-device-changed
         or drm-device-removed
         or graphics-device-added
         or graphics-device-changed
         or graphics-device-removed
         ...)

This would stop and start the service if eg. a monitor was connected or disconnected so that Synergy would detect the new configuration.

I am writing Systemd service files for Synergy, but I can't find what an equivalent mechanism would be. man systemd.special doesn't list any graphics related targets, systemctl list-units --type=device only shows the graphics adapter (not the monitor) and it's not clear to me how to get Systemd to stop and start a service on a particular event.

How can I do these things? I'm writing it on Ubuntu 16.04, but the more distro agnostic the answer, the better.

  • I suspect that PartOf= is the answer to my question of how to restart the service, but that depends on the exact nature of whatever mechanism detects display changes. – detly Apr 12 '17 at 23:56
  • Are the directives in man systemd.path what you are looking for? – Mark Stosberg Apr 13 '17 at 14:57
  • @MarkStosberg Doesn't look like it, unless there are path events for display configuration changes. I can't find any though. – detly Apr 17 '17 at 22:40
  • @MarkStosberg Actually, some more Googling revealed that the contents of /sys/class/drm/... might change on certain events. I'll dig into that. – detly Apr 17 '17 at 22:47
  • @MarkStosberg Nope, can't do it. It requires recursive monitoring and following symlinks, which isn't supported AFAICT. – detly Apr 17 '17 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.