commit 228fcbdd0d0e86afdfacadebbf812d24452b4686
parent 9e672cf0a5ab64886957cbbb091252393d54dec2
Author: Chris Down <chris@chrisdown.name>
Date: Mon, 23 Mar 2020 17:10:43 +0000
clipmenud: Tidy up some old, too-verbose comments
Diffstat:
1 file changed, 2 insertions(+), 23 deletions(-)
diff --git a/clipmenud b/clipmenud
@@ -24,7 +24,6 @@ cache_file=$cache_dir/line_cache
lock_file=$cache_dir/lock
session_lock_file=$cache_dir/session_lock
lock_timeout=2
-has_clipnotify=0
has_xdotool=0
# This comes from the environment, so we rely on word splitting.
@@ -125,7 +124,6 @@ flock -x -n "$session_lock_fd" ||
die 2 "Can't lock session file -- is another clipmenud running?"
declare -A last_data
-declare -A last_filename
declare -A last_cache_file_output
command -v clipnotify >/dev/null 2>&1 || die 2 "clipnotify not in PATH"
@@ -159,16 +157,8 @@ while true; do
for selection in "${cm_selections[@]}"; do
data=$(_xsel -o --"$selection"; printf x)
-
- debug "Data before stripping: $data"
-
- # We add and remove the x so that trailing newlines are not stripped.
- # Otherwise, they would be stripped by the very nature of how POSIX
- # defines command substitution.
data=${data%x}
- debug "Data after stripping: $data"
-
if [[ $data != *[^[:space:]]* ]]; then
debug "Skipping as clipboard is only blank"
continue
@@ -179,22 +169,14 @@ while true; do
continue
fi
-
- # If we were in the middle of doing a selection when the previous poll
- # ran, then we may have got a partial clip.
possible_partial=${last_data[$selection]}
if [[ $possible_partial && $data == "$possible_partial"* ]] ||
[[ $possible_partial && $data == *"$possible_partial" ]]; then
- info "Last clip for $selection was a possible partial, removing line cache entry"
+ # Don't actually remove the file yet, because it might be
+ # referenced by an older entry. These will be dealt with at vacuum.
debug "$selection: $possible_partial is a possible partial of $data"
-
previous_size=$(wc -c <<< "${last_cache_file_output[$selection]}")
truncate -s -"$previous_size" "$cache_file"
-
- file=${last_filename[$selection]}
-
- # Don't remove the file yet, because it might be referenced by an
- # older entry. These will be dealt with at vacuum time.
fi
first_line=$(get_first_line "$data")
@@ -205,7 +187,6 @@ while true; do
filename="$cache_dir/$(cksum <<< "$first_line")"
last_data[$selection]=$data
- last_filename[$selection]=$filename
# Recover without restart if we deleted the entire clip dir.
# It's ok that this only applies to the final directory.
@@ -236,8 +217,6 @@ while true; do
fi
done
- # Fail quickly if we're not far enough over, to avoid calling `cksum` a
- # lot and killing perf if we're not batched.
if (( CM_MAX_CLIPS )) && [[ -f $cache_file ]] &&
(( "$(wc -l < "$cache_file")" > CM_MAX_CLIPS_THRESH )); then
info "Trimming clip cache to CM_MAX_CLIPS ($CM_MAX_CLIPS)"