Skip to content

FileAssoc: Slice D — Linux: .desktop MimeType + XDG MIME XML + .deb postinstall + snap update #668

@fernandotonon

Description

@fernandotonon

Parent epic: #664
Depends on: Slice A (#665).

Goal

On a Linux install (deb or snap), file managers (Nautilus, Dolphin, Nemo) and xdg-open route the supported 3D formats to QtMeshEditor.

Scope

Shared assets (referenced by both deb and snap)

  • packaging/linux/qtmesheditor.desktop (canonical file, copied into both deb and snap at build time):

    [Desktop Entry]
    Name=QtMeshEditor
    GenericName=3D Model Editor
    Comment=Free 3D asset tool — FBX/glTF/materials/MCP CLI
    Keywords=3D;mesh;FBX;glTF;model;material;animation;Ogre;editor;
    Exec=qtmesheditor %F
    TryExec=qtmesheditor
    Icon=qtmesheditor
    Terminal=false
    Type=Application
    Categories=Graphics;3DGraphics;Development;
    MimeType=model/gltf-binary;model/gltf+json;application/vnd.autodesk.fbx;model/obj;model/stl;application/vnd.ms-collada+xml;application/sla;model/x-ply;application/x-3ds;application/x-ogre-mesh;application/x-ogre-material;application/x-ps1-rsd;application/x-ps1-tmd;
    StartupWMClass=QtMeshEditor
    

    Note Exec=qtmesheditor %F (capital F = supports multi-file selection from "Open With" multi-select; deferred to Slice A's multi-file handling).

  • packaging/linux/qtmesheditor.xml — XDG shared-mime-info entries declaring custom MIME types for formats without a registered IANA type:

    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
      <mime-type type="application/x-ogre-mesh">
        <comment>Ogre 3D Mesh</comment>
        <glob pattern="*.mesh"/>
        <icon name="qtmesheditor-mesh"/>
      </mime-type>
      <mime-type type="application/x-ogre-material">
        <comment>Ogre 3D Material Script</comment>
        <glob pattern="*.material"/>
        <icon name="qtmesheditor-material"/>
      </mime-type>
      <mime-type type="application/x-ps1-rsd">
        <comment>PlayStation Resource Database</comment>
        <glob pattern="*.rsd"/>
        <icon name="qtmesheditor-mesh"/>
      </mime-type>
      <mime-type type="application/x-ps1-tmd">
        <comment>PlayStation TMD Model</comment>
        <glob pattern="*.tmd"/>
        <icon name="qtmesheditor-mesh"/>
      </mime-type>
      <mime-type type="model/x-ply">
        <comment>Stanford Polygon Format</comment>
        <glob pattern="*.ply"/>
        <icon name="qtmesheditor-static"/>
      </mime-type>
      <!-- Other formats use their IANA-registered types so no entries needed here -->
    </mime-info>

.deb

  • DEBIAN-control.in updated to declare:
    Provides: 3d-model-viewer
    
  • New install-time files in the .deb:
    • /usr/share/applications/qtmesheditor.desktop (from the shared asset).
    • /usr/share/mime/packages/qtmesheditor.xml (from the shared asset).
    • /usr/share/icons/hicolor/<sizes>/apps/qtmesheditor.png — the app icon (probably already exists; verify).
    • /usr/share/icons/hicolor/<sizes>/mimetypes/qtmesheditor-mesh.png, qtmesheditor-material.png, qtmesheditor-static.png, qtmesheditor-animatable.png — the per-family icons mirroring Slices B and C.
  • DEBIAN-postinst (new — currently the project has no postinst):
    #!/bin/sh
    set -e
    if command -v update-desktop-database >/dev/null 2>&1; then
        update-desktop-database -q /usr/share/applications || true
    fi
    if command -v update-mime-database >/dev/null 2>&1; then
        update-mime-database /usr/share/mime || true
    fi
    if command -v gtk-update-icon-cache >/dev/null 2>&1; then
        gtk-update-icon-cache --quiet /usr/share/icons/hicolor || true
    fi
    exit 0
  • DEBIAN-postrm mirrors postinst for clean uninstall.
  • These need wiring through the existing CMake / packaging path that produces the .deb. Verify the project's current packaging step (the workflow at .github/workflows/deploy.yml mentions deb) and extend it to copy the new files.

Snap

  • snap/gui/qtmesheditor.desktop updated to add the MimeType= line (currently absent — see the existing file). Replace it with the canonical packaging/linux/qtmesheditor.desktop minus the ${SNAP}/meta/gui/icon.png rewrite that the snap toolchain currently does.
  • snap/snapcraft.yaml updated to register the XDG MIME XML:
    apps:
      qtmesheditor:
        command: bin/qtmesheditor
        common-id: io.github.fernandotonon.QtMeshEditor
        desktop: meta/gui/qtmesheditor.desktop
        plugs:
          - home
          - removable-media
          - desktop
          - desktop-legacy
          - wayland
          - x11
          - opengl
    parts:
      qtmesheditor:
        # ... existing part definition ...
        override-prime: |
          snapcraftctl prime
          mkdir -p $SNAPCRAFT_PRIME/meta/mime
          cp $SNAPCRAFT_PROJECT_DIR/packaging/linux/qtmesheditor.xml $SNAPCRAFT_PRIME/meta/mime/qtmesheditor.xml
    Note: snap's MIME registration story is weaker than deb's — file managers may not pick up custom MIME types from a snap-confined app unless the snap is installed classic or with extra plugs. Document the limitation; for users who care, recommend the deb.

Verification

A new scripts/verify-linux-association.sh that uses xdg-mime query default model/gltf-binary and asserts QtMeshEditor is listed in the alternatives (xdg-mime query default returns one app; gio mime model/gltf-binary lists alternatives — use both).

Acceptance Criteria

  • After apt install qtmesheditor*.deb, xdg-open model.fbx opens QtMeshEditor.
  • File managers (Nautilus, Dolphin, Nemo) list QtMeshEditor in "Open With…" for all supported formats.
  • Custom MIME types (.mesh, .rsd, .tmd, .material) get the right icon in file managers.
  • update-mime-database, update-desktop-database, gtk-update-icon-cache run cleanly on postinst with no errors.
  • Uninstall removes the .desktop and MIME registration cleanly (verified by verify-linux-association.sh post-uninstall).
  • Snap registration works on at least Ubuntu (where snap is well-supported); document any limitations for confined snaps.
  • CI's scan-assets-docker job (or a new verify-linux-association job) runs the verification script and fails the build if the registration is missing.

Effort

~5 days. Snap's MIME-registration quirks under confinement are the schedule risk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfile-assocOS file associations: be the default 3D model viewer on macOS/Win/Linux

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions