Merge tag '1.0.0'
Initial stable release
This commit is contained in:
commit
0717e72a03
15
clipmenu
15
clipmenu
|
@ -1,10 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
LC_COLLATE=C
|
||||||
|
|
||||||
dmenu_lines=${CLIPMENU_LINES-8}
|
dmenu_lines=${CLIPMENU_LINES-8}
|
||||||
|
|
||||||
declare -A selections
|
declare -A selections
|
||||||
|
ordered_selections=()
|
||||||
|
|
||||||
|
files=("/tmp/clipmenu.$USER/"*)
|
||||||
|
|
||||||
|
for (( i=${#files[@]}-1; i>=0; i-- )); do
|
||||||
|
file=${files[$i]}
|
||||||
|
|
||||||
for file in /tmp/clipmenu/*; do
|
|
||||||
first_line=$(sed -n '/./{p;q}' "$file")
|
first_line=$(sed -n '/./{p;q}' "$file")
|
||||||
|
|
||||||
lines=$(wc -l "$file")
|
lines=$(wc -l "$file")
|
||||||
|
@ -14,10 +21,14 @@ for file in /tmp/clipmenu/*; do
|
||||||
first_line+=" ($lines lines)"
|
first_line+=" ($lines lines)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ordered_selections+=("$first_line")
|
||||||
selections[$first_line]=$file
|
selections[$first_line]=$file
|
||||||
done
|
done
|
||||||
|
|
||||||
chosen_line=$(printf '%s\n' "${!selections[@]}" | dmenu -l "$dmenu_lines" "$@")
|
chosen_line=$(
|
||||||
|
printf '%s\n' "${ordered_selections[@]}" |
|
||||||
|
awk '!x[$0]++' | dmenu -l "$dmenu_lines" "$@"
|
||||||
|
)
|
||||||
|
|
||||||
[[ $chosen_line ]] || exit 1
|
[[ $chosen_line ]] || exit 1
|
||||||
|
|
||||||
|
|
11
clipmenud
11
clipmenud
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cache_dir=/tmp/clipmenu/
|
cache_dir=/tmp/clipmenu.$USER/
|
||||||
mkdir -p "$cache_dir"
|
mkdir -p -m0700 "$cache_dir"
|
||||||
|
|
||||||
declare -A last_data
|
declare -A last_data
|
||||||
|
|
||||||
|
@ -13,9 +13,12 @@ while sleep 1; do
|
||||||
data=$(xclip -o -sel "$selection"; printf x)
|
data=$(xclip -o -sel "$selection"; printf x)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 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}
|
data=${data%x}
|
||||||
|
|
||||||
[[ $data ]] || continue
|
[[ $data == *[^[:blank:]]* ]] || continue
|
||||||
|
|
||||||
[[ ${last_data[$selection]} == "$data" ]] && continue
|
[[ ${last_data[$selection]} == "$data" ]] && continue
|
||||||
last_data[$selection]=$data
|
last_data[$selection]=$data
|
||||||
|
@ -23,6 +26,6 @@ while sleep 1; do
|
||||||
md5=$(md5sum <<< "$data")
|
md5=$(md5sum <<< "$data")
|
||||||
md5=${md5%% *}
|
md5=${md5%% *}
|
||||||
|
|
||||||
printf '%s' "$data" > "$cache_dir/$md5"
|
printf '%s' "$data" > "$cache_dir/$(LC_ALL=C date +%F-%H-%M-%S)-$md5"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue