Autocutsel and an Introduction to Systemd User Servicestech
This post shows how to run
autocutsel as a
systemd user service
to keep X11 clipboards in sync.
X11 has two kinds of copy/paste buffers, namely the primary selection and the clipboard selection. The primary selection is invoked when highlighting text and with the middle mouse button while the clipboard selection uses Ctrl+C and Ctrl+V.
If you wish to keep both buffers in sync, you can use the
to do just that, effectively merging the two buffers.
I used to just start
autocutsel with my window manager, but there is
a more clean solution,
systemd user services. User services are like
regular system-wide services, but they are only started when the
associated user is logged in and kept running until all sessions of
that users are closed.
As with regular
systemdservices, we need a service file.
[Unit] Description=Autocutsel [Service] Type = forking Restart = on-failure RestartSec = 10 ExecStartPre = /usr/bin/autocutsel -fork ExecStart = /usr/bin/autocutsel -selection PRIMARY -fork [Install] WantedBy=default.target
User service file go into the
~/.config/systemd/userdirectory. We will save above service file as
To control user services, use
systemctllike usual, but with the
--userflag. After saving
autocutsel.service, first reload the database of services with
systemctl --user daemon-reload
and then enable the service
systemctl --user enable autocutsel
Log out and back on again.
autocutselshould be running and keeping your clipboards in sync.
systemd will make sure that only one instance of the service is
running at a time and restart the daemon if it crashes.