Skip to content

Commit

Permalink
Add oneshot mode support
Browse files Browse the repository at this point in the history
Fixes #27.
  • Loading branch information
cdown committed Feb 18, 2017
1 parent b839f80 commit db05c51
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions clipmenud
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit db05c51

Please sign in to comment.