Open
Description
I have been trying to find a way to get chafa to work alongside as a image previewer for setting wallpaper. My wallpapers dir contains valid image formats 'png/jpg/gif'. While the static image preview is fine, during gif preview it just vomits on the terminal.
chafa-fzf-reduced.mp4
I have tested many different alternatives such as imgcat
, kitty's icat
and ueberzugpp
. where ueberzugpp
is the only one who can render gif preview without any terminal buffer abuse. Kitty
and imgcat
does not seem to support animated previews.
I have seen many people just putting the --animate off
argument. but I would like to see if this can be fixed or hacked in some sense. Because there is nothing faster than chafa on the whole internet afaik.
Snippet from my wallpaper tool
set_selected_wallpaper() {
local wallpaper_dir
wallpaper_dir="$(get_wallpaper_dir)"
if [ -z "$wallpaper_dir" ]; then
log_message "ERROR" "Wallpaper directory not found."
return 1
fi
# Check if fzf is installed
if ! command -v fzf >/dev/null; then
log_message "ERROR" "fzf is not installed. Cannot select a wallpaper."
return 1
fi
# Use fzf to select a wallpaper
local preview_cmd
if [[ -n $KITTY_WINDOW_ID && "$(get_battery_status)" == "Discharging" ]]; then
preview_cmd="kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=\${FZF_PREVIEW_COLUMNS}x\${FZF_PREVIEW_LINES}@0x0 {}"
elif command -v chafa >/dev/null; then
preview_cmd="chafa --clear -s \${FZF_PREVIEW_COLUMNS}x\${FZF_PREVIEW_LINES} {}"
elif command -v viu >/dev/null; then
preview_cmd="viu {}"
else
log_message "WARNING" "No image preview tool (kitty icat, viu, or chafa) is installed. Preview will not be available."
preview_cmd="echo 'Preview not available {}'"
fi
# Use fzf to select a wallpaper with image preview
local selected_wallpaper
selected_wallpaper=$(
find "$wallpaper_dir" -type f |
fzf --reverse --border \
--preview "$preview_cmd" \
--preview-window=top:75%:wrap
)
if [ -z "$selected_wallpaper" ]; then
log_message "WARNING" "No wallpaper selected."
return 0
fi
# Stop the slideshow and set the selected wallpaper
stop_slideshow
if [[ "$selected_wallpaper" == *.gif ]]; then
log_message "INFO" "Animating GIF wallpaper: $selected_wallpaper"
animate_gif_wallpaper "$selected_wallpaper"
else
log_message "INFO" "Setting static wallpaper: $selected_wallpaper"
set_wallpaper_fallback "$selected_wallpaper"
fi
set_slideshow_status "paused"
log_message "INFO" "Selected wallpaper set: $selected_wallpaper"
}
Expected behaviour:
uerberzugpp-fzf-reduced.mp4
Environment:
OS : ArchLinux (6.12.10)
PROC : Intel(R) Core(TM) i7-14700HX
TERM : kitty (0.39.0)
WM : Hyprland (0.46.0)