Adding Desktop Application Icons for Terminal-based Programs in GNOME Linux and Ubuntu
I just downloaded the Parity Ethereum node, and it’s an old fashioned terminal-based program. Here’s how to make a launcher for it so it’ll integrate with the GNOME desktop. It should also work with KDE, but I haven’t tried it.
For reference, read: Desktop files: putting your application in the desktop menus.
This is similar to How to Create a .desktop File for a Document in Linux.
These instructions should work with pretty much any Terminal-based program.
I downloaded the program and installed the package. It worked fine, but needed to fire up a Terminal to run it. I wanted to have an icon, and launch the application from the main search tool. (I think it’s called “Activities Overview” and you reach it by pressing the Window key.)
Applications get registered into the desktop environment via files that end in .desktop. These are just plain text files (and if you’re old enough to remember Windows 3.1, they are like PIF files).
.desktop files reside in ~/.local/share/applications/
Here’s parity.desktop. The red text is the customized part.
[Desktop Entry] Name=Parity Exec=xterm -e parity Icon=parity.png Type=Application Categories=Accessories;
I think it’s pretty self-explanatory, except for the details, and the Category entry. The Category line is for putting the icon into an hierarchical application menu. The current GNOME doesn’t have one, but older desktops do.
The Name line sets the name to display under the icon.
The Exec is the command to run. We don’t run parity directly, but run xterm (an old X terminal program that has a nice, small font), and tell xterm to run parity.
The Icon is the path to the icon. If there’s no path, it looks inside ~/.local/share/icons/ for the file.
The Application Icon
You need to find an icon from somewhere. I went to the parity.io website and used GIMP’s screenshotter to snag a small icon, and saved it.
Here are a couple screenshots of this .desktop file in action.
What’s also nice about .desktop files is that the Exec line can hold additional command line options. So you can do pretty much anything you want, before running the application. You could write a shell script to set up the environment, first, before executing the program.