Avoid double writing if both selections are the same
This commit is contained in:
parent
8bb4ff3999
commit
e6c312b639
16
clipmenud
16
clipmenud
|
@ -116,12 +116,18 @@ while (( CM_ONESHOT )) || sleep "${CM_SLEEP:-0.5}"; do
|
||||||
|
|
||||||
debug "New clipboard entry on $selection selection: \"$first_line\""
|
debug "New clipboard entry on $selection selection: \"$first_line\""
|
||||||
|
|
||||||
filename="$cache_dir/$(cksum <<< "$first_line")"
|
# Without checking ${last_data[any]}, we often double write since both
|
||||||
debug "Writing $data to $filename"
|
# selections get the same content
|
||||||
printf '%s' "$data" > "$filename"
|
if [[ ${last_data[any]} != "$data" ]]; then
|
||||||
|
filename="$cache_dir/$(cksum <<< "$first_line")"
|
||||||
|
debug "Writing $data to $filename"
|
||||||
|
printf '%s' "$data" > "$filename"
|
||||||
|
|
||||||
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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
last_data[any]=$data
|
||||||
|
|
||||||
if (( CM_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
|
||||||
|
|
Loading…
Reference in a new issue