The information in this thread have been moved to https://help.ubuntu.com/community/Un...ndDesktopFiles
A thread for discussion of the wiki page only can be found here http://ubuntuforums.org/showthread.php?t=2012385
Since the last 3 posts I've helped are mainly about this issue, I see that many users have a problem of making their own launcher, place it to unity, edit a launcher of unity etc.
This tutorial will show all the basics you need to know on how to have your unity launcher as you want and how to create desktop files for this or other purpose.
1. How to create a .desktop file
.desktop files are files for launching links or applications (here I cover applications).
To create one, you can use gedit to manually create a desktop file or install a program for it. Both ways are easy but with the former you have more control on launcher's behavior
a) Use gedit
Open gedit and paste in:
Edit all the fields except 'Type' and 'Terminal' probably, so as to much your needs. 'Categories' field should be OK to be left as is, if you are working on a script or something similar.
Comment=My comment is this
A realistic example is the following:
You can now do right click on your file->Properties->Permissions->Allow executing file as program and use your launcher with double click! This action will change the .desktop's file look.
Comment=Change wallpapers automatically
Specifically, it will hide the .desktop extension, it will rename it to what the field 'Name' inside the .desktop file has, and, finally, it will show the icon!
Launcher without execution permissions:
Launcher with execution permissions:
Please note that in reality the filename is still the same, just the system chooses to show it like this because it's nicer.
b) Use gnome-desktop-item-edit
This way is simpler.
Run the following command:
sudo apt-get install --no-install-recommends gnome-panel
where ~/.local/share/applications/ could be any other output path you want the launcher to appear, like ~/Desktop/
gnome-desktop-item-edit ~/.local/share/applications/ --create-new
After you run this command, a window will appear which will let you choose the launcher's options. Also, note that by clicking on the icon on the top left of the window which opened you can choose an icon for your launcher.
After pressing OK, the launcher will be placed where you specified throough the command line (the 1st argument after the command gnome-desktop-item-edit)
2. Have your .desktop file appear in Unity launcher
In order to add your launcher to the Unity bar on the left, you have to place your launcher at /usr/share/applications/ or at ~/.local/share/applications/ (the former needs root permission while the latter no, but the former has not problems at all while the latter has showed some problems at me, like it doesn't show the program's name or similar).
After moving your file there, search for it in Dash (Windows key -> type the name of the application) and drag en drop it to the unity bar. Now your launcher is on the unity bar!
3. How to edit a launcher of the Unity bar
a) Edit its main characteristics
First of all, you need to know the exact name of the launcher, not the name of the program it launches. For this purpose, open a terminal (Ctrl+Alt+T) and give this command:
It will show you a list of the names of all the launchers you have in your unity launcher, starting from the top of the unity launcher and going to the bottom o f it.
gsettings get com.canonical.Unity.Launcher favorites
Now, you can detect the name of the launcher you want to edit. Copy it to clipboard (select it->right click->copy) for later use.
In a terminal head to /usr/share/applications:
and edit the launcher that is placed there (remember that you have its name in your clilpboard) using the command:
It will ask you for password. Type in your login password and gedit will open with the launcher file you wish to edit. To edit the launcher go to 1->a of this tutorial on the top, where it says it clearly on how to create a launcher and the same applies on editing it.
gksudo gedit [paste here what you have in your clipboard with right click->paste or Ctrl+Shift+V]
b) Add shortcuts to a launcher
After adding the main characteristics of a launcher, such as filling its 'Name' and 'Exec' fields, then you can add one or more shortcuts like these:
An example of adding these shortcuts is the best way to learn how to do it, as it's very simple.
This is a working .desktop file for Audacious, an awesome music player which provides its launcher with the shortcuts 'Play', 'Pause', 'Next' and 'Previous' and they do the corresponding action:
GenericName[es]=Reproductor de música
GenericName[fr]=Lecteur de Musique
GenericName[it]=Lettore di Musica
GenericName[pt]=Leitor de Música
GenericName[ro]=Lector de Muzică
Comment=Listen to music
Comment[fr]=Écouter de la musique
Comment[nb]=Lytt til musikk
[Play Shortcut Group]
[Pause Shortcut Group]
[Next Shortcut Group]
[Previous Shortcut Group]
The thing that has to do with shortcuts is everything after
' including this.
Through the manpage of audacious I very easily found how to go to the Next/Previous song and Pause/Play it, so it was very easy to add some shortcuts.
Please note that an application can have 'live' shortcuts that change during the program's execution, but that's another story, not directly linked to the contents of the .desktop file of the application!
That's all, if you have any comments or additions please add them.