How to Create an Integrated Application Launcher For an Appimage file in Ubuntu

In this tutorial, we will learn how to create a custom application launcher for an appimage in the Gnome Desktop Environment in Ubuntu. Although we are focusing on Ubuntu for this tutorial, this method should also work in other distributions that use the Gnome Desktop Environment and may also be useful reading for those using other Desktop Environments as some parts are still applicable.

In this tutorial you will learn:

  • What an appimage file is
  • How to download and run an appimage program
  • How to create an application launcher for an appimage program
 How to Create an Integrated Application Launcher For an Appimage file in Ubuntu

How to Create an Integrated Application Launcher For an Appimage file in Ubuntu

Software requirements and conventions used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 20.04.2
Software no specific software is required, but our examples use kiwix
Other Privileged access to your Linux system as root or via the sudo command is not required except in an optional step where we install an icon theme.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

What is an Appimage file?

An appimage file is a compressed image of an application and any libraries it uses. When you execute an appimage file, it is temporarily mounted on your file system in order to run. Traditionally, applications are installed by using the package manager. In the case of Ubuntu, that would be apt. This is a very convenient method of installation for the end user, but for developers it can be a lot of extra work to package their applications separately for each distribution’s package manager. Developers are able to package their application into an appimage file once and it will run on any distribution. As a result, you may find that some software is only available in the appimage format for your distribution.

When you download the appimage file, there is no installation and no root privileges necessary. Appimages make no changes to your system, and they are portable universal binaries that includes all dependencies and libraries within it. We previously covered Snaps and Flatpak which provide similar features. These features are often seen as benefits of appimages, but depending on how you prefer to launch applications, they may also be a drawback. Typically, when you install an application via the distribution’s package manager, it neatly integrates into the system and an application launcher is created for you.

On the other hand, when you download an application that is distributed as an appimage file, it is just another file on your computer. In order to open the application, you need to make this file executable and launch the application by specifying the path to it on the command line or double clicking the file in your file manager, which in the case of Ubuntu would be nautilus. If you want an application launcher, then you need to create it yourself.

Download the appimage

One of the benefits of the appimage format is that you can download the application directly from the developer’s website no matter what distribution you are using. For the purposes of this tutorial we will download the Kiwix appimage from the official Kiwix website. Kiwix is a free and open source application that lets you do download all of Wikipedia and read it offline. It has grown to allow downloading and offline reading from other sources as well, but those details are beyond the scope of this article.

On the official download page there are download links available for Linux, Windows, macOS, Android, iOS, and browser extensions. If you click the link for Linux, then you will be able to download the latest version as an appimage. To download and run this appimage on the command line all you need to do is enter the following commands to download the file, make it executable, and run it.

$ wget https://download.kiwix.org/release/kiwix-desktop/kiwix-desktop_x86_64.appimage
$ chmod +x kiwix-desktop_x86_64.appimage
$ ./kiwix-desktop_x86_64.appimage


Although an appimage can be downloaded to and ran from any directory, in order to keep the filesystem well organized, let’s move it to a more appropriate directory before we make an application launcher for it.

$ mkdir ~/bin && mv kiwix-desktop_x86_64.appimage ~/bin/

Creating an application launcher

One of the great features of Ubuntu 20.04 is that you can easily launch applications by clicking Show Applications in the dock panel and then clicking the application in the Applications Window. Alternatively, you can press the Superkey(often the windows key on pcs and left command key on macs), type the name of the application and then press enter to launch it. In order for an application to show up in this Applications Window, it must have a desktop entry in an appropriate directory. These desktop entries are files that specify how to launch the application and end in the .desktop file extension.

System wide applications have desktop entries located in /usr/share/applications. However, writing to this directory requires root privileges and since one of the benefits of appimages is that they don’t require root privileges, we will create a desktop entry in the ~/.local/share/applications directory. The ~/.local/share/applications directory is for desktop entries for the current user. Creating a .desktop file here will make the application launcher available to the current user.

With your favorite text editor, create a file called kiwix.desktop in ~/.local/share/applications.

$ vim ~/.local/share/applications/kiwix.desktop

Next, enter the following into the the file and save it.

[Desktop Entry]
Name=Kiwix
Comment=Read Wikipedia offline
Exec=/home/username/bin/kiwix-desktop_x86_64.appimage
Icon=kiwix
Terminal=false
Type=Application
Categories=Education;

