Set custom thumbnails for .txt and .gcode files in Thunar

Hello,
I just installed Zorin 16 ,I would like to ask for some advice and how to's about a particular case. I work with a large list of .txt and .gcode files, they are all text of course , some kind of x and y coordinates representing a shape, so my laser cutter will take one and cut the corresponding shape, what I want to achieve is to be able to see the corresponding image as a thumbnail of the file, so I can pick the right one in a glimpse instead of open one by one to check.sometimes is easy to pick them by name but usually I must to open a bunch before I can find the right one. I did my homework and tried under custom actions and preferences settings with no luck, I asked chatgpt too but I got more confused :slight_smile: So any help and advice is appreciated! I think I can edit the images for the thumbnails individually but no idea how to proceed to make everything work.
Thank you!

Core or Lite? Actually the method i though worked for Core/Pro doesn't work system wide for gcode, @Storm might have the answer

I think is Lite cos I have a Zorin OS Lite Desktop file in /usr/share/xsessions and when I do cat /proc/version I get:

linux version 5.15.0-71-generic (buildd@lcy02-amd64-111) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #78~20.04.1-Ubuntu SMP Wed Apr 19 11:26:48 UTC 2023

Besides, cat /etc/os-release yields:
NAME="Zorin OS"
VERSION="16.2"
ID=zorin
ID_LIKE=ubuntu
PRETTY_NAME="Zorin OS 16.2"
VERSION_ID="16"
HOME_URL="Zorin OS - Make your computer better."
SUPPORT_URL="https://help.zorin.com/"
BUG_REPORT_URL="Send Feedback - Zorin OS"
PRIVACY_POLICY_URL="Privacy Policy - Zorin"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Hopefully this can help:
https://docs.xfce.org/xfce/tumbler/available_plugins#customized_thumbnailer_for_text-based_documents

Oh! I read that so I need to install tumbler and ImageMagick, easy, now I edit the thumbnailer file and the supporting script so far so good but how I add my little thumbnail image? will tumber produce a little preview of the text inside my files? I want to view the shape that represent the text, not the text itself, so I guess a little png image file will be needed. Hope it makes sense :slight_smile:

ImageMagick comes with Zorin OS.

I could be wrong... But I believe tumbler comes with Zorin OS Lite, as well.


I just looked, it does.
You can install this, however:

tumbler-plugins-extra

Then create the script outlined in the XFCE docs.

1 Like

I just did ImageMagik --version and tumbler --version and they are not in the system so I guess Lite comes without them. so I will install them, my problem is I have no idea what to do with the thumbnailer file and the script ,specially the script for Imagemagick ,I mean it says it will convert a "tempFile" so I'm assuming they are talking about the small preview of my text file, but this is not the shape that the text file represents, anyway I will install both and play around to see if I can get something useful.

I exclusively use Zorin OS Lite. I assure you, they come with.
The --version command does not work with everything. It depends on whether the maintainer includes the version read in the package. Some do, some don't. So running the version command is not a sure fire way to be sure if something is installed.
Just run:

sudo apt install imagemagick

sudo apt install tumbler

It should say something like:
imagemagick is already the newest version (8:6.9.10.23+dfsg-2.1ubuntu11.7). imagemagick set to manually installed.
If not, then it will install it.

Navigate in your file manager to the path ~/.local/share/thumbnailers/
The tilde (~) is shorthand for HOME.
If you do not see the .local folder, tap the keyboard shortcut ctrl+h. You then will see it (and other folders and files with a . in front of them).
Right click in an open area and select Create New File. Name that file text.thumbnailer

Copy the below and paste it into that file you just created and save the file.

[Thumbnailer Entry]
Version=1.0
Encoding=UTF-8
Type=X-Thumbnailer
Name=Text Thumbnailer
MimeType=text/plain;text/html;text/css;
Exec=sh -c '~/bin/textthumb %s %i %o'

Reboot and test.

Monkey see, monkey do,so I did too and found some interesting results, no thumbnailers folder in my installation so not sure if I should create one and add the text.thumnailer. In the other hand, I found some .so files of tumbler in another location, here the screenshots, also I installed tumbler extras using terminal.


Ho! I almost forgot, you were so right about tumbler and ImageMagick :slight_smile:

I found this thread: nautilus - How to manually create a thumbnail for one file using another file - Ask Ubuntu and they used this script and nautilus, no idea how it works (yet) so I guess I can install nautilus and give it a try :slight_smile:

#!/bin/bash

# Based on CC-BY 2016 Marcin Kaminski https://askubuntu.com/users/98096/marcin-kaminski
# https://askubuntu.com/a/201894/216568

# USAGE: mkthumb.sh [-s] [-r] <path> [path]
# create nautilus thumbnails for clips in the directories (and their
# sub-directories) given as parameters.
# -s is used to skip generating thumbnails that already exist

skip_existing=0
if [[ "${1}" == "-s" ]]; then
    skip_existing=1
    shift
fi

maxdepth="1"
if [[ "${1}" == "-r" ]]; then
    maxdepth="9999"
    shift
fi

mkImageThumb() {
    size="${3}"
    file="${1}"
    dest="${2}"
    convert -thumbnail ${size}x${size} "${file}[0]" "${dest}" &>/dev/null
    if (( $? == 0 )); then
        echo "OK   ${file} [${dest}]"
    else
        echo "FAIL ${file}"
    fi
}

OLDIFS="${IFS}"
IFS=$'\n'
for dir in $@; do
    realdir=`realpath "${dir}"`
    echo "Processing directory ${realdir}"
    for file in $(find "${realdir}" -maxdepth ${maxdepth} -regextype posix-egrep -iregex '.*\.clip'); do
        md5=$(echo -n "${file}" | perl -MURI::file -MDigest::MD5=md5_hex -ne 'print md5_hex(URI::file->new($_));')
        image=$(dirname "${file}")/$(basename "${file}" .clip).png
        dest="${HOME}/.cache/thumbnails/normal/${md5}.png"
        if [[ ! -f "${dest}" || "${skip_existing}" != "0" ]]; then
            mkImageThumb "${image}" "${dest}" 128
        else
            echo "SKIP ${file}"
        fi
        dest="${HOME}/.cache/thumbnails/large/${md5}.png"
        if [[ ! -f "${dest}" || "${skip_existing}" != "0" ]]; then
                mkImageThumb "${image}" "${dest}" 256
        else
            echo "SKIP ${file}"
        fi
    done
done
IFS="${OLDIFS}"

Nautilus should automatically show thumbsnails. It does with mine txt pdf etc.

yeah but I want to show a png image file that doesn't correspond to the content of the txt file as a thumbnail, lets say I want to see a puppy as a thumbnail of a txt file :slight_smile:

Then you have to edit the mimetype icons of your current icon theme. There's several mimetype icons for each file type, so you going to do some hunting.

But if I do so, will it show the same puppy image with all the txt files or I can edit the image to each file in my folder? I found several alternatives in github but they are for files generated by prusaslicer, they come with an encoded image in base64 inside the file, but my files are like:


G0 X-51.492 Y32.691
G0 X-51.492 Y31.191
G0 X-51.492 Y29.691
G0 X-51.492 Y28.191
G0 X-51.492 Y26.691
G0 X-51.492 Y25.191
G0 X-51.492 Y23.691
G0 X-51.492 Y22.191
G0 X-51.492 Y20.691
G0 X-51.492 Y19.191
G0 X-51.492 Y17.691
G0 X-51.492 Y16.191

Something like this, all the nc files here are plain text, like gode or txt

Ah, now I understand what you're trying to do. I think Dolphin can do that, but that's a QT/KDE file browser.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.