Skip to content

Pihaar/autocutsel

Repository files navigation

autocutsel

X11/Wayland clipboard synchronization tool. Keeps the cutbuffer, CLIPBOARD, and PRIMARY selections in sync.

This is an actively maintained fork of sigmike/autocutsel.

Build License: GPL v2

OBS stable build status
OBS nightly build status

Installation

Pre-built packages are available via the openSUSE Build Service.

openSUSE Tumbleweed

sudo zypper addrepo https://download.opensuse.org/repositories/home:Pihaar:autocutsel/openSUSE_Tumbleweed/home:Pihaar:autocutsel.repo
sudo zypper refresh
sudo zypper install autocutsel

openSUSE Leap 15.6

sudo zypper addrepo https://download.opensuse.org/repositories/home:Pihaar:autocutsel/15.6/home:Pihaar:autocutsel.repo
sudo zypper refresh
sudo zypper install autocutsel

Fedora 43

sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/home:Pihaar:autocutsel/Fedora_43/home:Pihaar:autocutsel.repo
sudo dnf install autocutsel

RHEL 9

RHEL is not available on OBS due to licensing. Use the binary-compatible RockyLinux 9 repository instead:

sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/home:Pihaar:autocutsel/RockyLinux_9/home:Pihaar:autocutsel.repo
sudo dnf install autocutsel

Debian 13

echo 'deb [signed-by=/etc/apt/keyrings/home_Pihaar_autocutsel.gpg] https://download.opensuse.org/repositories/home:/Pihaar:/autocutsel/Debian_13/ /' | sudo tee /etc/apt/sources.list.d/home_Pihaar_autocutsel.list
curl -fsSL https://download.opensuse.org/repositories/home:/Pihaar:/autocutsel/Debian_13/Release.key | gpg --dearmor | sudo tee /etc/apt/keyrings/home_Pihaar_autocutsel.gpg > /dev/null
sudo apt update
sudo apt install autocutsel

Packages for additional distributions (Arch, CentOS Stream, RockyLinux, SUSE SLFO, and more) are listed on the OBS project page.

Features (beyond upstream)

  • -mouseonly — sync PRIMARY to CLIPBOARD only on mouse selection (ignores keyboard selections)
  • Wayland auto-detection — direct selection sync when cutbuffer is unavailable
  • -encoding — charset conversion for VNC clients with legacy encodings
  • Systemd user service — template unit with sandboxing and per-instance configuration
  • Single-instance lock — prevents duplicate processes per selection
  • PRIMARY clear — clears stale PRIMARY holders (e.g. xterm highlighting) after CLIPBOARD sync

Building from source

Dependencies

Fedora/RHEL/CentOS:

sudo dnf install gcc make autoconf automake libtool pkg-config \
  libX11-devel libXt-devel libXmu-devel libXaw-devel libXext-devel \
  libinput-devel systemd-devel

Ubuntu/Debian:

sudo apt-get install gcc make autoconf automake libtool pkg-config \
  libx11-dev libxt-dev libxmu-dev libxaw7-dev libxext-dev \
  libinput-dev libudev-dev

openSUSE:

sudo zypper install gcc make autoconf automake libtool pkg-config \
  libX11-devel libXt-devel libXmu-devel libXaw-devel libXext-devel \
  libinput-devel systemd-devel

Build & install

./bootstrap
./configure
make
make check        # run tests
sudo make install

Usage

Classic setup

The traditional approach uses two instances to keep CLIPBOARD, PRIMARY, and the cutbuffer in sync:

autocutsel &                        # CLIPBOARD ↔ cutbuffer
autocutsel -selection PRIMARY &     # PRIMARY ↔ cutbuffer

Add -fork to daemonize, or use the systemd service for automatic startup.

On Wayland (detected automatically via WAYLAND_DISPLAY), the cutbuffer is not available and selections are synced directly. A single instance is sufficient:

autocutsel -selection PRIMARY &

Options

Option Description Default
-selection NAME X selection to operate on (CLIPBOARD, PRIMARY) CLIPBOARD
-cutbuffer N Cutbuffer number (0–7), not used on Wayland 0
-pause MS Polling interval in milliseconds 500
-buttonup Only sync when mouse button is released (helps with LibreOffice and similar) off
-fork Daemonize (run in background) off
-mouseonly Sync PRIMARY→CLIPBOARD on mouse selection only (requires -selection PRIMARY, libinput, input group) off
-encoding CHARSET Convert between UTF-8 and the given charset (e.g. WINDOWS-1252 for VNC) off
-debug Print debug output off
-verbose Report version and sync events off

Mouse-only mode

With -mouseonly, only mouse-based text selection is synced from PRIMARY to CLIPBOARD — keyboard selections (Shift+Arrow etc.) are ignored. This requires access to input devices via libinput:

sudo usermod -aG input $USER   # re-login required
autocutsel -selection PRIMARY -mouseonly

Only a single instance is needed (unlike the classic two-instance setup).

cutsel utility

cutsel is a companion tool for inspecting and manipulating selections and cutbuffers:

cutsel cut                    # print cutbuffer content
cutsel cut "text"             # set cutbuffer content
cutsel sel                    # print CLIPBOARD content
cutsel sel -selection PRIMARY # print PRIMARY content
cutsel targets                # list selection targets offered by the owner

Systemd user service

autocutsel ships a template unit autocutsel@.service with example argument files.

# Create config directory and copy example
mkdir -p ~/.config/autocutsel
cp /usr/share/doc/autocutsel/examples/mouseonly.args ~/.config/autocutsel/

# Enable and start
systemctl --user daemon-reload
systemctl --user enable --now autocutsel@mouseonly

# View logs
journalctl --user -u 'autocutsel@*'

Available configurations in examples/:

File Description
mouseonly.args Sync PRIMARY to CLIPBOARD on mouse selection only
clipboard.args Sync CLIPBOARD with cutbuffer (traditional, pair with primary)
primary.args Sync PRIMARY with cutbuffer (traditional, pair with clipboard)

Acknowledgments

autocutsel was originally created by Michael Witrant (sigmike). Original project: https://www.nongnu.org/autocutsel/

License

GNU General Public License v2.0 or later — see COPYING.

About

autocutsel - X11/Wayland clipboard synchronizer with systemd service, mouseonly mode, and encoding conversion

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors