Feedback on Upstart script for Synergy client

Jason Heeris jason.heeris at gmail.com
Tue Feb 19 06:22:06 UTC 2013


I'm writing an Upstart job conf for the Synergy client[1]. Synergy
basically allows you to share a mouse and keyboard with another PC,
and it's useful to have it start up right from the moment there's a
graphical login screen. Typically people use lightdm scripts for this,
but I think an Upstart job would be more universal and easier to
distribute.

I started by getting something that just works on my machine, and it's
included below; but a quick look at it will show that it's very
fragile, and specific to lightdm. So I'd like some advice on improving
it. Specifically:

1. For this to work under lightdm, I need to set XAUTHORITY to
'/var/run/lightdm/root/:0'. Is there a better way to do this? Is there
a DM independent way to do this, or do I need to detect whether it's
running under lightdm, gdm, kdm, etc. and take separate action for
each of them?

2. Synergy doesn't detect new devices or changes in resolution, so I
make it restart on as many graphics-related events as I can find. Are
any of those redundant with each other? Or deprecated? Have I missed
any?

3. Slurping the client address from a file in /etc seemed the simplest
possible way to get it. Are there problems with this?

Of course, feel free to offer criticism on any other aspect of it too.

---- /etc/init/synergyc.conf
# Synergy Client
#
# Starts the synergy client when an X session is up and running.

description "Synergy Client"
author "Jason Heeris <jason.heeris at gmail.com>"

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
          or bdi-device-added
          or bdi-device-changed
          or bdi-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
         or bdi-device-added
         or bdi-device-changed
         or bdi-device-removed)

env XAUTHORITY=/var/run/lightdm/root/:0

script
    SYNERGY_HOST_FILE="/etc/synergy/client"
    if [ -e "${SYNERGY_HOST_FILE}" ]; then
        CLIENT_ADDR=$(cat "${SYNERGY_HOST_FILE}")
        exec synergyc -f "${CLIENT_ADDR}"
    fi
end script
----

Cheers,
Jason

[1] http://synergy-foss.org/



More information about the ubuntu-devel mailing list