The easiest way to launch applications on Linux is frequently to just type the name of the application. It's fast, efficient, and immediate. However, it is often seen as unglamourous and overly technical, so many users want icons that they can point to and click on, imagining that that icon is really the application that they have just launched. The fact of the matter is that on no operating system is that the way applications are actually defined, but nevertheless people seem to enjoy the idea.
And even if you hold no illusion about where applications live, or how many files it actually takes to keep an application running, it can be handy to have quick-launchers for those applications that you use all the time.
Linux makes it easy to create launchers for applications and have them disguise themselves as “application files”; icons that you can click to launch an application. Just like on any other OS, that icon does not actually contain the entire application, but unlike other operating systems, the launchers on Linux contain none of the application. It's just a pointer to an executable.
This makes for great flexibility. For example, if you have a standard set of applications that you always launch together (a web browser and an email client, or JACK and a DAW and a favoured stand-alone synth, or two graphic applications, and so on), then you can create a script that launches them, and then create a launcher with a clever icon which triggers the script; just like that, you have implemented one- (or two, depending on your configuration) click launchers.
These launchers are usually called “dot-desktop” files, because any file that ends with a
.desktop and is made executable automatically gets interpreted by a Linux desktop as a launcher.
The absolute, most basic method of creating a launcher is not to create a launcher at all, but use K Menu to register an application with the KDE desktop. This is not portable (meaning that if you stop using the KDE desktop and opt for the XFCE desktop, the launcher will not show up in the XFCE menu), but it's easy and quick.
To create an entry in the K Menu, right-click on the K Menu icon and select Edit Menu.
In the menu editor that appears, click the New Entry icon in the top toolbar. Fill in the fields, including a name of the application, some relevant comment, an icon from either a file on your hard drive or from the themes installed on your computer, and, most importantly, the path to the binary that you want to be executed.
Save your changes and close the editor.
Your entry is added to the KDE desktop's internal database of applications, so your launcher isn't just available from the K Menu, but also from Krunner (
F2 by default, although many people re-map it to
space for convenience) and other KDE infrastructure. The launcher can be dragged out of the menu and added to panels or even to the desktop (if you run in desktop mode).
Simple Launcher File
You might prefer to create an actual
.desktop file, either because you want to ensure that your launcher is available from all incarnations of your OS, or because want to create the file once, and then re-use it for years to come.
The dot-desktop specification is defined by the Free Desktop group, a specifications group that governs conventions that cross all (or nearly all) Linux desktop environments and tools. Open your favourite text editor (such as Kate or Emacs) and enter this text:
[Desktop Entry] Version=1.0 Type=Application Name=Foo Viewer Comment=View Foo Files TryExec=xeyes Exec=xeyes %F Icon=xeyes MimeType=image/x-foo;
Save the file as
foo.desktop. In your file manager, the file looks the same as any other file, or at least, so far.
Right-click on the document and select Properties. In the Permissions tab of the Properties window that appears, place a tick mark next to is executable.
Now the document takes new form; its icon changes to the system standard xeyes icon, and if you click (or double-click, depending on your configuration) on it, it attempts to launch
%F in the example represents a file; not actually useful with Xeyes, but if this were an application that could open documents, it would make it so that the application would launch and open whatever document you drag-and-drop onto it).
Were you (with
su) to copy
/usr/share/applications, the entry would show up in your K Menu, and once the menu database got updated, also in Krunner.
This example has been mostly useless because it uses a fake application name along with a useless application, but the principle works with any application that you install. It's especially good for experimental or off-the-wall applications that are delivered to users with nothing but a command. You can launch it from the terminal, but with
.desktop files, you can customise the install and make it all the more integrated with your system.
With a little extra effort, you can think outside the box and use launchers for more than just adding an application to your application menu. For instance,
.desktop files make great shortcuts for users who need to run complex commands but do not want to bother to execute a command from a terminal, or they can be used as one-touch triggers for scripts that you use often.
For example, if you find yourself launching JACK, Patchage, a sequencer, and a stand-alone synth frequently, then you could feasibly create a launcher called
AudioRig and use it as a one-click launcher.
- First, create a simple script that performs the actions that you want your launcher to do. For instance:
#!/bin/bash jackd --realtime -d alsa \ --midi seq --playback hw:0 & seq24& patchage& yoshimi -j&
- Mark the script executable and place it in your
$ chmod +x audlaunch.sh $ mv audlaunch.sh ~/bin
- Test the script to make sure it does what you think it's going to do.
- Assuming your script launches everything as expected. you can create a launcher for it in the form of a
[Desktop Entry] Version=1.0 Type=Application Name=AudioRig Comment=AudioRig Exec=/home/klaatu/bin/audlaunch.sh Icon=/path/to/fancy/icon MimeType=application/x-sh;
- Mark the
.desktopfile executable and add it to
/usr/share/applicationsor just place it out on your desktop or in your file manager.
This same trick can be used to help make your projects, organised with Planter, easily launched. Add the full commands used to launch individual components in your project to a simple launcher script, and then create a
.desktop file to call the launcher script. Store both at the root level of your project directory, and your project becomes a nearly self-contained launchable archive of your work.