demoth / jake2

Quake 2 java port
GNU General Public License v2.0
59 stars 9 forks source link

Model viewer: thumbnailer support #113

Open demoth opened 3 months ago

demoth commented 3 months ago

Add support to run model-viewer as a cli tool to generate png thumbnails previews for files for the operating system.

For example, to create a thumbnailer for .bsp files:

sudo nano /usr/share/thumbnailers/bsp.thumbnailer

[Thumbnailer Entry]
TryExec=/usr/local/bin/bsp-thumbnailer
Exec=/usr/local/bin/bsp-thumbnailer %i %o %s
MimeType=application/x-bsp

Create the Thumbnailer Script: sudo nano /usr/local/bin/bsp-thumbnailer

#!/bin/bash

input_file="$1"
output_file="$2"
size="$3"

# Replace this with the command to generate a thumbnail from your application
/path/to/your/application --render-thumbnail "$input_file" --output "$output_file" --size "$size"

Create a new MIME type definition file in /usr/share/mime/packages/ for each file type.

sudo nano /usr/share/mime/packages/quake2-resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-bsp">
    <comment>BSP File</comment>
    <glob pattern="*.bsp"/>
  </mime-type>
  <mime-type type="application/x-pcx">
    <comment>PCX Image</comment>
    <glob pattern="*.pcx"/>
  </mime-type>
  <mime-type type="application/x-mdl">
    <comment>MDL File</comment>
    <glob pattern="*.mdl"/>
  </mime-type>
  <mime-type type="application/x-wal">
    <comment>WAL File</comment>
    <glob pattern="*.wal"/>
  </mime-type>
</mime-info>

Update the MIME database: sudo update-mime-database /usr/share/mime