almost finaly

This commit is contained in:
2026-09-13 19:18:33 +06:00
parent 3a7be7b631
commit 18ed76636f
17 changed files with 894 additions and 0 deletions
+61
View File
@@ -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
+51
View File
@@ -0,0 +1,51 @@
#img {
padding: 5px;
width: 120px;
height: 120px;
}
#entry {
padding: 10px;
}
window {
background-color: #090909;
border: 2px solid #fefefe;
}
input {
background-color: #090909;
color: #fefefe;
border: 1px solid #62605a;
}
input:selected {
background-color: @gray1;
color: #fcfcfc;
}
#entry {
color: #fefefe;
background-color: #090909;
padding: 5px;
margin: 2px;
}
#entry:selected {
background-color: #c3c3c3;
color: #fcfcfc;
}
scrollbar {
background-color: #090909;
}
scrollbar slider {
background-color: #62605a;
border-radius: 5px;
}
scrollbar slider:hover {
background-color: #808080;
}