9c16837227
For some reason, .* is really taxing for pgrep, but if you remove it it's way faster... % \time -v pgrep -nf '.*clipmenud$' 325286 Command being timed: "pgrep -nf .*clipmenud$" User time (seconds): 0.83 System time (seconds): 0.00 Percent of CPU this job got: 100% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.83 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 7632 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 1418 Voluntary context switches: 1 Involuntary context switches: 3 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 % \time -v pgrep -nf 'clipmenud$' 325286 Command being timed: "pgrep -nf clipmenud$" User time (seconds): 0.04 System time (seconds): 0.00 Percent of CPU this job got: 100% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.04 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 7320 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 1257 Voluntary context switches: 1 Involuntary context switches: 7 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 |
||
---|---|---|
init | ||
tests | ||
.travis.yml | ||
clipctl | ||
clipdel | ||
clipfsck | ||
clipmenu | ||
clipmenud | ||
LICENSE | ||
Makefile | ||
README.md |
clipmenu is a simple clipboard manager using dmenu (or rofi with
CM_LAUNCHER=rofi
) and xsel.
Demo
Usage
Start clipmenud
, then run clipmenu
to select something to put on the
clipboard. For systemd users, a user service called clipmenud
is packaged as
part of the project.
You may wish to bind a shortcut in your window manager to launch clipmenu
.
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'
For a full list of environment variables that clipmenud can take, please see
clipmenud --help
.
Features
The behavior of clipmenud
can be customized through environment variables.
Despite being only <300 lines, clipmenu has many useful features, including:
- Customising the maximum number of clips stored (default 1000)
- Disabling clip collection temporarily with
clipctl disable
, reenabling withclipctl enable
- Not storing clipboard changes from certain applications, like password managers
- Taking direct ownership of the clipboard
- ...and much more.
Check clipmenud --help
to view all possible environment variables and what
they do. If you manage clipmenud
with systemd
, you can override the
defaults by using systemctl --user edit clipmenud
to generate an override
file.
Installation
Several distributions, including Arch and Nix, provide clipmenu as an official
package called clipmenu
.
Manual installation
If your distribution doesn't provide a package, you can manually install using
make install
(or better yet, create a package for your distribution!). You
will need xsel
and clipnotify
installed, and also dmenu
unless you plan
to use a different launcher.
How does it work?
clipmenud is less than 300 lines, and clipmenu is less than 100, so hopefully it should be fairly self-explanatory. However, at the most basic level:
clipmenud
clipmenud
uses clipnotify to wait for new clipboard events.- 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
clipmenu
reads the index to find all available clips.dmenu
is executed to allow the user to select a clip.- After selection, the clip is put onto the PRIMARY and CLIPBOARD X selections.