Saturday, June 04, 2022

Adding AppImage Apps to a Files "File Association" List

Some AppImage programs don't create file association or don't add themselves as an "Open With" option (in the list when right clicked on).  Let's use XnView as an example;

1.  Created a file named xnview.desktop in your favorite text editor and add the following to it. When done just save it (I wanted a desktop shortcut too so I saved mine in my Desktop folder).  Replace USERNAME with your user name. I also store all my AppImages files in my Home directory in the folder AppImages and all my custom Icons are stored in my Pictures folder in a folder called Icons.  You may need to change the paths in the Exec= and Icon= sections to match your setup.

[Desktop Entry]
Encoding=UTF-8
Name=XnView
Comment=Image Viewer
Exec=/home/USERNAME/AppImages/XnView_MP.glibc2.18-x86_64.AppImage %F
Type=Application
Icon=/home/USERNAME/Pictures/Icons/XnView.png
Categories=Graphics;
MimeType=image/xnview;
Name[en_US]=XnView

2.  Once saved, the xnview.desktop file appeared on your desktop (if you saved it to your Desktop folder).  I right clicked on it's icon and selected the Allow Launching. If you saved your's elsewhere you will have to find it, right click on it, select Permissions and check the "Allow Executing File as a program" tick box.

3.  Opened a Terminal Window and navigated to your Desktop folder (or the location of where you saved your xnview.desktop file) by typing;
cd Desktop

4.  Now copy the xnview.desktop file to  /usr/share/applications directory.
sudo cp xnview.desktop /usr/share/applications/xnview.desktop

5. Now to edit your mimeapps.list file.  Type the following into your Terminal Window
gedit ~/.config/mimeapps.list

6.  Once Gedit opens your mimeapps.list files, we need to add the following line under the section [Added Associations];  
 image/jpeg=xnview.desktop; 

7.  Once done adding the single line, just save your mimeapps.list file and close Gedit.

That's it.  Now when you Right Click on a graphics file you will now find XnView as one of the apps you can use to open that file with.  You can also make it the Default App for opening that file type or just add it to the list of apps that can open that file type. The first time, you may have to pick the "Other Application" option to find XnView or your AppImage App.

I've done this on Ubuntu 20.04 and on 22.04.  Worked on both.