Skip to content

rhafaelcm/thumbnail_plt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PLT Thumbnail (HP-GL) Generator for GNOME

Thumbnailer for the GNOME desktop environment that displays thumbnails for PLT (.plt) and HP-GL (.hpgl) files in the file manager (Nautilus/Files).

This tool uses plotconvert to rasterize vector plot files into PNG thumbnails, with stroke scaling optimized for small preview sizes.

Features

  • Converts .plt and .hpgl files to PNG thumbnails via plotconvert.
  • Uses --png-max-size to limit the longest side to the size requested by GNOME.
  • Uses --png-stroke-scale 10 for visible outlines in small thumbnails.
  • Registers a custom MIME type (application/x-plt) for .plt files.
  • Also supports the standard MIME type application/vnd.hp-hpgl for .hpgl files.
  • Downloads the latest plotconvert binary automatically during installation.

Dependencies

  • curl or wget: To download plotconvert from GitHub Releases. Install with sudo apt install curl if needed.
  • GNOME Desktop Environment: Required for thumbnailer integration (Nautilus/Files).
  • sudo: Required to install plotconvert and the thumbnailer script in /usr/bin/.

Installation

First, make the scripts executable:

chmod +x install.sh install-and-update.sh uninstall.sh

Then run the installer:

./install.sh

To install (if needed) and update plotconvert when a newer release is available:

./install-and-update.sh

This script checks the latest version on GitHub, compares it with the installed plotconvert, downloads and installs the update when a newer version exists, and refreshes the thumbnailer files.

The script will:

  1. Fetch the latest plotconvert release from GitHub Releases.
  2. Download and install the plotconvert-linux-x86_64 binary to /usr/bin/plotconvert (requires sudo).
  3. Register a custom MIME type (application/x-plt) for .plt files at ~/.local/share/mime/packages/.
  4. Copy plt-thumbnailer.sh to /usr/bin/ and make it executable (requires sudo).
  5. Copy plt.thumbnailer to ~/.local/share/thumbnailers/.
  6. Update the paths in the .thumbnailer file.

Note: The thumbnailer script and plotconvert binary must be installed in /usr/bin/ because GNOME 43+ runs thumbnailers inside a bubblewrap (bwrap) sandbox that only has access to /usr, /lib, and /lib64. Scripts in ~/.local/bin/ are not accessible inside the sandbox.

After installation, clear the thumbnail cache and restart Nautilus:

rm -rf ~/.cache/thumbnails/*
nautilus -q

Updating plotconvert

If the thumbnailer is already installed, run:

./install-and-update.sh

The script will:

  1. Fetch the latest plotconvert release from GitHub.
  2. Compare it with the installed version (plotconvert --version).
  3. Download and install the new binary when a newer version is available.
  4. Refresh plt-thumbnailer.sh and plt.thumbnailer.

If the thumbnailer is not installed yet, it runs ./install.sh automatically.

Uninstallation

./uninstall.sh

After uninstalling, clear the cache and restart Nautilus:

rm -rf ~/.cache/thumbnails/*
nautilus -q

Manual Installation

If you prefer to install manually:

  1. Download the latest plotconvert binary:
TAG=$(curl -fsSL https://api.github.com/repos/rhafaelcm/plotconvert/releases/latest \
  | grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' \
  | sed -E 's/.*"([^"]*)".*/\1/')
curl -fsSL "https://github.com/rhafaelcm/plotconvert/releases/download/${TAG}/plotconvert-linux-x86_64" \
  -o /tmp/plotconvert
sudo install -m 755 /tmp/plotconvert /usr/bin/plotconvert
  1. Register the custom MIME type:
mkdir -p ~/.local/share/mime/packages
cat > ~/.local/share/mime/packages/application-x-plt.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-plt">
    <comment>HP-GL Plot File</comment>
    <glob pattern="*.plt"/>
  </mime-type>
</mime-info>
EOF
update-mime-database ~/.local/share/mime
  1. Copy the script to /usr/bin/ and make it executable:
sudo cp plt-thumbnailer.sh /usr/bin/
sudo chmod +x /usr/bin/plt-thumbnailer.sh
  1. Create the thumbnailers directory (if it doesn't exist) and copy the configuration file:
mkdir -p ~/.local/share/thumbnailers
cp plt.thumbnailer ~/.local/share/thumbnailers/
  1. Update the paths in the .thumbnailer file:
sed -i "s|^TryExec=.*|TryExec=/usr/bin/plt-thumbnailer.sh|" ~/.local/share/thumbnailers/plt.thumbnailer
sed -i "s|^Exec=.*|Exec=/usr/bin/plt-thumbnailer.sh %i %o %s|" ~/.local/share/thumbnailers/plt.thumbnailer
  1. Clear the cache and restart Nautilus:
rm -rf ~/.cache/thumbnails/*
nautilus -q

How It Works

GNOME uses .thumbnailer files in ~/.local/share/thumbnailers/ (user-level) or /usr/share/thumbnailers/ (system-level) to generate thumbnails.

The plt.thumbnailer file specifies:

  • MimeType: application/x-plt for .plt files and application/vnd.hp-hpgl for .hpgl files.
  • TryExec: Path to the script. The system checks if it exists before using it.
  • Exec: Command executed by GNOME. %i = input file, %o = output file, %s = requested size.

The plt-thumbnailer.sh script receives these arguments and calls plotconvert:

plotconvert --to png --png-stroke-scale 10 --png-max-size <SIZE> --output <output> <input>

The --png-max-size parameter receives the size requested by GNOME (%s), limiting the longest side of the PNG. The default is 256 pixels if no size is provided.

GNOME 43+ runs external thumbnailers inside a bubblewrap (bwrap) sandbox for security. The sandbox only mounts /usr, /lib, and /lib64 as read-only, which is why both plotconvert and the script must be installed in /usr/bin/.

Troubleshooting

  • Thumbnails not showing:

    • Check that plotconvert is installed: which plotconvert && plotconvert --version
    • Verify the MIME type is registered: xdg-mime query filetype yourfile.plt (should return application/x-plt)
    • Verify the paths in ~/.local/share/thumbnailers/plt.thumbnailer are correct.
    • Check that plt-thumbnailer.sh is executable: ls -la /usr/bin/plt-thumbnailer.sh
    • Clear the cache: rm -rf ~/.cache/thumbnails/* and restart: nautilus -q
    • Check logs: journalctl --user -b | grep -i thumb
  • Manual script test:

/usr/bin/plt-thumbnailer.sh /path/to/file.plt /tmp/test.png 256
  • Unsupported architecture:
    • Currently only x86_64 is supported. The installer downloads plotconvert-linux-x86_64 from GitHub Releases.

Contributing

Feel free to open issues or pull requests if you find problems or have suggestions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages