X11 clipboard history and management using spmenu
Go to file
William Casarin 630e7a016c clipmenu: print selection to stdout
This allows you to use clipmenu in desktop scripts. For example you
could pipe the output of your narrowed selection to another command.

Signed-off-by: William Casarin <jb55@jb55.com>
2020-03-24 18:00:20 -07:00
init systemd: Use 500ms RestartSec 2019-02-13 16:34:32 +00:00
tests Use a single line cache file 2020-03-23 13:00:14 +00:00
.travis.yml Use a single line cache file 2020-03-23 13:00:14 +00:00
clipdel Use a single line cache file 2020-03-23 13:00:14 +00:00
clipfsck Use a single line cache file 2020-03-23 13:00:14 +00:00
clipmenu clipmenu: print selection to stdout 2020-03-24 18:00:20 -07:00
clipmenud clipmenud: Remove weird extra line in --help 2020-03-24 01:11:02 +00:00
LICENSE License as public domain 2015-10-26 11:10:54 +00:00
README.md readme: Remove out of date information 2020-03-23 18:16:22 +00:00

Tests

clipmenu is a simple clipboard manager using dmenu (or rofi with CM_LAUNCHER=rofi) and xsel.

Demo

Demo

Usage

Start clipmenud, then run clipmenu to select something to put on the clipboard.

A systemd user service for starting clipmenud is included at init/clipmenud.service. You can then start clipmenud like this:

systemctl --user start clipmenud

All args passed to clipmenu are transparently dispatched to dmenu. That is, if you usually call dmenu with args to set colours and other properties, you can invoke clipmenu in exactly the same way to get the same effect, like so:

clipmenu -i -fn Terminus:size=8 -nb '#002b36' -nf '#839496' -sb '#073642' -sf '#93a1a1'

If you prefer to collect clips on demand rather than running clipmenud as a daemon, you can bind a key to the following command for one-off collection:

CM_ONESHOT=1 clipmenud

For a full list of environment variables that clipmenud can take, please see clipmenud --help.

Installation

Several distributions, including Arch and Nix, provide clipmenu as an official package called clipmenu.

If your distribution doesn't provide a package, you can run the scripts standalone (or better yet, package them!).

How does it work?

clipmenud is less than 200 lines, and clipmenu is less than 100, so hopefully it should be fairly self-explanatory. However, at the most basic level:

clipmenud

  1. clipmenud uses clipnotify to wait for new clipboard events.
  2. If clipmenud detects changes to the clipboard contents, it writes them out to the cache directory and an index using a hash as the filename.

clipmenu

  1. clipmenu reads the index to find all available clips.
  2. dmenu is executed to allow the user to select a clip.
  3. After selection, the clip is put onto the PRIMARY and CLIPBOARD X selections.