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
Thread closed.
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.Code:[Desktop Entry] Version=1.6 Name=ProgramName Comment=My comment is this Exec=/home/alex/Documents/exec.sh Icon=/home/alex/Pictures/icon.png Terminal=false Type=Application Categories=Utility;Application;
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.Code:[Desktop Entry] Version=2.3 Name=Wallch Comment=Change wallpapers automatically Exec=/usr/bin/wallch Icon=/usr/share/icons/wallch.png Terminal=false Type=Application Categories=Utility;Application;
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:
1->a
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:
and thenCode: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/Code: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.Code: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:Code:cd /usr/share/applications
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.Code: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:
The thing that has to do with shortcuts is everything after 'X-Ayatana-Desktop-Shortcuts=Play;Pause;Next;Previous;' including this.Code:[Desktop Entry] Version=1.0 Type=Application Name=Audacious GenericName=Music Player GenericName[be]=Музычны плэер GenericName[da]=Lydafspiller GenericName[de]=Musikspieler GenericName[es]=Reproductor de música GenericName[fr]=Lecteur de Musique GenericName[it]=Lettore di Musica GenericName[lt]=Muzikos grotuvas GenericName[nl]=Muziekspeler GenericName[nb]=Lydavspiller GenericName[pt]=Leitor de Música GenericName[ro]=Lector de Muzică GenericName[ru]=Аудиоплеер GenericName[se]=Ljudspelare Comment=Listen to music Comment[be]=Слухайце музыку Comment[de]=Musik hören Comment[fr]=Écouter de la musique Comment[hu]=Hallgasson zenét Comment[it]=Ascoltare musica Comment[lt]=Klausyti muzikos Comment[nb]=Lytt til musikk Comment[nl]=Muziek luisteren Comment[ru]=Слушайте музыку Comment[es]=Escucha música Icon=audacious Categories=AudioVideo;Audio;Player;GTK; Exec=audacious %U TryExec=audacious Terminal=false MimeType=application/ogg;application/x-cue;application/x-ogg;application/xspf+xml;audio/midi;audio/mp3;audio/mpeg;audio/mpegurl;audio/ogg;audio/prs.sid;audio/x-flac;audio/x-it;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-s3m;audio/x-scpls;audio/x-stm;audio/x-vorbis+ogg;audio/x-wav;audio/x-xm;x-content/audio-cdda; X-Ayatana-Desktop-Shortcuts=Play;Pause;Next;Previous; [Play Shortcut Group] Name=Play Exec=audacious -p TargetEnvironment=Unity [Pause Shortcut Group] Name=Pause Exec=audacious -t TargetEnvironment=Unity [Next Shortcut Group] Name=Next Exec=audacious -f TargetEnvironment=Unity [Previous Shortcut Group] Name=Previous Exec=audacious -r TargetEnvironment=Unity
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.






Wallch (Wallpaper Changer): 
Adv Reply

Bookmarks