clipmenu

Simple clipboard management using dmenu
git clone https://git.sinitax.com/cdown/clipmenu
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 2b04a1eafe0db7e0a9d640750fa59e3cebb4c322
parent f576a116fde40328e5c0967b90f476b5416acc9b
Author: Chris Down <chris@chrisdown.name>
Date:   Mon,  5 Feb 2018 23:49:41 +0000

Add optional support for clipnotify to avoid polling

Diffstat:
Mclipmenud | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/clipmenud b/clipmenud @@ -11,6 +11,7 @@ cache_dir=$CM_DIR/clipmenu.$major_version.$USER/ cache_file=$cache_dir/line_cache lock_file=$cache_dir/lock lock_timeout=2 +has_clipnotify=0 xsel_log=/dev/null for file in /proc/self/fd/2 /dev/stderr; do @@ -86,9 +87,20 @@ mkdir -p -m0700 "$cache_dir" declare -A last_data +command -v clipnotify >/dev/null 2>&1 && has_clipnotify=1 + exec {lock_fd}> "$lock_file" -while (( CM_ONESHOT )) || sleep "${CM_SLEEP:-0.5}"; do +while true; do + if ! (( CM_ONESHOT )); then + if (( has_clipnotify )); then + clipnotify + else + # Use old polling method + sleep "${CM_SLEEP:-0.5}" + fi + fi + if ! flock -x -w "$lock_timeout" "$lock_fd"; then if (( CM_ONESHOT )); then printf 'ERROR: %s\n' 'Timed out waiting for lock' >&2