clipmenu

Simple clipboard management using dmenu
git clone https://git.sinitax.com/cdown/clipmenu
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 7b4267868e6a7881e5f80509211d3a9a0411fb68
parent 52b144d970f1a2aae73059fde52e8e614b5bc3e1
Author: Chris Down <chris@chrisdown.name>
Date:   Tue, 20 Feb 2018 10:09:50 +0000

Revert "Remove last_data checks"

This reverts commit 55407ba3f622c99b1efafbe6b6371680f6abd8f6.

Diffstat:
Mclipmenud | 25++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/clipmenud b/clipmenud @@ -103,6 +103,8 @@ fi # shellcheck disable=SC2174 mkdir -p -m0700 "$cache_dir" +declare -A last_data + command -v clipnotify >/dev/null 2>&1 && has_clipnotify=1 if ! (( has_clipnotify )); then @@ -153,16 +155,29 @@ while true; do continue fi + if [[ ${last_data[$selection]} == "$data" ]]; then + debug 'Skipping as last selection is the same as this one' + continue + fi + + last_data[$selection]=$data + first_line=$(get_first_line "$data") debug "New clipboard entry on $selection selection: \"$first_line\"" - filename="$cache_dir/$(cksum <<< "$first_line")" - debug "Writing $data to $filename" - printf '%s' "$data" > "$filename" + # Without checking ${last_data[any]}, we often double write since both + # selections get the same content + 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" + printf '%s\n' "$first_line" >> "$cache_file" + fi - debug "Writing $first_line to $cache_file" - printf '%s\n' "$first_line" >> "$cache_file" + last_data[any]=$data if (( CM_OWN_CLIPBOARD )) && [[ $selection != primary ]] && element_in clipboard "${cm_selections[@]}"; then