Use CM_* env vars
This commit is contained in:
parent
117385015b
commit
e65b51b33c
|
@ -22,8 +22,8 @@ there, but it basically works like this:
|
||||||
## clipmenud
|
## clipmenud
|
||||||
|
|
||||||
1. `clipmenud` polls the clipboard every 0.5 seconds (or another interval as
|
1. `clipmenud` polls the clipboard every 0.5 seconds (or another interval as
|
||||||
configured with the `CLIPMENUD_SLEEP` environment variable). Unfortunately
|
configured with the `CM_SLEEP` environment variable). Unfortunately there's
|
||||||
there's no interface to subscribe for changes in X11, so we must poll.
|
no interface to subscribe for changes in X11, so we must poll.
|
||||||
2. If `clipmenud` detects changes to the clipboard contents, it writes them out
|
2. If `clipmenud` detects changes to the clipboard contents, it writes them out
|
||||||
to the cache directory.
|
to the cache directory.
|
||||||
|
|
||||||
|
|
2
clipmenu
2
clipmenu
|
@ -7,7 +7,7 @@ shopt -s nullglob
|
||||||
cache_dir=/tmp/clipmenu.$major_version.$USER
|
cache_dir=/tmp/clipmenu.$major_version.$USER
|
||||||
cache_file=$cache_dir/line_cache
|
cache_file=$cache_dir/line_cache
|
||||||
|
|
||||||
: "${CM_LAUNCHER:-dmenu}"
|
: "${CM_LAUNCHER=dmenu}"
|
||||||
|
|
||||||
# It's okay to hardcode `-l 8` here as a sensible default without checking
|
# It's okay to hardcode `-l 8` here as a sensible default without checking
|
||||||
# whether `-l` is also in "$@", because the way that dmenu works allows a later
|
# whether `-l` is also in "$@", because the way that dmenu works allows a later
|
||||||
|
|
14
clipmenud
14
clipmenud
|
@ -6,6 +6,10 @@ cache_file=$cache_dir/line_cache
|
||||||
lock_file=$cache_dir/lock
|
lock_file=$cache_dir/lock
|
||||||
lock_timeout=2
|
lock_timeout=2
|
||||||
|
|
||||||
|
: "${CM_ONESHOT=0}"
|
||||||
|
: "${CM_OWN_CLIPBOARD=1}"
|
||||||
|
: "${CM_DEBUG=0}"
|
||||||
|
|
||||||
_xsel() {
|
_xsel() {
|
||||||
timeout 1 xsel --logfile /dev/stderr "$@"
|
timeout 1 xsel --logfile /dev/stderr "$@"
|
||||||
}
|
}
|
||||||
|
@ -42,7 +46,7 @@ get_first_line() {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
if (( DEBUG )); then
|
if (( CM_DEBUG )); then
|
||||||
printf '%s\n' "$@" >&2
|
printf '%s\n' "$@" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -56,9 +60,9 @@ declare -A last_filename
|
||||||
|
|
||||||
exec {lock_fd}> "$lock_file"
|
exec {lock_fd}> "$lock_file"
|
||||||
|
|
||||||
while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
|
while sleep "${CM_SLEEP:-0.5}"; do
|
||||||
if ! flock -x -w "$lock_timeout" "$lock_fd"; then
|
if ! flock -x -w "$lock_timeout" "$lock_fd"; then
|
||||||
if (( ONESHOT )); then
|
if (( CM_ONESHOT )); then
|
||||||
printf 'ERROR: %s\n' 'Timed out waiting for lock' >&2
|
printf 'ERROR: %s\n' 'Timed out waiting for lock' >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
@ -114,7 +118,7 @@ while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
|
||||||
debug "Writing $first_line to $cache_file"
|
debug "Writing $first_line to $cache_file"
|
||||||
printf '%s\n' "$first_line" >> "$cache_file"
|
printf '%s\n' "$first_line" >> "$cache_file"
|
||||||
|
|
||||||
if ! (( NO_OWN_CLIPBOARD )) && [[ $selection != primary ]]; then
|
if (( CM_OWN_CLIPBOARD )) && [[ $selection != primary ]]; then
|
||||||
# Take ownership of the clipboard, in case the original application
|
# Take ownership of the clipboard, in case the original application
|
||||||
# is unable to serve the clipboard request (due to being suspended,
|
# is unable to serve the clipboard request (due to being suspended,
|
||||||
# etc).
|
# etc).
|
||||||
|
@ -132,7 +136,7 @@ while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
|
||||||
|
|
||||||
flock -u "$lock_fd"
|
flock -u "$lock_fd"
|
||||||
|
|
||||||
if (( ONESHOT )); then
|
if (( CM_ONESHOT )); then
|
||||||
debug 'Oneshot mode enabled, exiting'
|
debug 'Oneshot mode enabled, exiting'
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue