Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-02-09 14:13:44

samueru-sama
Member
Registered: 2022-11-09
Posts: 9
Windows 10Firefox 128.0

Thunar is not display thumbnails from a custom tumbnailer

I made this simple script that gets the thumbnails from AppImages that I have, yes I know there is the xapp-appimage thumbnailer but it doesn't work with all the appimages that I have.

#!/bin/sh

set -u
INPUT="$(realpath "$1")"
OUTPUT="$(realpath -m "$2")"
SIZE="$3"
_TMPDIR="$(mktemp -d)"
TMPICON="squashfs-root/.DirIcon"
COUNT=0

_error() {
	printf '\n%s\n\n' "ERROR: $*"
	[ -d "$_TMPDIR" ] && rm -rf "$_TMPDIR"
	exit 1
}

command -v magick 1>/dev/null || _error "Missing imagemagick dependency"
[ -x "$INPUT" ] || _error "AppImage does not have executable permission"
mkdir -p "$_TMPDIR" && cd "$_TMPDIR" || _error "Could not create temp directory"
"$INPUT" --appimage-extract '.DirIcon' 1>/dev/null || _error "Failed to extract .DirIcon, is it an AppImage?"

# Resolve possible symlinks
if [ -L ./"$TMPICON" ]; then
	while [ "$COUNT" -lt 10 ]; do
		printf '\n%s\n' "Resolving symlink $TMPICON"
		LINKPATH="$(readlink ./"$TMPICON" 2>/dev/null)"
		"$INPUT" --appimage-extract "${LINKPATH#./}"
		mv -v ./squashfs-root/"${LINKPATH#./}" ./"$TMPICON"
		[ -L ./"$TMPICON" ] || break
		COUNT=$((COUNT + 1))
	done
fi

# Convert to SVG, TODO: Find a way to do this with imagemagick as well
if file "$TMPICON" | grep -q "SVG"; then
	command -v rsvg-convert 1>/dev/null || _error "Missing rsvg-convert dependency"
	rsvg-convert "$TMPICON" -o "$TMPICON"
fi

magick "$TMPICON" -background none -thumbnail "$SIZE" "$TMPICON"
mv -v "$TMPICON" "$OUTPUT"
rm -rf "$_TMPDIR"

While it works perfectly with pcmanfm-qt, it doesn't work with thunar at all, doing some troubleshooting by piping the array to a file I can see that thunar is calling the script without issues since I get this output:

/home/samuel/Local/bin/kdenlive /tmp/samuel/tumbler-YD0Y12.png 128
/home/samuel/Local/bin/libreoffice /tmp/samuel/tumbler-X97D12.png 128
/home/samuel/Local/bin/lite-xl /tmp/samuel/tumbler-UBBD12.png 128
/home/samuel/Local/bin/mpv /tmp/samuel/tumbler-MVJF12.png 128
/home/samuel/Local/bin/nvtop /tmp/samuel/tumbler-YPWE12.png 128

And if I modify the script to copy and check the temp tumbler-*.png images, they are valid png and have the correct requested size (128x128px in this case).

So the issue looks like thunar expects something else from the images? I don't get anything generated in $XDG_CACHE_HOME/thumbnails when using thunar so it looks like the random tumbler-*.png images are just discarded by thunar for some reason.

How can I check what kind of error is being given by tumbler?

I tried running the tumblerd daemon manually in the terminal, same with thunar and I don't see any errors so I'm out of ideas.

UPDATE: I've been able to get an output from tumbler now since I added verbose to the script:

qla2Fj8.png

So it is all running fine according to tumbler but the thumbnail never ends up displaying. 🤔

EDIT: I also just tested the script with caja and it works perfectly with it.

Last edited by samueru-sama (2025-02-09 14:53:18)

Offline

#2 2025-02-10 00:20:43

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,781
LinuxFirefox 135.0

Re: Thunar is not display thumbnails from a custom tumbnailer

