dnut / clipboard-sync

Synchronizes the clipboard across multiple X11 and wayland instances running on the same machine.
67 stars 10 forks source link
arch archlinux clipboard desktop environment gnome linux rust sway wayland x11 xorg

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:

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

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
  3. 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

NixOS

Add this repo to your flake inputs:

clipboard-sync.url = "github:dnut/clipboard-sync";

Put clipboard-sync.nixosModules.default into flake modules.

To enable the systemd service, add services.clipboard-sync.enable = true; into the configuration.nix.

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
  2. 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
  3. Compile the program

    cd clipboard-sync*
    make

The executable is here:

./target/release/clipboard-sync