Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model viewer: thumbnailer support #113

Open
demoth opened this issue May 21, 2024 · 0 comments
Open

Model viewer: thumbnailer support #113

demoth opened this issue May 21, 2024 · 0 comments
Labels
model-viewer Standalone viewer for q2 file formats

Comments

@demoth
Copy link
Owner

demoth commented May 21, 2024

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

@demoth demoth added the model-viewer Standalone viewer for q2 file formats label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
model-viewer Standalone viewer for q2 file formats
Projects
None yet
Development

No branches or pull requests

1 participant