commit c40456caa030f1bbaa93a3621782892af9e2af46
parent 3a4a76dcb938613de57c9b749efb468c0672e79d
Author: Chris Down <chris@chrisdown.name>
Date: Wed, 5 Feb 2014 18:51:48 +0800
Do not write to file if last selection data is the same
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/clipmenud b/clipmenud
@@ -3,6 +3,8 @@
cache_dir=/tmp/clipmenu/
mkdir -p "$cache_dir"
+declare -A last_data
+
while sleep 1; do
for selection in clipboard primary; do
data=$(xsel --"$selection"; printf x)
@@ -10,6 +12,9 @@ while sleep 1; do
[[ $data ]] || continue
+ [[ ${last_data[$selection]} == "$data" ]] && continue
+ last_data[$selection]=$data
+
md5=$(md5sum <<< "$data")
md5=${md5%% *}