Feedback on Upstart script for Synergy client
Dmitrijs Ledkovs
dmitrij.ledkov at ubuntu.com
Thu Feb 21 11:56:16 UTC 2013
On 19 February 2013 06:22, Jason Heeris <jason.heeris at gmail.com> wrote:
> 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)
>
Looks good, in ubiquity we use:
start on (starting gdm
or starting kdm
or starting xdm
or starting lxdm
or starting lightdm)
To cover more DMs.
> 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
>
I have used the following hack instead
script
test -f /usr/share/acpi-support/power-funcs || exit 0
. /usr/share/acpi-support/power-funcs
getXconsole
test -n "$XAUTHORITY" || exit 0
...(continue doing your things)
Which will set XAUTHORITY environment variable, DISPLAY, user, etc.
Regards,
Dmitrijs.
More information about the ubuntu-devel
mailing list