Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions contrib/cliphist-fuzzel-img
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
#!/usr/bin/env bash

# requires imagemagick to generate thumbnails

thumbnail_size=64
thumbnail_dir="${XDG_CACHE_HOME:-$HOME/.cache}/cliphist/thumbnails"

cliphist_list=$(cliphist list)
if [ -z "$cliphist_list" ]; then
fuzzel -d --placeholder "cliphist: please store something first" --lines 0
fuzzel -d --prompt-only "cliphist: please store something first "

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from placeholder to prompt because of conflicts with minimal-lines. This could be changed to fuzzel -d --prompt-only "" --placeholder "cliphist: please store something first " to keep placeholder style.

rm -rf "$thumbnail_dir"
exit
fi

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

# Write square shaped thumbnail to cache if it doesn't exist
# Write binary image to cache file if it doesn't exist
read -r -d '' thumbnail <<EOF
/^[0-9]+\s<meta http-equiv=/ { next }
match(\$0, /^([0-9]+)\s(\[\[\s)?binary.*(jpg|jpeg|png|bmp)/, grp) {
cliphist_item_id=grp[1]
ext=grp[3]
thumbnail_file=cliphist_item_id"."ext
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)
system("[ -f ${thumbnail_dir}/"thumbnail_file" ] || echo " cliphist_item_id "\\\\\t | cliphist decode >${thumbnail_dir}/"thumbnail_file)
print \$0"\0icon\x1f${thumbnail_dir}/"thumbnail_file
next
}
Expand Down
Loading