cdown/clipmenu: Clipboard management using dmenu #862
Labels
CLI-UX
Command Line Interface user experience and best practices
Git-Repo
Source code repository like gitlab or gh
github
gh tools like cli, Actions, Issues, Pages
linux
Linux notes tools links
source-code
Code snippets
cdown/clipmenu: Clipboard management using dmenu
Snippet
"clipmenu is a simple clipboard manager using dmenu (or rofi with CM_LAUNCHER=rofi) and xsel.
Demo
Usage
clipmenud
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.
For those using a systemd unit and not using a desktop environment which does it automatically, you must import $DISPLAY so that clipmenud knows which X server to use. For example, in your ~/.xinitrc do this prior to launching clipmenud:
systemctl --user import-environment DISPLAY
clipmenu
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:
clipctl disable
, reenabling withclipctl enable
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 usingsystemctl --user edit clipmenud
to generate an override file.Supported launchers
Any dmenu-compliant application will work, but here are CM_LAUNCHER configurations that are known to work:
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 needxsel
andclipnotify
installed, and alsodmenu
unless you plan to use a different launcher.How does it work?
clipmenud
is less than 300 lines, andclipmenu
is less than 100, so hopefully it should be fairly self-explanatory. However, at the most basic level:clipmenud
clipmenud
usesclipnotify
to wait for new clipboard events.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.Suggested labels
None
The text was updated successfully, but these errors were encountered: