new tool: cliphist-wofi

parent 24635079
...@@ -13,6 +13,9 @@ The set of utilities used in Ximper Linux includes various tools that help speed ...@@ -13,6 +13,9 @@ The set of utilities used in Ximper Linux includes various tools that help speed
Script for automatically starting applications that support XDG Autostart. Script for automatically starting applications that support XDG Autostart.
Necessary for window managers that do not support this specification. Necessary for window managers that do not support this specification.
### cliphist-wofi
Script for displaying clipboard menu with image support via wofi.
## License ## License
MIT License MIT License
......
#!/bin/bash
wofi_flags="$*"
thumb_dir="${XDG_CACHE_HOME:-$HOME/.cache}/cliphist/thumbs"
mkdir -p "$thumb_dir"
cliphist_list="$(cliphist list)"
for thumb in "$thumb_dir"/*; do
clip_id="${thumb##*/}"
clip_id="${clip_id%.*}"
check=$(rg <<< "$cliphist_list" "^$clip_id\s")
if [ -z "$check" ]; then
>&2 rm -v "$thumb"
fi
done
read -r -d '' prog <<EOF
/^[0-9]+\s<meta http-equiv=/ { next }
match(\$0, /^([0-9]+)\s(\[\[\s)?binary.*(jpg|jpeg|png|bmp)/, grp) {
image = grp[1]"."grp[3]
system("[ -f $thumb_dir/"image" ] || echo " grp[1] "\\\\\t | cliphist decode | magick - -resize '256x256>' $thumb_dir/"image )
print "img:$thumb_dir/"image
next
}
1
EOF
choice=$(gawk <<< "$cliphist_list" "$prog" | wofi -I --dmenu -Dimage_size=100 -Dynamic_lines=true $wofi_flags)
[ -z "$choice" ] && exit 1
if [ "${choice::4}" = "img:" ]; then
thumb_file="${choice:4}"
clip_id="${thumb_file##*/}"
clip_id="${clip_id%.*}\t"
else
clip_id="${choice}"
fi
printf '%s' "$clip_id" | cliphist decode
...@@ -2,7 +2,7 @@ prefix ?= /usr ...@@ -2,7 +2,7 @@ prefix ?= /usr
bindir ?= $(prefix)/bin bindir ?= $(prefix)/bin
DESTDIR ?= DESTDIR ?=
EXECUTABLES = wm-xdg-autostart EXECUTABLES = wm-xdg-autostart cliphist-wofi
all: install all: install
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment