Skip to content
/ clipcat Public
forked from xrelkd/clipcat

clipcat is a clipboard manager written in Rust Programming Language.

License

Notifications You must be signed in to change notification settings

Icelk/clipcat

 
 

Repository files navigation

Clipcat

CI

Clipcat is a clipboard manager written in Rust Programming Language.

About this fork

Some critical issues (mainly loosing the connection) were found when using it, and xrelkd didn't respond, so I fixed them here.

Wayland support is built in, but not tested. If anyone is interested, please report back!

I've also added a systemd service file, which you can copy to ~/.config/systemd/user/clipcat.service

Compiling RocksDB took ages, and currently my DB is 34MB. That's a lot for 250 snippets of text. Apparently, it doesn't remove from the actual files when clearing the history. So I removed the dependency, and now data is serialized and deserialized using bincode, which already was an explicit dependency.

This also adds configuration value to the [monitor] section of clipcatd.toml; filter_min_size. It filters the copy actions for a minimum size. See the example configuration below for more info. If you use Vim and set this to 1, holding x no longer ruins the Clipcat history; Vim's 1 byte long copy actions aren't saved.

You can install all the binaries (with both X11 and Wayland support) using

$ cargo install --path . -F all-bins

or with only wayland support:

$ cargo install --path . --no-default-features -F all-bins,wayland

Architecture

Clipcat uses the Client-Server architecture. There are two role types in this architecture: Server and Client.

Clipcat Server

A clipcat server (as known as daemon) is running as the background process and does the following routines:

  • Watching the changes of X11 clipboard.
  • Caching the content of X11 clipboard.
  • Inserting content into X11 clipboard.
  • Serving as a gRPC server and waiting for remote procedure call from clients.

Clipcat Client

A clipcat client sends requests to the server for the following operations:

  • List: list the cached clips from server.
  • Insert: replace the current content of X11 clipboard with a clip.
  • Remove: remove the cached clips from server.

List of Implementations

Program Role Type Comment
clipcatd Server The clipcat server (daemon)
clipcatctl Client The clipcat client which provides a command line interface
clipcat-menu Client The clipcat client which calls built-in finder or external finder for selecting clip

Quick Start

Installation

Linux Distribution Package Manager Package Command
Various Nix clipcat nix-env -iA nixpkgs.clipcat
NixOS Nix clipcat nix-env -iA nixos.clipcat
Arch Linux Paru clipcat paru -S clipcat

Usage

  1. Setup configurations for clipcat.
$ mkdir -p                       $XDG_CONFIG_HOME/clipcat
$ clipcatd default-config      > $XDG_CONFIG_HOME/clipcat/clipcatd.toml
$ clipcatctl default-config    > $XDG_CONFIG_HOME/clipcat/clipcatctl.toml
$ clipcat-menu default-config  > $XDG_CONFIG_HOME/clipcat/clipcat-menu.toml
  1. Start clipcatd for watching clipboard events.
$ clipcatd
  1. Copy arbitrary text from other X11 process with your mouse or keyboard.

  2. You can run following commands with clipcatctl or clipcat-menu:

Command Comment
clipcatctl list List cached clipboard history
clipcatctl promote <id> Insert cached clip with <id> into X11 clipboard
clipcatctl remove [ids] Remove cached clips with [ids] from server
clipcatctl clear Clear cached clipboard history
Command Comment
clipcat-menu insert Insert a cached clip into X11 clipboard
clipcat-menu remove Remove cached clips from server
clipcat-menu edit Edit a cached clip with \$EDITOR

Note: Supported finders for clipcat-menu:

Configuration

Program Default Configuration File Path
clipcatd $XDG_CONFIG_HOME/clipcat/clipcatd.toml
clipcatctl $XDG_CONFIG_HOME/clipcat/clipcatctl.toml
clipcat-menu $XDG_CONFIG_HOME/clipcat/clipcat-menu.toml

Configuration for clipcatd

daemonize = true          # run as a traditional UNIX daemon
max_history = 50          # max clip history limit
log_level = 'INFO'        # log level

[monitor]
load_current = true       # load current clipboard content at startup
enable_clipboard = true   # watch X11 clipboard
enable_primary = true     # watch X11 primary clipboard
filter_min_size = 0       # ignores copy actions with a size equal to or less this, in bytes

[grpc]
host = '127.0.0.1'        # host address for gRPC
port = 45045              # port number for gRPC

Configuration for clipcatctl

server_host = '127.0.0.1' # host address of clipcat gRPC server
server_port = 45045       # port number of clipcat gRPC server
log_level = 'INFO'        # log level

Configuration for clipcat-menu

server_host = '127.0.0.1' # host address of clipcat gRPC server
server_port = 45045       # port number of clipcat gRPC server
finder = 'rofi'           # the default finder to invoke when no "--finder=<finder>" option provided

[rofi]                    # options for "rofi"
line_length = 100         # length of line
menu_length = 30          # length of menu

[dmenu]                   # options for "dmenu"
line_length = 100         # length of line
menu_length = 30          # length of menu

[custom_finder]           # customize your finder
program = 'fzf'           # external program name
args = []                 # arguments for calling external program

Integration

Integrating with Zsh

For zsh user, it will be useful to integrate clipcat with zsh.

Add the following command in your zsh configuration file (~/.zshrc):

if type clipcat-menu >/dev/null 2>&1; then
    alias clipedit=' clipcat-menu --finder=builtin edit'
    alias clipdel=' clipcat-menu --finder=builtin remove'

    bindkey -s '^\' "^Q clipcat-menu --finder=builtin insert ^J"
    bindkey -s '^]' "^Q clipcat-menu --finder=builtin remove ^J"
fi

Integrating with i3 Window Manager

For i3 window manager user, it will be useful to integrate clipcat with i3.

Add the following options in your i3 configuration file ($XDG_CONFIG_HOME/i3/config):

exec_always --no-startup-id clipcatd                # start clipcatd at startup

set $launcher-clipboard-insert clipcat-menu insert
set $launcher-clipboard-remove clipcat-menu remove

bindsym $mod+p exec $launcher-clipboard-insert
bindsym $mod+o exec $launcher-clipboard-remove

Note: You can use rofi or dmenu as the default finder.

Compiling from Source

clipcat requires the following tools and packages to build:

  • git
  • rustc
  • cargo
  • pkgconfig
  • protobuf
  • clang
  • libclang
  • libxcb

With the above tools and packages already installed, you can simply run:

$ git clone https://github.com/xrelkd/clipcat.git
$ cd clipcat
$ cargo build --release --features=all

License

Clipcat is licensed under the GNU General Public License version 3. See LICENSE for more information.

About

clipcat is a clipboard manager written in Rust Programming Language.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 87.8%
  • Shell 10.2%
  • Nix 1.5%
  • Dockerfile 0.5%