Results 1 to 4 of 4

Thread: Tutorial: Unity Launchers and Desktop files

  1. #1
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Ubuntu Development Release

    Arrow Tutorial: Unity Launchers and Desktop files

    The information in this thread have been moved to

    A thread for discussion of the wiki page only can be found here

    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:
    [Desktop Entry]
    Comment=My comment is this
    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.

    A realistic example is the following:
    [Desktop Entry]
    Comment=Change wallpapers automatically
    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.
    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
    and then
    gnome-desktop-item-edit ~/.local/share/applications/ --create-new
    where ~/.local/share/applications/ could be any other output path you want the launcher to appear, like ~/Desktop/
    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:
    gsettings get com.canonical.Unity.Launcher favorites
    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.
    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:
    cd /usr/share/applications
    and edit the launcher that is placed there (remember that you have its name in your clilpboard) using the command:
    gksudo gedit [paste here what you have in your clipboard with right click->paste or Ctrl+Shift+V]
    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.

    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:
    [Desktop Entry]
    GenericName=Music Player
    GenericName[be]=Музычны плэер
    GenericName[es]=Reproductor de música
    GenericName[fr]=Lecteur de Musique
    GenericName[it]=Lettore di Musica
    GenericName[lt]=Muzikos grotuvas
    GenericName[pt]=Leitor de Música
    GenericName[ro]=Lector de Muzică
    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
    Exec=audacious %U
    [Play Shortcut Group]
    Exec=audacious -p
    [Pause Shortcut Group]
    Exec=audacious -t
    [Next Shortcut Group]
    Exec=audacious -f
    [Previous Shortcut Group]
    Exec=audacious -r
    The thing that has to do with shortcuts is everything after 'X-Ayatana-Desktop-Shortcuts=Play;Pause;Next;Previous;' 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.
    Last edited by Elfy; June 29th, 2012 at 08:35 AM.

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  2. #2
    Join Date
    Jun 2007

    Re: Tutorial: Unity Launchers and Desktop files

    A few comments on, mainly concerning custom .desktops

    If there is any use possible or desired for DnD on the launcher than a MimeType= line needs to be present with appropriate types listed.

    The Categories= will & can be used to affect where the launcher will appear in the Dash apps menu > Filter results

    When a custom .desktop is created & desired to show on the right click context menu the Exec= line needs to end with a %<letter>, typically %U, %f or %F

    Regarding quicklists - starting in 12.04 it has been moved to Desktop Actions though 12.04 will still allow "X-Ayatana-Desktop-Shortcuts"
    The new way would be to use instead - using the audacious as EX.


    [Desktop Action Play]
    Exec=audacious -p


    The order that quicklists are displayed in the launcher is solely determined by the order listed in the X-Ayatana-Desktop-Shortcuts= or Actions= line. This line also determines what quicklists are shown, you can remove a quicklist option by removing it's entry in that line, the section can remain in case you want to add back at some point

    Of minor interest thru 12.04.
    Some apps may be better without the global menu, this can be changed thru it's .desktop for most uses (doesn't affect when starting from rhe terminal

    For most apps this will do, added to the Exec= line, not used in quicklists unless the quicklist is launching a new instance. Ex. again of audacious

    Exec=env UBUNTU_MENUPROXY=0 audacious %U
    For qt4 apps a different env, example vlc
    Exec=env QT_X11_NO_NATIVE_MENUBAR=1 vlc %U

  3. #3
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Ubuntu Development Release

    Re: Tutorial: Unity Launchers and Desktop files

    Thanks for the additions! Interesting facts

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  4. #4
    Join Date
    May 2007
    The New Forest
    Xubuntu Development Release

    Re: Tutorial: Unity Launchers and Desktop files

    This thread is closed.

    The information is now held on the community wiki at

    Thank you for your thread and the work you have done in keeping it current and of use to the community.

    A thread for discussion of the wiki can be found at

    Support threads regarding the wiki and it's content should be created in a suitable forum.
    Forum Social IRC Channel
    Xubuntu IRC Support
    Xubuntu Support

    Please do not PM me about Registration issues without having been asked to. I will tell you to post here


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts