Utilize Blender 2.8 to instantly open all kinds of 3D model files by double clicking them from Cinnamon / Nemo or similar. Bash, Python and some configuration for Linux Mint 19.3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Victor Giers 1e3749f79a „README.md“ ändern 4 years ago
blender-icons initial commit 4 years ago
Blender Launcher.desktop initial commit 4 years ago
README.md „README.md“ ändern 4 years ago
blender-launcher.sh initial commit 4 years ago
blender_2.8_import_3dobjects.py initial commit 4 years ago

README.md

Double-click any 3D file to open it in Blender 2.8

You can run blender-launcher.sh like you can run the blender binary.
I’m using /home/giers/.local/bin/blender-launcher.sh %f as launcher command for Blender 2.81a in Linux Mint 19.3. Note that ~ won’t work in a .desktop file. Put the .desktop file in ~/.local/share/applications if it didn’t go there automatically after creating it.
Put blender-launcher.sh and blender_2.8_import_3dobjects.py in ~/.local/bin. Blender is expected to be in ~/.local/share/blender, you can change that path in the .sh.

How to set MIME-Types and respective icons in Linux Mint 19.3

Probably also works in other versions of Mint and maybe in Ubuntu as well.

In order to run Blender with the launcher when double clicking on a 3D-model file and for them to have Blenders icon, do the following:

Create a new mime-type in /etc/mime.types file. I called mine model/model which counts for all kinds of 3d models. Create a .xml file in /usr/share/mime/* (one respective folder with arbitrary name) - with arbitrary name. I made mine be /usr/share/mime/model/3d-models.xml and for safety measures put a copy in /usr/share/mime/packages/overrides.xml because I saw that on StackOverflow .. ! One of them should be enough though. This is the content:

<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="model/model">
    <comment>3D model or scene</comment>
    <comment xml:lang="de">3D Model oder Szene</comment>
    <generic-icon name="model-model"/>
    <glob pattern="*.dae"/>
    <glob pattern="*.stl"/>
    <glob pattern="*.obj"/>
    <glob pattern="*.fbx"/>
    <glob pattern="*.ply"/>
    <glob pattern="*.gltf"/>
    <glob pattern="*.glb"/>
    <glob pattern="*.mdl"/>
    <glob pattern="*.3ds"/>
    <glob pattern="*.abc"/>
    <glob pattern="*.x3d"/>
    <glob pattern="*.wrl"/>
    <glob pattern="*.bvh"/>
  </mime-type>
</mime-info>

Run

sudo grep -R "\.dae" *

in /usr/share/mime for each filetype (not only dae) to see if one of the file types is associated with another mime type already. If so, delete these entries from all the files that do not say that they’re automatically generated in their first lines. I found intervening entries in the files in the model folder and in the following files: freedesktop.org.xml types and subclasses - so I removed them. Now renew and overwrite the automatically generate files with the new mime-info file by running

sudo update-mime-database /usr/share/mime/

Reload Cinnamon with Alt+F2 and running the command r and pressing F5 in the folder containing example files. Check if your files mimetypes have been updated by either looking at their properties (“Type” is shown right underneath the “Name” in Nemo). Running file -i <filename> didn’t give me the actual updated results right away, strangely. If the new mimetypes have been set successfully it’s now time to change the files icons. Put the icon .pngs with their respective sizes in /usr/share/icons/Mint-Y-Dark/* (or your respective themes relative folders) If your file types mimetype is model/model, they have to be called model-model (replace / with -). Run the following command to update the icon cache.

sudo update-icon-caches /usr/share/icons/*

If the icons don’t show up make sure you’re not checking on empty files and reload Cinnamon by pressing Alt+F2 and running the command r and press F5, just like when refreshing the mimetypes.