This simple tutorial shows how to manually add your apps or scripts into start menu (aka main menu, applications menu, or GNOME ‘Show Apps’ menu) in Linux, so you can search for and launch them just like apps installed from Software or App Center.
There are many popular applications available for Linux (e.g., Firefox, Blender, Thunderbird) through portable tarball or AppImage. No need to install, just run the executable file (after adding permission) will launch this kind of applications.
These apps however are not well integrated. They by default do NOT show in system app launcher. To make them like the apps installed from system repository, user have to create .desktop
shortcut files for them. And, here’s how to do the trick step by step.
NOTE 1: This tutorial uses waterfox as example. NOTE 2: It should work in most Linux, includes Ubuntu, Debian, Fedora, etc.
Step 1: Get Executable & Icon file PATH
Before start creating the shortcut file for your apps or scripts, you need to first find out the PATH to the executable file and icons file.
In my case, I’m going to make ‘waterfox’ visible in start menu. So, browse into the app folder (extracted from downloaded tarball). Copy the PATH + executable filename.
For GNOME Nautilus file browser, press Ctrl+L to easily copy the folder PATH
As the screenshot shows, the executable file path for launching the app is: /home/merilyn/App/waterfox/waterfox in my case.
Also, browse to find out the icon file. Or, create/download one from the web if your app don’t even have a logo icon.
In my case, I’m going to use the icon file: /home/merilyn/App/waterfox/browser/chrome/icons/default/default128.png
Step 2: Create .desktop shortcut file
Now, launch your favorite text editor and write following lines:
[Desktop Entry] Type=Application Name=Text to display beside app icon Comment=Text to display as tooltip Exec=/home/merilyn/App/waterfox/waterfox Icon=/home/merilyn/App/waterfox/browser/chrome/icons/default/default128.png Terminal=false
Here, you need to do:
- change “Name” value for the text display along with app icon in menu.
- change “Exec” value according Step 1.
- and change “Icon” value according Step 1.
- if the app needs to start in terminal, set ‘
Terminal=true
‘
The previous lines are usually OK for basic use. For choice, you can add more (see the document for more):
- Categories= to group the icon in start menu. Values include: Audio, Video, Development, Education, Game, Graphics, Network, Office, Science, System, Utility, and more.
- MimeType= to launch from files’ right-click ‘Open With’ dialog. Right-click a file, and go ‘Properties’ to check its “Type”.
- Actions=custom-value1;custom-value2; …; Add right-click options for the app shortcut, if the executable supports command line options. You need to then add corresponding [Desktop Action custom-value1], [Desktop Action custom-value2], … with ‘Name’ and ‘Exec’ for each action.
Finally, save the file as “whatever_name.desktop” (without quotes) in your user folder.
Step 3: Validate the .desktop shortcut file
Before applying the .desktop
shortcut file, validate it in case there’s mis-configuration or typos.
To do so, first open the folder that contains the file you just created. Then, right-click on blank area in that folder and select “Open in Terminal“.
In pop-up terminal, valicate the .desktop file by running command:
desktop-file-validate file_name.desktop
Re-edit the .desktop file, until the command above pass without any error.
Step 4: Apply the .desktop shortcut file
Finally, in that terminal window (right-click on folder that contains the .desktop file and select “Open in Terminal”) run command to apply the .desktop file by installing to:
- either
/usr/share/applications
- or
.local/share/applications
To make the shortcut icon visible for all users in system, use command (recommend to move app source folder to /opt
):
sudo desktop-file-install file_name_here.desktop
For current user only, run this one instead:
desktop-file-install file_name_here.desktop --dir=$HOME/.local/share/applications
Finally, run command to refresh database (optional in my case) and done.
sudo update-desktop-database
See the result in my case via screenshot:
Undo
Depends on where you installed the .desktop
shortcut file. Just delete it will remove the app icon from start menu.
To do so, open terminal and run command for system wide:
sudo rm /usr/share/applications/file_name_here.desktop
Or use this command for the local installation:
rm $HOME/.local/share/applications/file_name_here.desktop