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
|
||||
|
||||
LC_COLLATE=C
|
||||
|
||||
dmenu_lines=${CLIPMENU_LINES-8}
|
||||
|
||||
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")
|
||||
|
||||
lines=$(wc -l "$file")
|
||||
|
@ -14,10 +21,14 @@ for file in /tmp/clipmenu/*; do
|
|||
first_line+=" ($lines lines)"
|
||||
fi
|
||||
|
||||
ordered_selections+=("$first_line")
|
||||
selections[$first_line]=$file
|
||||
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
|
||||
|
||||
|
|
11
clipmenud
11
clipmenud
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
cache_dir=/tmp/clipmenu/
|
||||
mkdir -p "$cache_dir"
|
||||
cache_dir=/tmp/clipmenu.$USER/
|
||||
mkdir -p -m0700 "$cache_dir"
|
||||
|
||||
declare -A last_data
|
||||
|
||||
|
@ -13,9 +13,12 @@ while sleep 1; do
|
|||
data=$(xclip -o -sel "$selection"; printf x)
|
||||
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 ]] || continue
|
||||
[[ $data == *[^[:blank:]]* ]] || continue
|
||||
|
||||
[[ ${last_data[$selection]} == "$data" ]] && continue
|
||||
last_data[$selection]=$data
|
||||
|
@ -23,6 +26,6 @@ while sleep 1; do
|
|||
md5=$(md5sum <<< "$data")
|
||||
md5=${md5%% *}
|
||||
|
||||
printf '%s' "$data" > "$cache_dir/$md5"
|
||||
printf '%s' "$data" > "$cache_dir/$(LC_ALL=C date +%F-%H-%M-%S)-$md5"
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue