1

I have seen this, this, and this.

Everyone talks about how to search for the app and launch it from a shortcut (instead of running it as an executable).

However, nobody talks about associating an AppImage with a mime type.

My goal is to click on a .stl file and open it with a default program that only ships as AppImage for Ubuntu/Linux.

As mentioned in the linked posts, this program already appears in the search because I integrated it by adding a .desktop launcher.

Uri Herrera
  • 14,866
bem22
  • 113

1 Answers1

1

As you've mentioned that you've already looked at how to create a desktop launcher for your AppImage, I will skip that part.

You're looking to edit the .desktop launcher and change what mime types are associated with it.

FWIW, this is not specifically for AppImages; this is how freedesktop desktop launchers work

I don't know what program you're referring to, but I'll use the following launcher as an example.

The launcher below is for a text editor called Nota. We're interested in the line MimeType=; as you can see, it reads MimeType=text/plain; which means that Nota is associated with any text file.

[Desktop Action FirejailProfile]
Exec=firejail --env=DESKTOPINTEGRATION=appimaged --private --appimage /Applications/nota
Name=Run without sandbox profile
TryExec=firejail

[Desktop Entry] Categories=Qt;KDE;Utility;TextEditor; Comment[es_MX]=Text editor Comment=Text editor Exec=/home/uri/Applications/nota-v2.2.0-stable-amd64.AppImage GenericName[es_MX]=Text Editor GenericName=Text Editor Icon=nota Keywords=text;editor; MimeType=text/plain; Name[es_MX]=Nota Name=Nota Path= StartupNotify=true Terminal=false TerminalOptions= TryExec=/Applications/nota Type=Application X-DBUS-ServiceName= X-DBUS-StartupType= X-KDE-SubstituteUID=false X-KDE-Username=

You can do the following to know what to put in that line for the desktop launcher you've created.

file -b --mime-type file.stl

This command will tell you what the mime type is. For example, the output could be application/sla for your .stl files.

So, the line in your desktop launcher would read MimeType=application/sla; so the desktop launcher would be registered to launch whatever is in Exec= and open that mime type.


Alternatively, you probably want to extract the upstream desktop launcher inside the AppImage and edit it accordingly, as I described here.


Next, edit ~/.config/mimeapps.list, and append:

application/sla=YourApp.desktop;

Uri Herrera
  • 14,866