The first line specifies that this is a desktop entry. The second line indicates the application name that you will see in the applications window. The third line consists of a comment that can be viewed as a tooltip. The fourth line specifies the path to the executable file. Here you should replace username with your actual username of course. The fifth line indicates the icon to use. You can either specify the path to a custom icon or use an icon that is part of an icon theme pack. The example above does the latter. In order for it to display an appropriate icon, you must be using an icon theme that includes an icon for this application.

On Ubuntu the “numix-icon-theme-circle” is an icon theme that includes a kiwix icon and be installed with $ sudo apt install numix-icon-theme-circle. The sixth line specifies whether this application runs in the terminal or not. The seventh line tells the system whether this is an Application, Link, or Directory. The final line specifies the category the application falls under for application menus that separate application launchers into different categories.

Now that you have created and saved the Desktop Entry, you should see the application in the Applications Window and should be able to launch it from there. You can optionally right click on the icon in the dock panel and click Add to Favorites if you would like this application launcher to remain in the dock at all times.

Alternative Method

Many appimages include their own .desktop file within the image. If you don’t want to create the file from scratch yourself, then you could locate the one that is included with your appimage, copy it, and edit its content as needed. Below we will look at an example of how to do this using the kiwix appimage.

First, go to the directory where you saved the appimage file and execute it as described in the Download the appimage section of this article. Now that you have executed the appimage it will be temporarily mounted on the file system. To find out where it is mounted issue the following command.

$ mount | grep .appimage


We get the following output which tells us that the expanded image is mounted in the /tmp/.mount_kiwix-HhmzJR diectory. The exact name of the temporary directory will differ each time the appimage is launched.

kiwix-desktop_x86_64.appimage on /tmp/.mount_kiwix-HHmzJR type fuse.kiwix-desktop_x86_64.appimage (ro,nosuid,nodev,relatime,user_id=1000,group_id=1000)

Now that we know where the decompressed appimage is mounted to we can see if any .desktop files are included in it with the following command.

$ find /tmp/.mount_kiwix-HHmzJR -iname "*.desktop"

We receive the following output.

/tmp/.mount_kiwix-HHmzJR/kiwix-desktop.desktop
/tmp/.mount_kiwix-HHmzJR/usr/share/applications/kiwix-desktop.desktop

As we can see there are two .desktop files provided within the appimage. We can copy either of these and edit it’s contents to suit our purposes.

$ cp /tmp/.mount_kiwix-HhmzJR/kiwix-desktop.desktop ~/.local/share/applications/

With your favorite text editor, edit the kiwix-desktop.desktop file in ~/.local/share/applications.

$ vim ~/.local/share/applications/kiwix.desktop

When opening the file to edit you will see the following contents.

[Desktop Entry]
Type=Application
Name=Kiwix
Comment=View offline content
Icon=kiwix-desktop
Exec=kiwix-desktop %F
Terminal=false
MimeType=application/org.kiwix.desktop.x-zim;
Keywords=zim;
Categories=Education;
X-AppImage-Version=2.0.5

Edit the Exec and Icon values so that the content looks like the following example.

[Desktop Entry]
Type=Application
Name=Kiwix
Comment=View offline content
Icon=kiwix
Exec=/home/username/bin/kiwix-desktop_x86_64.appimage
Terminal=false
MimeType=application/org.kiwix.desktop.x-zim;
Keywords=zim;
Categories=Education;
X-AppImage-Version=2.0.5

Conclusion

In this article we introduced appimages and briefly discussed their pros and cons. We then took a deep dive into how to create application launchers for appimages using two different methods. If you are using appimages as an end user, then creating application launchers for them can greatly enhance your user experience, especially on Ubuntu 20.04 which implements a polished user friendly version of the Gnome Desktop Environment.

After creating the application launcher, you can easily launch the appimage from the Application Window using the Show Applications feature of the dock or with the Superkey and can even pin the icon to the dock by adding it as a favorite. Appimages are extremely convenient, but their lack of system integration may sometimes be jarring for those who are accustomed to traditional package management on Linux. The next time you find yourself in need of software that is distributed as an appimage give one of these methods of creating an application launcher a try and let us know what you think of it in the comments below.