commit db05c519427a507d0c82b177105bc691ff819e30
parent b839f807795d2485e55741569b542247e8bbdb3e
Author: Chris Down <chris@chrisdown.name>
Date: Fri, 17 Feb 2017 20:45:06 -0500
Add oneshot mode support
Fixes #27.
Diffstat:
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/clipmenud b/clipmenud
@@ -54,9 +54,14 @@ exec {lock_fd}> "$lock_file"
while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
if ! flock -x -w "$lock_timeout" "$lock_fd"; then
- printf 'ERROR: %s\n' \
- 'Timed out waiting for lock, skipping this run' >&2
- continue
+ if (( ONESHOT )); then
+ printf 'ERROR: %s\n' 'Timed out waiting for lock' >&2
+ exit 1
+ else
+ printf 'ERROR: %s\n' \
+ 'Timed out waiting for lock, skipping this run' >&2
+ continue
+ fi
fi
for selection in clipboard primary; do
@@ -118,4 +123,9 @@ while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
done
flock -u "$lock_fd"
+
+ if (( ONESHOT )); then
+ debug 'Oneshot mode enabled, exiting'
+ break
+ fi
done