Configure Synergy as systemd service


Synergy is a mouse and keyboard sharing software (not free anymore). I use it for sharing my Fedora 20 K&M with my Windows box. As Fedora 20 replaces init with systemd, there is no rc.local where I can add my own startup script.

Systemd provides a easy way to allow you create your own system service. Here is how I create the synergy service.

1) Create a synergy configuration file

sudo vi /etc/synergy.conf

section: screens
Windows:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
Fedora:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
end

section: aliases
end

section: links
Windows:
right = Fedora
Fedora:
left = Windows
end

section: options
relativeMouseMoves = false
screenSaverSync = true
win32KeepForeground = false
switchCorners = none
switchCornerSize = 0
end

2) Create a service file for synergy. As the screen sharing is based on users, I need to name it as synergy@.service instead of synergy.service.

sudo vi /lib/systemd/system/synergy@.service

[Unit]
Description=Synergy for sharing mouse and keyboard
After=network.target

[Service]
ExecStart=/usr/bin/synergys -f -d WARNING –name Fedora -c /etc/synergy.conf -a 192.168.1.100:24800 –log /var/log/synergy.log
User=%i

[Install]
WantedBy=multi-user.target

3) Reload the systemd daemon

sudo systemctl daemon-reload

4) Add synery service to the startup.

sudo systemctl enable synergy@$(whoami)
ln -s ‘/usr/lib/systemd/system/synergy@.service’ ‘/etc/systemd/system/multi-user.target.wants/synergy@jchen.service’

5) Start synergy service

sudo systemctl start synergy@$(whoami)

6) Check the status

sudo systemctl status synergy@$(whoami)

synergy@jchen.service – Synergy for sharing mouse and keyboard
Loaded: loaded (/usr/lib/systemd/system/synergy@.service; enabled)
Active: active (running) since Fri 2014-10-24 09:28:29 AEDT; 5s ago
Main PID: 32187 (synergys)
CGroup: /system.slice/system-synergy.slice/synergy@chenj1.service
└─32187 /usr/bin/synergys -f -d WARNING –name Fedora -c /etc/synergy.conf -a 192.168.1.100:24800 –log /var/log/synergy….

Oct 24 09:28:29 fedora systemd[1]: Starting Synergy for sharing mouse and keyboard…

References:
https://fedoraproject.org/wiki/Systemd
http://www.freedesktop.org/wiki/Software/systemd/

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s