version 1.0
This commit is contained in:
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
export XDG_RUNTIME_DIR=/run/user/$(id -u)
|
||||
|
||||
thumb_dir="${XDG_CACHE_HOME:-$HOME/.cache}/cliphist/thumbs"
|
||||
mkdir -p "$thumb_dir"
|
||||
|
||||
make_thumb() { # $1 - исходник, $2 - результат
|
||||
if command -v gdk-pixbuf-thumbnailer >/dev/null 2>&1; then
|
||||
gdk-pixbuf-thumbnailer -s 256 "$1" "$2" 2>/dev/null
|
||||
elif command -v magick >/dev/null 2>&1; then
|
||||
magick "$1" -resize '256x256>' "$2" 2>/dev/null
|
||||
elif command -v convert >/dev/null 2>&1; then
|
||||
convert "$1" -resize '256x256>' "$2" 2>/dev/null
|
||||
fi
|
||||
# если тулза нет/ошибка — отдаём оригинал, wofi сам смасштабирует
|
||||
[ -s "$2" ] || cp -f "$1" "$2"
|
||||
}
|
||||
|
||||
wofi_input=""
|
||||
|
||||
while read -r line; do
|
||||
[[ "$line" == *"<meta http-equiv="* ]] && continue
|
||||
[[ -z "$line" ]] && continue
|
||||
|
||||
id="${line%%[[:space:]]*}"
|
||||
|
||||
if [[ "$line" == *binary* ]]; then
|
||||
thumb_path="${thumb_dir}/${id}.png"
|
||||
|
||||
if [ ! -s "$thumb_path" ]; then
|
||||
tmp="$(mktemp)"
|
||||
# ВАЖНО: передаём строку через pipe,
|
||||
# иначе decode прочитает stdin цикла и «съест» список
|
||||
printf '%s\n' "$line" | cliphist decode > "$tmp" 2>/dev/null
|
||||
[ -s "$tmp" ] && make_thumb "$tmp" "$thumb_path"
|
||||
rm -f "$tmp"
|
||||
fi
|
||||
|
||||
if [ -s "$thumb_path" ]; then
|
||||
wofi_input+="img:${thumb_path}\n"
|
||||
else
|
||||
wofi_input+="${line}\n"
|
||||
fi
|
||||
else
|
||||
wofi_input+="${line}\n"
|
||||
fi
|
||||
done <<< "$(cliphist list)"
|
||||
|
||||
choice="$(printf '%b' "$wofi_input" | wofi -I --dmenu --cache-file=/dev/null \
|
||||
-Dimage_size=100 -Dynamic_lines=true --prompt "Буфер обмена")"
|
||||
|
||||
[ -z "$choice" ] && exit 0
|
||||
|
||||
if [[ "$choice" == img:* ]]; then
|
||||
f="${choice#img:}"
|
||||
id="$(basename "$f" .png)"
|
||||
printf '%s\t' "$id" | cliphist decode | wl-copy
|
||||
else
|
||||
printf '%s\n' "$choice" | cliphist decode | wl-copy
|
||||
fi
|
||||
@@ -0,0 +1,53 @@
|
||||
@import "$HOME/.config/aether/theme/wofi.css";
|
||||
|
||||
#img {
|
||||
padding: 5px;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
#entry {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
|
||||
window {
|
||||
background-color: @bg;
|
||||
border: 2px solid @gray3;
|
||||
}
|
||||
|
||||
input {
|
||||
background-color: @bg;
|
||||
color: @fg;
|
||||
border: 1px solid @gray2;
|
||||
}
|
||||
|
||||
input:selected {
|
||||
background-color: @gray1;
|
||||
color: @fg_bright;
|
||||
}
|
||||
|
||||
#entry {
|
||||
color: @fg;
|
||||
background-color: @bg;
|
||||
padding: 5px;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
#entry:selected {
|
||||
background-color: @gray1;
|
||||
color: @fg_bright;
|
||||
}
|
||||
|
||||
scrollbar {
|
||||
background-color: @bg;
|
||||
}
|
||||
|
||||
scrollbar slider {
|
||||
background-color: @gray2;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
scrollbar slider:hover {
|
||||
background-color: @gray3;
|
||||
}
|
||||
Reference in New Issue
Block a user