If you run tumblerd with debug enabled, I get:

tumblerd-DEBUG: 16:52:45.514: Starting job 15
tumbler-desktop-thumbnailer-DEBUG: 16:52:45.514: 'Exec=/usr/local/bin/appimage %i %o %s': Handling URI 'file:///home/toz/Downloads/tt/kdenlive-24.12.1-x86_64.AppImage'
INPUT=/home/toz/Downloads/tt/kdenlive-24.12.1-x86_64.AppImage
OUTPUT=/tmp/tumbler-DK8X12.png
SIZE=128

Resolving symlink squashfs-root/.DirIcon
squashfs-root/kdenlive.png
renamed './squashfs-root/kdenlive.png' -> './squashfs-root/.DirIcon'

Resolving symlink squashfs-root/.DirIcon
squashfs-root/usr/share/icons/hicolor/64x64/apps/kdenlive.png
renamed './squashfs-root/usr/share/icons/hicolor/64x64/apps/kdenlive.png' -> './squashfs-root/.DirIcon'
renamed 'squashfs-root/.DirIcon' -> '/tmp/tumbler-DK8X12.png'
tumblerd-DEBUG: 16:52:45.595: Error signal for job 15: Code 8, message: (domain gdk-pixbuf-error-quark, code 3) Unrecognized image file format
tumblerd-DEBUG: 16:52:45.595: URIs:
  file:///home/toz/Downloads/tt/kdenlive-24.12.1-x86_64.AppImage

Given that this works with pcmanfm and nemo, I would suggest a tumbler bug report.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2025-02-10 09:39:35

samueru-sama
Member
Registered: 2022-11-09
Posts: 9
Windows 10Firefox 128.0

Re: Thunar is not display thumbnails from a custom tumbnailer

ToZ wrote:

If you run tumblerd with debug enabled, I get:

tumblerd-DEBUG: 16:52:45.514: Starting job 15
tumbler-desktop-thumbnailer-DEBUG: 16:52:45.514: 'Exec=/usr/local/bin/appimage %i %o %s': Handling URI 'file:///home/toz/Downloads/tt/kdenlive-24.12.1-x86_64.AppImage'
INPUT=/home/toz/Downloads/tt/kdenlive-24.12.1-x86_64.AppImage
OUTPUT=/tmp/tumbler-DK8X12.png
SIZE=128

Resolving symlink squashfs-root/.DirIcon
squashfs-root/kdenlive.png
renamed './squashfs-root/kdenlive.png' -> './squashfs-root/.DirIcon'

Resolving symlink squashfs-root/.DirIcon
squashfs-root/usr/share/icons/hicolor/64x64/apps/kdenlive.png
renamed './squashfs-root/usr/share/icons/hicolor/64x64/apps/kdenlive.png' -> './squashfs-root/.DirIcon'
renamed 'squashfs-root/.DirIcon' -> '/tmp/tumbler-DK8X12.png'
tumblerd-DEBUG: 16:52:45.595: Error signal for job 15: Code 8, message: (domain gdk-pixbuf-error-quark, code 3) Unrecognized image file format
tumblerd-DEBUG: 16:52:45.595: URIs:
  file:///home/toz/Downloads/tt/kdenlive-24.12.1-x86_64.AppImage

Given that this works with pcmanfm and nemo, I would suggest a tumbler bug report.

I found a solution, there might be still a bug though.

https://github.com/Samueru-sama/simple- … ler/pull/1

The issue was that I used to use imagemagick to resize the thumbnail in place and then finally I mv the thumbnail to $OUTPUT. I noticed this after looking at some custom thumbnailer examples for thunar and noticed that they made imagemagick directly place the output image to output.

I have no idea why modifying the image in place and then moving it breaks it for thunar, maybe some permission issue?

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.009 seconds, 7 queries executed - Memory usage: 545.45 KiB (Peak: 546.29 KiB) ]