Skip to content

Commit 6eda526

Browse files
authored
feat(contrib): drop imagemagick in cliphist-fuzzel-img (#153)
1 parent e18c06a commit 6eda526

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

contrib/cliphist-fuzzel-img

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
#!/usr/bin/env bash
22

3-
# requires imagemagick to generate thumbnails
4-
5-
thumbnail_size=64
63
thumbnail_dir="${XDG_CACHE_HOME:-$HOME/.cache}/cliphist/thumbnails"
74

85
cliphist_list=$(cliphist list)
96
if [ -z "$cliphist_list" ]; then
10-
fuzzel -d --placeholder "cliphist: please store something first" --lines 0
7+
fuzzel -d --prompt-only "cliphist: please store something first "
118
rm -rf "$thumbnail_dir"
129
exit
1310
fi
1411

1512
[ -d "$thumbnail_dir" ] || mkdir -p "$thumbnail_dir"
1613

17-
# Write square shaped thumbnail to cache if it doesn't exist
14+
# Write binary image to cache file if it doesn't exist
1815
read -r -d '' thumbnail <<EOF
1916
/^[0-9]+\s<meta http-equiv=/ { next }
2017
match(\$0, /^([0-9]+)\s(\[\[\s)?binary.*(jpg|jpeg|png|bmp)/, grp) {
2118
cliphist_item_id=grp[1]
2219
ext=grp[3]
2320
thumbnail_file=cliphist_item_id"."ext
24-
system("[ -f ${thumbnail_dir}/"thumbnail_file" ] || echo " cliphist_item_id "\\\\\t | cliphist decode | magick - -thumbnail ${thumbnail_size}^ -gravity center -extent ${thumbnail_size} ${thumbnail_dir}/"thumbnail_file)
21+
system("[ -f ${thumbnail_dir}/"thumbnail_file" ] || echo " cliphist_item_id "\\\\\t | cliphist decode >${thumbnail_dir}/"thumbnail_file)
2522
print \$0"\0icon\x1f${thumbnail_dir}/"thumbnail_file
2623
next
2724
}

0 commit comments

Comments
 (0)