Thursday, September 26, 2019

Linking AppImages to a File Type

I installed CURA 4.3 on Ubuntu 16.04 and it only comes as an AppImage file.  I don't mind the concept of AppImage's  "single file contains everything needed to run the program" but I couldn't get it to associate with the .STL file format.   It wouldn't come up as one of the OPEN WITH options after right clicking on an .STL file.

To fix this you will need to open GEDIT or your favorite text editor (I use GEANY) then;

1. Create a new blank file.

2. Copy and paste the following into this new blank file.

[Desktop Entry]
Encoding=UTF-8
Name=Cura
Comment=Cura 3D slicing application.
Exec={INSERT PATH TO APPIMAGE} %F
Type=Application
Icon={INSERT PATH TO ICON}
Categories=Graphics; 
MimeType=image/CURA;

3.  Replace the {INSERT PATH TO APPIMAGE} with the path to your AppImage file and the name of your AppImage file.  The COMMENT and NAME should be replaced with info and description name of your AppImage file (the NAME is what will appear in your OPEN WITH list when you right click on a file in Nautilus.

The {INSERT PATH TO APPIMAGE} line looks like this in mine:
Exec=/home/jeff/AppImages/Ultimaker_Cura-4.3.0.AppImage %F

*** NOTE:  The official recommendation by the AppImage developers is to create an extra directory, ${HOME}/Applications/ (or ${HOME}/.local/bin/ or ${HOME}/bin/) and store all AppImages there.  But as you can see I did not follow this recommendation. You can put AppImages anywhere and they'll work, even USB drives.

4.  Replace the {INSERT PATH TO ICON} with the path to the icon image you want to associate with your AppImage program.

This line looks like this in mine:
Icon=/home/jeff/Pictures/Icons/Cura.png

*** NOTE:  I keep all my Icons in this folder to make them easy to find

5.  Save this file to your Downloads directory as a .desktop file, I called mine CURA.DESKTOP.  You can name yours whatever you want but the .desktop part must be there.

6. Now we make your new .desktop file executable by opening Nautilus (Files) and right clicking on your new .desktop file.  Now select the PERMISSION tab and check the "Allow executing file as Program" box.


7.  Now we need to copy your new .desktop file to the /usr/share/applications/ folder.  This has to be done in TERMINAL because of permissions.

    A.  Open a TERMINAL window.
    B.   Then type the following. (Assuming your .desktop file is in Downloads directory)

           cd Downloads

           sudo cp cura.desktop /usr/share/applications/

           * Hit ENTER KEY after each of these two commands and enter your password if asked.

           *** NOTE:  you will need to replace cura.desktop with name of your .desktop file you created in steps 1 - 6 .

         
       

8. After it copies just close the TERMINAL window.

9.  Now we need to edit the mimeapps.list that is locate in your HOME directory under the .config directory.

10.  Open Nautilus (Files) and select VIEW and check SHOW HIDDEN FILES



11.  Now navigate to home/YOURuserNAME/.config/ and open the file mimeapps.list with GEDIT or your favorite text editor.

Mine was located here;
home/jeff/.config/mimeapps.list

12.  Once mimeapps.list is open in your text editor add this line under the section [Added Associations]

image/cura=cura.desktop;

***Note:  Replace cura.desktop with the name of your .desktop file.

13.  Save mimapps.list and close your text editor.

14.  Last step; find an .stl file and right click on it and choose CURA as the default app under OPEN WITH.


I hope this  helps someone out. There might be an easier way but I don't know what it would be.

*** NOTE:  This should work with any file type you would wanted associated with a program.  Basically just replace Cura with your your program and .stl with your file type.  It would be nice if there was a little more integration between AppImages and your OS but I guess that is the point AppImages "one file, run anywhere".  To uninstall AppImages just delete that single AppImage file (and undo all this file association I just showed you :-)


No comments: