Playing with desktop files aka application launchers in Linux


Desktop files are text files, with .desktop extension, that launches applications. In this tutorial, I wish to explore different ways you can use desktop files to run range of applications.

Anatomy of a desktop file.

If you see the contents of files under /usr/share/applications, you might see something that looks like this.

[Desktop Entry]
Comment=Simple GTK2 color selector and picker


Some of the interesting variables from this file are

Name: Name of the application as it appears in your launcher, menu etc
GenericName: Generic Name of the application, E.g Web browser
Exec: Name of the application/script to be executed
Icon: Image file, that appears as icon
Terminal: Should this application show the terminal (could be helpful for applications that logs output in a terminal)
Type: Application, Link and Directory are three types
Categories: Under which section on menu, should it appear

You can use only names for Icon or Exec, if those files are located at standard path, otherwise you will have to use full path.

If you want to create desktop files locally, create a directory where you will store these files. Lets call it myapplications inside your home directory as ~/myapplications. To make this directory recognizable by application menus or launchers like gnome-do, synapse, unity-dash etc, you will also have to link it to ~/.local/share/applications. Run following command to do so.

$ ln -s ~/myapplications ~/.local/share/applications/

Lets see different examples, where we can use the desktop files.

Note: Be sure to make the files executable, after its creation, using “chmod +x filename“.

1. Games

Lets say, I want to create a desktop file for a game called FTL, that runs only if I run the FTL script on the game’s own installation directory i.e I cannot run /path/to/ftl/FTL and execute the game, if I am in some other directory in a terminal. I will create a desktop file that looks like this

[Desktop Entry]
Comment=Good Game


Only interesting thing about above file is the Path variable, that specifies, in which directory should the command execute.

After you create these files, you can collect them just by copying them where ever you like. Just click the icon and the application should launch. You could also drag it to different launcher bars (as you can see in figure below for elementary), execute it from standard application launcher menu etc.


2. Web pages

If I wanted an icon that launches G+, I would create a simple desktop file, that looks like this.

[Desktop Entry]
Comment=Google Plus
Exec=chromium-browser ''


In this case, I downloaded a 256×256 image of googleplus from internet, and kept it inside .icons directory (you can keep it anywhere you like).

If you wanted to open up a collection of web pages, using a desktop file, you could easily do so using a script, and point Exec to that script. E.g If I wanted to run, Exec could look this this.


And the script file ( would look like this

chromium-browser '' ''

3. Command line scripts

As an example let us assume you have dual graphics cards (Intel/AMD hybrid). To switch between the two, you would create a desktop file that looks like this.

[Desktop Entry]
Name=Switch AMD Intel 
Comment=Switch between AMD and Intel Graphics card

Here, Exec points to a perl script (you can use bash or other scripts too). Content of that script looks like this.

$checkGraphicsCommand = `aticonfig --pxl`;
chomp $checkGraphicsCommand;
if ($checkGraphicsCommand eq "PowerXpress: Integrated GPU is active (Power-Saving mode).") {
 # Activate the discrete GPU drivers 
 system "pkexec aticonfig --px-dgpu && pkill gnome-session"
} else {
 # Activate the integrated intel 3000HD drivers
 system "pkexec aticonfig --px-igpu && pkill gnome-session"

The good thing is, I don’t have to open up AMD catalyst control center, or fire up a terminal and follow series of steps just to switch the graphics cards. I could simply use my regular application launcher (e.g application menu, gnome-do etc) and execute the  script just as I would execute a GUI application.



As you can see, I mentioned a wide range of examples. Purpose of which is to encourage you to create your own launcher for applications you run. There are much more parameters and variables that can be used on a desktop file, which you can see if you explore files at /usr/share/applications. To cover even more use cases, see Desktop Entry Specification. The power of desktop files is limitless. E.g I could create launcher for all my nintento 64 roms (using mupen64plus). I could create desktop files to launch a script that mixes a series of commands and applications. I could create several versions of same application, depending upon different parameters.  The point is, there is nothing wrong with using the terminal to execute commands, but sometimes, it is less intimidating and more enjoyable to press a button and see stuffs happen.




Filed under Uncategorized

3 responses to “Playing with desktop files aka application launchers in Linux

  1. Hey, thanks. this is what i need.

    btw, i wanna ask something, could ubuntu using “active desktop” like wind*ws?
    if ubuntu could, and combine with application launcher, it will make my work more easy

    • Yes it works in Ubuntu too (actually desktop files are standard files for creating links to applications in most Linux desktops).

      As in the example (G+ from Web pages section), you could easily open any webpage using a desktop file. You just need to use a command, something like


      Here, I have used xdg-open instead of firefox or chromium-browser, because this command opens the web page in default web browser.

      I don’t know how Active Desktop works. May be, you want to drag and drop icons from browser to desktop (I don’t know any application or browser in Linux that works like that). If you use above example as a template, I don’t think it is that hard to create links to web pages you visit.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s