Skip to content

Synchronizes the clipboard across multiple X11 and wayland instances running on the same machine.

Notifications You must be signed in to change notification settings

dnut/clipboard-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clipboard Sync

Synchronizes the clipboard across multiple X11 and wayland instances running on the same machine.

To use clipboard sync, you only need to install it and start the service. It identifies and synchronizes your clipboards automatically.

Example use cases:

  • Improve Wayland compatibility: You have already enabled support for wayland in your system, but your computer does not synchronize the clipboard between X11 and wayland windows. clipboard-sync can solve this problem. more details
  • VNC: You run a VNC server and would like all host and client logins from the same user to share the same clipboard.
  • Multiple displays: You run two or more desktop environments or window managers in separate ttys, switching between desktops using ctrl-alt-F*.
  • Nested Wayland: You run a wayland compositor within a window. examples:
    • you primarily use kde, but run sway in a window to consolidate all your messenger apps into a single tiled/tabbed window.
    • you use gnome and develop extensions for gnome, so you run a nested gnome environment for testing.

Table of Contents:

Installation

Install clipboard-sync with your system's package manager. If your system is not supported, please vote on the appropriate issue, or create one if it does not exist.

Arch Linux

clipboard-sync is available in the Arch User Repository.

Ubuntu & Debian

Install from the official repository:

sudo wget -P /etc/apt/sources.list.d/ https://raw.githubusercontent.com/dnut/deb/master/dnut.list
sudo apt update && sudo apt install clipboard-sync

Advanced Installation

If your system is not supported, you have two other options:

  • Generic Linux
    • automatically and cleanly installs or uninstalls the entire package.
    • requires extra steps to acquire the source code.
  • Cargo
    • only installs the executable, which needs to be run manually.
    • requires extra steps to manually edit and install a systemd service if desired.
    • If you use cargo-update, it can make updates to the executable easier.

Generic Linux

Build from Source, then install either system-wide or for only the current user:

sudo make install  # system
make user-install  # user

It can be easily uninstalled:

sudo make uninstall  # system
make user-uninstall  # user

Cargo

clipboard-sync is published to crates.io, so it can be installed as a normal binary crate.

  1. Install rust: https://www.rust-lang.org/tools/install
  2. Install clipboard-sync
cargo install clipboard-sync
  1. If you want it to run in the background, you can use tmux, or you can manually download the systemd service file and copy it to a systemd folder. You can download it to the correct path using this command, after which you may need to manually edit the file to point the correct binary location:
wget -P "$HOME/.config/systemd/user/" https://raw.githubusercontent.com/dnut/clipboard-sync/master/clipboard-sync.service

It can be easily uninstalled:

cargo uninstall clipboard-sync
rm -r "$HOME/.config/systemd/clipboard-sync.service"

Ubuntu & Debian (advanced)

In addition to installing from the official repository, you can also build and install the deb package from source. Follow the instructions to Build from Source, then create a deb file and install it with:

make deb && sudo apt install ./dist/deb/clipboard-sync_*.deb

Usage

The typical set-and-forget approach is to enable to service:

systemctl --user enable --now clipboard-sync

If you don't want it to run constantly, only on-demand, don't use systemd. Directly call the binary as needed:

clipboard-sync

You can also daemonize clipboard-sync using tmux instead of systemd. ~/.bashrc aliases may be handy for these commands.

tmux new-session -ds clipboard-sync clipboard-sync  # start in background
tmux attach -t clipboard-sync                       # view status
ctrl-b, d                                           # while viewing status, send back to background
ctrl-c                                              # while viewing status, terminate the process

Build from Source

  1. Ensure you have the build dependencies: rust make gcc libc libxcb
  • install rust using rustup: https://www.rust-lang.org/tools/install
  • For the rest:
    • arch linux: sudo pacman -Syu make gcc libxcb
    • debian/ubuntu: sudo apt install make gcc libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
  1. Download the source from the releases page and unzip it. Alternatively, select one of these commands to download the source:
wget -O- https://github.com/dnut/clipboard-sync/archive/refs/tags/0.2.0.tar.gz | tar xvz
curl -L https://github.com/dnut/clipboard-sync/archive/refs/tags/0.2.0.tar.gz | tar xvz
git clone https://github.com/dnut/clipboard-sync.git --branch stable
  1. Compile the program
cd clipboard-sync*
make

The executable is here:

./target/release/clipboard-sync