Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to ask some questions about .desktop files, and figure something out that I think would be rather nifty.

I will start by saying I am running [elementary OS Luna] with kernel [3.2.0-65-generic-pae].

I know a little about .desktop files, and what they do. I learned from someone over at the eOS IRC. One little thing always bugged me about making my own. When you open an application via its .desktop, it will light up that icon in ubuntu, I believe. In eOS, we get a little light indicator as well. It stays WITH the icon itself. When you make your own, it does not.

For example, I made a .desktop that attaches to a .sh that would open a .jar. When I click the icon, it does what I would like, and opens. The only thing I dislike is the fact that there is a whole new icon that pops up. It is the Oracle Java icon, and it is blurry, as well as an eye-sore. I was curious if there is a command I can put in my .desktop that will enable it to only light up the original icon, and such as other apps do.

Also, I was curious if there was a way to convert things like .png to the file format of .desktops icons.

Thank you in advanced.

share|improve this question
You can use .png files as the .desktop icon. Just write in the icon location as /home/user/Pictures/Logos/javaicon.png – Tim Jul 19 '14 at 8:41
Thank you, Tim. I will have to try that out. Do you have any clue as of the other thing? – Brendon Jul 19 '14 at 8:43
No I don't sorry... – Tim Jul 19 '14 at 8:51
It is perfectly fine, thank you for your help. – Brendon Jul 19 '14 at 9:07
As to the second part, have a look at – muru Jul 19 '14 at 9:12

First I suggest you watch log for your file:

Open Terminal
auditctl -a exit,always -w /path/to/file and press Enter.
sudo nano /var/log/audit/audit.log and press Enter to watch log.

Full reference: Desktop Entry Specification

Freedesktop example

[Desktop Entry]
Name=Foo Viewer
Comment=The best viewer for Foo objects available!
Exec=fooview %F

[Desktop Action Gallery]
Exec=fooview --gallery
Name=Browse Gallery

[Desktop Action Create]
Exec=fooview --create-new
Name=Create a new Foo!

Quote: Icon to be shown togheter with the action. If the name is an absolute path, the given file will be used. If the name is not an absolute path, the algorithm described in the Icon Theme Specification will be used to locate the icon. Implementations may choose to ignore it.


Good short tutorial by Joe Reimero: Anatomy of a .desktop File

Joe Reimero example

[Desktop Entry]
Name=My Application

By Joe that I agree also the path to the Icon can be absolute OR relative and it depends on what standard you have chosen to construct your symbolic link. Traditionally it is PNG.

Great tutorial especial for you: Turn your Java apps Gnome-Shell friendly

[Desktop Entry]
Name=IntelliJ IDEA Ultimate Edition
Comment=The Most Intelligent Java IDE
Exec=env IDEA_CLASSPATH\=../lib/asm.jar /home/diego/bin/ideaIU-10.5/bin/

Note for line:

Exec=env IDEA_CLASSPATH\=../lib/asm.jar /home/diego/bin/ideaIU-10.5/bin/

where you see CLASSPATH variable next to exec.

Any chance that it also can help how it say OS Luna:

.desktop files follow the Desktop Entry Specification. They should be installed in /usr/share/applications. Users may create their own launchers by putting .desktop files in ~/.local/share/applications.


share|improve this answer
So, if I am reading correctly, mind you it is 5 am where I live, I just have to add the desktop action crew? – Brendon Jul 19 '14 at 9:09
I'm very sorry. That probably sounded very idiotic. I am not entirely sure what you are doing that will keep the second icon from popping up. Further elaboration would be nice. – Brendon Jul 19 '14 at 9:12
I think for OS Luna need to say it can be a little bit specific configuration. Obviously you should to find reference at OS Luna help. It's very possible. – swift Jul 19 '14 at 9:20
found tutorial especial for you, editing answer – swift Jul 19 '14 at 9:30
Thank you for the assistance. – Brendon Jul 19 '14 at 9:32

A .desktop launcher file can likely just be (sort of) simplified down to something like the following

[Desktop Entry]
Name=Google Maps
Exec=google-chrome --app=,-1.3424413,11z
Comment=Open Google Maps
GenericName=Open Google Maps


  • You need both [Desktop Entry] and Type=Application to say it is a application launcher.
  • Name is its name
  • Exec is the command it runs
  • Comment/GenericName desribe it (not always needed)
  • Icon is the path to a icon or a icon from the theme(s) you are using in /usr/share/icons (not always needed, but the default icon if often annoying)
  • Categories - specifies the category it is in (useful for menus - not always needed)
  • Keywords are words that can be used to find it when you search for it (not always needed).
  • Hidden/NoDisplay set to false make sure it is displayed (not always needed).
  • Terminal whether to run in terminal or not`.

For changing the icon, you just need to change the Icon line to specify a different icon - e.g. to use a text editor icon from /usr/share/icons:


or you can specify a path to a icon file


This is also possible by right-clicking on the launcher in most file mangers and selecting properties: enter image description here

Then clicking on the icon and selecting a new one - note if it is in /usr/share/applications you probably need permissions to edit the file.


I can't exactly remember why (probably made it for something), but I appear to have the following script that can create .desktop launchers - here it is:

if [ "$1" = "--help" ]; then
   echo -e "\e[1mUsage:\e[0m\n  create-launcher [OPTIONS...] [FILENAME] - create a launcher\n\e[1mHelp Options:\e[0m\n  --help    Show help options\n\e[1mApplication Options:\e[0m\n  -n NAME       Sets the name of the New launcher\n  -c COMMAND    Sets the command the launcher will be used to Launch\n  -t COMMENT    Sets the comment used to describe the launcher\n  -i ICON       Specifies an icon filename or stock icon to display.\n\n\e[1mNote\e[0m - ideally all of the above options should be used, mainly the Name option as it used to create the name of the launcher, and the command option as that is required for the launcher to work."
while getopts n:c:t:i: option
    case "${option}"
        n) NAME=${OPTARG};;
        c) COMMAND=${OPTARG};;
        t) COMMENT=${OPTARG};;
        i) ICON=${OPTARG};;
FILE=$HOME/.local/share/applications/$(echo $NAME | sed 's/ /-/g').desktop
if [ $FILE = $NOFILE ]; then
   echo -e "ERROR: Please enter atleast the Name for the launcher - for more info run\n    create-launcher --help" 
   exit 1
echo "New launcher created at $FILE"
echo -e "[Desktop Entry]\nType=Application" > $FILE
echo Name=$NAME >> $FILE
echo Exec=$COMMAND >> $FILE
echo Comment=$COMMENT >> $FILE
echo Icon=$ICON >> $FILE
echo -e "Hidden=false\nNoDisplay=false\nTerminal=false\n#X-GNOME-Autostart-enabled=true" >> $FILE
chmod +x $FILE

This can be saved to a executable file, and creates a simple launcher like the following (except the fields are filled by specifying the scripts options - see ./create-launcher --help) in ~/.local/share/applications (which should mean the launcher shows in menus etc)

[Desktop Entry]

The last line is not important unless it is used elsewhere to start a program on login.

share|improve this answer
This is very interesting. You gave me a lot of information, and I will look into it. Thank you. – Brendon Jul 19 '14 at 17:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.