How can I edit/create new launcher items in Unity by hand?

506,277

Solution 1

For 11.04 and earlier:

Unity does support custom launchers from .desktop files. To create custom launcher from a .desktop file you need to create a *.desktop file for your program.

gedit ~/.local/share/applications/name.desktop

The .desktop file should look something like this:

[Desktop Entry]
Name=the name you want shown
Comment=
Exec=command to run
Icon=icon name
Terminal=false
Type=Application
StartupNotify=true

In your file manager open your home folder and navigate to: (You may need to press ctrl+h to show hidden files to see the .gconf directory.)

.gconf-> desktop-> unity-> launcher -> favourites

you'll see a bunch of folders starting with "app-". you need to create a folder for your program. Use the same name.desktop you used in /usr/share/applications. Go into 1 of the folders for something that is already on the dock & copy the xml file and paste that into your new folder. Open it with your text editor and change the name of the *.desktop to your name.desktop.

Open gconf-editor (you can open gconf by running the command gconf-editor in the Terminal) & go to:

desktop-> unity-> launcher -> favorites

Double click the list on the right & add your name.desktop.

Log out & back in and you should see your launcher. (thank you kerry_s on the Ubuntu Forums for helping with this answer)

Unity also has a feature called Lenses. By default, you have two in Unity: Applications and Files. In the future, you will be able to install and create a lot more. There is some info about that on the Ubuntu wiki: https://wiki.ubuntu.com/Unity/Lenses

Solution 2

Updated: 2015-Dec

For Ubuntu 15.10 or 14.04 LTS (11.10 or later, with Unity (3D))

NOTE: This can replace the function of an existing icon, or (once created) can be searched for (from Dash icon) to add to current button-bar.

First make your OWN copy of any of the .desktop files you want to modify. It is MUCH safer, and then you can always delete and start over.

(list all files)

ls /usr/share/applications/*.desktop

Example: Mozilla Firefox, firefox.desktop

(do this once, or after deleting any failed attempt)

cp /usr/share/applications/firefox.desktop ~/.local/share/applications

Then carefully change any wording, or add additional options.

(edit the file)

gedit ~/.local/share/applications/firefox.desktop &

Note: The ampersand '&' releases the command line immediately.


My own 'firefox.desktop' file:

Mozilla Firefox

[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Name[es]=Navegador web Firefox
Name[fr]=Navigateur Web Firefox
Name[it]=Firefox Browser Web
Name[nl]=Firefox webbrowser
Comment=Browse the World Wide Web
Comment[de]=Im Internet surfen
Comment[es]=Navegue por la web
Comment[fr]=Naviguer sur le Web
Comment[it]=Esplora il web
Comment[nl]=Verken het internet
GenericName=Web Browser
GenericName[es]=Navegador web
GenericName[fr]=Navigateur Web
GenericName[it]=Browser web
GenericName[nl]=Webbrowser
Keywords=Internet;WWW;Browser;Web;Explorer
Keywords[de]=Internet;WWW;Browser;Web;Explorer;Webseite;Site;surfen;online;browsen
Keywords[es]=Explorador;Internet;WWW
Keywords[fr]=Internet;WWW;Browser;Web;Explorer;Fureteur;Surfer;Navigateur
Keywords[it]=Internet;WWW;Browser;Web;Navigatore
Keywords[nl]=Internet;WWW;Browser;Web;Explorer;Verkenner;Website;Surfen;Online 
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
Actions=NewWindow;NewPrivateWindow;NewSafeMode;ProfileManager;

[Desktop Action NewWindow]
Name=Open a New Window
Name[de]=Ein neues Fenster öffnen
Name[es]=Abrir una ventana nueva
Name[fr]=Ouvrir une nouvelle fenêtre
Name[it]=Apri una nuova finestra
Name[nl]=Nieuw venster openen
Exec=firefox -new-window
OnlyShowIn=Unity;

[Desktop Action NewPrivateWindow]
Name=Open a New Private Window
Name[de]=Ein neues privates Fenster öffnen
Name[es]=Abrir una ventana privada nueva
Name[fr]=Ouvrir une nouvelle fenêtre de navigation privée
Name[it]=Apri una nuova finestra anonima
Exec=firefox --private-window
OnlyShowIn=Unity;

[Desktop Action NewSafeMode]
Name=Open in Safe Mode
Exec=firefox --safe-mode
OnlyShowIn=Unity;

[Desktop Action ProfileManager]
Name=Open Profile Manager
Exec=firefox --ProfileManager
OnlyShowIn=Unity;

My own 'libreoffice-startcenter.desktop' file:

LibreOffice

[Desktop Entry]
Version=1.0
Terminal=false
Icon=libreoffice-main
Type=Application
Categories=Office;
Exec=libreoffice %U
# MimeType=application/vnd.openofficeorg.extension;
MimeType=application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-template;application/vnd.oasis.opendocument.text-web;application/vnd.oasis.opendocument.text-master;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.template;application/vnd.sun.xml.writer.global;application/vnd.stardivision.writer;application/msword;application/vnd.ms-word;application/x-doc;application/rtf;text/rtf;application/vnd.wordperfect;application/wordperfect;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-word.document.macroenabled.12;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/vnd.ms-word.template.macroenabled.12;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/vnd.stardivision.calc;application/vnd.stardivision.chart;application/msexcel;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.binary.macroenabled.12;text/csv;application/x-dbf;application/vnd.oasis.opendocument.graphics;application/vnd.oasis.opendocument.graphics-template;application/vnd.sun.xml.draw;application/vnd.sun.xml.draw.template;application/vnd.stardivision.draw;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocument.presentation-template;application/vnd.sun.xml.impress;application/vnd.sun.xml.impress.template;application/vnd.stardivision.impress;application/mspowerpoint;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.ms-powerpoint.presentation.macroenabled.12;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.oasis.opendocument.formula;application/vnd.sun.xml.math;application/vnd.stardivision.math;

Name=LibreOffice 
Name[pt_BR]=BrOffice 
GenericName=Office 
GenericName[de]=Büroanwendungen
GenericName[en]=Office
GenericName[es]=Oficina
GenericName[fr]=Bureautique
GenericName[it]=Office
Comment=The office productivity suite compatible to the open and standardized ODF document format. Supported by The Document Foundation.
Comment[de]=Die zum offenen und standardisierten ODF-Format kompatible Sammlung von Büroanwendungen. Unterstützt durch »The Document Foundation«.
Comment[en]=The office productivity suite compatible to the open and standardized ODF document format. Supported by The Document Foundation.
Comment[es]=Suite de productividad para la oficina compatible con ODF, el formato de documentos abierto y estandarizado. Con el soporte de la Document Foundation.
Comment[fr]=Suite bureautique compatible avec le format de document standard et ouvert ODF. Soutenue par The Document Foundation.
Comment[it]=La suite di produttività compatibile con il formato standard e aperto dei documenti ODF. Supportata dalla The Document Foundation.

X-Ayatana-Desktop-Shortcuts=Writer;Calc;Draw;Impress;Math;

[Writer Shortcut Group]
Name=Writer
Exec=libreoffice --writer %U
TargetEnvironment=Unity

[Calc Shortcut Group]
Name=Calc
Exec=libreoffice -calc %U
TargetEnvironment=Unity

[Draw Shortcut Group]
Name=Draw
Exec=libreoffice -draw %U
TargetEnvironment=Unity

[Impress Shortcut Group]
Name=Impress
Exec=libreoffice -impress %U
TargetEnvironment=Unity

[Math Shortcut Group]
Name=Math
Exec=libreoffice -math %U
TargetEnvironment=Unity

A multi-tool icon 'toolbox.desktop' file:

[Desktop Entry]
Name=Ubuntu Toolbox
Comment=System Settings
Exec=unity-control-center --overview
Icon=redhat-tools
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;System;
OnlyShowIn=Unity;
Keywords=Preferences;Settings;
X-Ubuntu-Gettext-Domain=unity-control-center

X-Ayatana-Desktop-Shortcuts=GnomeTerminal;SoftwareCenter;SoftwareUpdates;

[GnomeTerminal Shortcut Group]
Name=Gnome Terminal
Exec=gnome-terminal
TargetEnvironment=Unity

[SoftwareCenter Shortcut Group]
Name=Ubuntu Software Center
Exec=software-center
TargetEnvironment=Unity

[SoftwareUpdates Shortcut Group]
Name=Update Manager  
Exec=update-manager -c  
TargetEnvironment=Unity

Here are some of my earlier efforts.

Files

Mozilla Thunderbird

Solution 3

For 11.10 and newer:

You can still create the Launcher on the Desktop by using the old GUI dialog.

Using ALT+F2 type:

gnome-desktop-item-edit --create-new ~/Desktop (Capital D)

This will start the dialog( Create launcher):

enter image description here

You can put this .desktop file in any folder, and then drag and drop to the launcher.

Note: The package gnome-desktop-item-edit must be installed first, so if you have gnome-panel installed, then it is installed automatically.

Solution 4

For 11.04 and earlier:

This is a method without editing config files and without root privileges.

First create the Launcher on the Desktop (only temporary)

  • right click your desktop
  • select Create Launcher...
  • create the custom Launcher as you want to.

Making a Launcher

Now you got the launcher on the Desktop. If you are satisfied with it, get it in the Launcher Panel:

  • Open your Home Folder. Press Ctrl + H to show hidden files if necessary.

  • Browse to .local/share/applications

  • Drag and drop your Launcher from Desktop to that folder.

  • Now drag and drop your launcher from .local/share/applications to the Launcher Bar on the left on your Screen.

  • You can now delete your custom Launcher on the Desktop if it's still there.

That's it.

Solution 5

I see many complex answers here. This solution is, I think, simple.

  • (First install the package alacarte, if you don't have it. This is the menu editor that was installed by default before 11.10. Obviously you only have to do this once.)
  • Start "Main Menu" by searching for it in the dash.
  • Add an item for your application and close the editor.
  • Start the application by searching for it in the dash.
  • Right-click on the icon and "Keep in launcher"

In Oneiric, you may also need to install the package gnome-panel, which alacarte should, but does not, depend on. See:

https://bugs.launchpad.net/ubuntu/+source/alacarte/+bug/826049

Share:
506,277

Related videos on Youtube

Ike
Author by

Ike

Updated on September 17, 2022

Comments

  • Ike
    Ike over 1 year

    Will Unity allow making custom launcher icons from .desktop files or via menu editing system? (Right now the launcher doesn't give the option to "keep in launcher" on all programs.

    For some programs I use, I have to make custom launchers or .desktop files.

    For instance, daily blender builds are generally just folders with an executable.

    In basic Gnome or KDE, I can make a new menu entry with the menu editing system. Then, I can also add it to Docky either from the menu or by dragging a .desktop file to it. Unity launcher doesn't support drag and drop, so thats not a bug or anything, but when I open a .desktop file, it has unpredictable results. Most time it will not have "keep in launcher". Sometime it will have a pinnable item without the .desktop's icon, and if I pin the item to the launcher, it will not call upon the program again after closing it. I've also gotten it to just work with a .desktop file for celtx.

    • Anatoly Mironov
      Anatoly Mironov almost 13 years
      If your Ubuntu has non-English locale, the custom icon may not work in the Unity Dash (but it works perfectly on the Desktop). Before drag-n-drop to the Unity Dash, edit your desktop file (e.g. with gedit) and remove the row with localized icon, in my case Icon[sv_SE]=gnome-panel-launcher and leave the other "Icon=" row.
    • Dan Dascalescu
      Dan Dascalescu almost 9 years
      It's ridiculous how difficult it is to create a shortcut to an app. If Windows can make is so easy, why can't Ubuntu?
    • 魔大农
      魔大农 over 8 years
      Have a look at Xubuntu: Xfce has very elegant support for this through the menu editor. Launchers can subsequently be added to the desktop through a context menu.
  • Jorge Castro
    Jorge Castro about 13 years
    You can just copy it to ~/.local/share/applications so you don't need to mess with the sudo.
  • Bazon
    Bazon about 13 years
    @Jorge: Yes, that works too. But is browsing to a hidden directory more easy? I'll type this alternative when I got time.
  • Bazon
    Bazon about 13 years
    by the way: Dragging from Desktop to Launcher directly works also, but only if you don't delete the Launcher on the Desktop.
  • Bazon
    Bazon about 13 years
    a further test showed you can move the launcher from Desktop to anywhere , it's only important that you don't delete the launcher (*.desktop file) afterwards, the symbol in the launcher bar seems to be a link to the other launcher in the file system.
  • krumpelstiltskin
    krumpelstiltskin about 13 years
    There no longer appears (in 11.04) to be the path "desktop-> unity-> launcher -> favorites" in the gconf-editor.
  • JannieT
    JannieT about 13 years
    It seems like you don't have to put the launcher in .local/share/applications folder before you drag and drop it on the launcher. You can store it in any folder.
  • Paul Lindner
    Paul Lindner about 13 years
    Thanks. That made it easy. Now I have to figure out how to change the icon (emblem?).
  • tobi
    tobi about 13 years
    @ John K: In the "creater launcher" dialogue in the beginning you can set an icon by clicking on the default icon in the top left of that window.
  • Ubuntuser
    Ubuntuser about 13 years
    my default launchers bar is empty
  • Lode
    Lode almost 13 years
    The answer below from Bazon has a way that works for 11.04 and is way easier.
  • b. e. hollenbeck
    b. e. hollenbeck over 12 years
    This doesn't work for all applications, particularly those that you install from source. I've tried pinning Netbeans 7.0 to the Unity bar in every way possible, before making my own .desktop file.
  • fitojb
    fitojb over 12 years
    @aendruk See rationale for that removal on GNOME’s Bugzilla.
  • JMC
    JMC over 12 years
    Icons can be rearranged by clicking and holding the icon for few seconds.
  • dumb906
    dumb906 over 12 years
    if your method is used, the application would not fall under any category.
  • Bart van Heukelom
    Bart van Heukelom over 12 years
    @dumb906 What do you mean? You can put the launcher in whatever category in the menu you want. Unless you mean something else by "category"?
  • Stefano
    Stefano over 12 years
    @aendruk: you can still open the "Create launcher window" with: gnome-desktop-item-edit --create-new <name of the desktop file>
  • Georgii Ivankin
    Georgii Ivankin over 12 years
    @aendruk to use the gnome-desktop-item-edit make sure you have gnome-panel package installed
  • gregghz
    gregghz over 12 years
    This is by far the simplest solution.
  • nickf
    nickf over 12 years
    When I do this, it shows up like you say, but I can't actually launch the application. It just sits there with a pulsing glow as if it is launching, but it never does.
  • copolii
    copolii over 12 years
    How on earth does this answer have less up-votes than the others? This is the FASTEST, SIMPLEST, MOST CORRECT answer!
  • stivlo
    stivlo over 12 years
    For Ubuntu this is an usability failure (a lot of other things are great, but here it falls short). The option to add a new application manually should be in the dash menu or in dash / more apps. @copolii this answer has less votes because was given many months after the original question. It works, I've also +1
  • Luis Alvarado
    Luis Alvarado about 12 years
    Thanks THIS is the solution I was looking for. The option should again be added in Ubuntu since this affects things from Wine apps in the Desktop, to customized scripts and programs that need parameters.
  • LnxSlck
    LnxSlck about 12 years
    This is the one that worked for me in Ubuntu 12.04
  • Ubuntuser
    Ubuntuser over 11 years
    doesnt work for 12.04
  • Alexis Wilke
    Alexis Wilke over 11 years
    That was the correct folder for me too! I guess when you upgrade from 11.04 or other older versions. Maybe they could have moved that folder to the new location instead of just creating a new folder... Thank you for adding this comment.
  • Andree
    Andree over 11 years
    The link to desktop file specification page is very useful. Thanks.
  • albfan
    albfan over 11 years
    alacarte, as good as always. Simple and effective.
  • wberry
    wberry about 11 years
    I had to sudo apt-get install gnome-panel first.
  • That Brazilian Guy
    That Brazilian Guy over 10 years
    What if there are no .desktop files? That's the case fot Sublime Text 2, for example.
  • That Brazilian Guy
    That Brazilian Guy over 10 years
    Doesn't work for me in 12.04.2
  • That Brazilian Guy
    That Brazilian Guy over 10 years
    Works for me in 12.4.2, but I had to install gnome-panel
  • Bryce
    Bryce over 10 years
    It's buggy in 12.04 see and vote at bugs.launchpad.net/ubuntu/+source/alacarte/+bug/1079953
  • Bevor
    Bevor over 10 years
    Tested with creating a launcher for manual Eclipse installation on 12.04.3. Works perfect.
  • laconbass
    laconbass over 10 years
    Works perfect on 13.10
  • rubo77
    rubo77 almost 10 years
    This doesn't seem to work any more on 14.04
  • rubo77
    rubo77 almost 10 years
    This works fine in Ubuntu 14.04; And if you want to add an icon to that Launcher, you have to select one with a total path, for example from /usr/share/icons/ (otherwise the icon will not be shown in the launcher)
  • Cory
    Cory almost 10 years
    Once you've copied and made the change, how do you actually get the new icon into the dash sidebar?
  • david6
    david6 almost 10 years
    Just drag from ~/.local/share/applications to dash sidebar. Open 'Nautilus/Files'; View > Show Hidden Files; navigate from '.local' > '.local/share' > ''.local/share/applications'; drag .desktop file ..
  • mchid
    mchid over 9 years
    works fine for creating one on 14.10
  • guettli
    guettli over 9 years
    This answer solves it. But I ask myself: Why is this answer needed? I think unity should support this in a way which does not need an explanation. A more easy solution would look like this: right click, choose "Add" ...
  • user68023
    user68023 about 9 years
    @guettli It's unbelievable, isn't it! Guess it's part of the "we hate end user customisation" which means you can't move the panel to the bottom of the screen, barely change the launcher behaviour, move the close/minimize etc icons to the right of the windows etc.
  • trappedIntoCode
    trappedIntoCode about 9 years
    This should be the accepted answer!
  • It's Willem
    It's Willem almost 9 years
    What if I want to create a launcher for a Python script?
  • It's Willem
    It's Willem almost 9 years
    @LnxSlck Me too! +1 to Bruno for this amazing answer! Upvotes abound!
  • It's Willem
    It's Willem almost 9 years
    Did not work for me in Ubuntu 12.04.5 LTS...
  • laconbass
    laconbass over 8 years
    And works like a charm in 14.04 too
  • 魔大农
    魔大农 over 8 years
    By far the best answer I've found. Also it's the only one that's easier than installing Xubuntu.
  • estibordo
    estibordo about 8 years
    Desktop files can also be in /usr/local/share/applications.
  • david6
    david6 about 8 years
    To clarify: The files in /usr/local/share are the launcher scripts created during application install. (as above) I recommend copying these to .local/share BEFORE attempting any further customisation.
  • Dan Dascalescu
    Dan Dascalescu almost 8 years
    Doesn't work in 16.04 - the menu item does't get saved.
  • Dan Dascalescu
    Dan Dascalescu almost 8 years
    Doesn't work in Ubuntu 16.04. It reads the menus correctly, but trying to create a new menu item fails silently - the item just isn't saved.
  • Dan Dascalescu
    Dan Dascalescu over 7 years
    Agree with @Alex: it's incredible how pigheaded Canonical is about their decisions. Check comment #2 on this gem.
  • Dan Dascalescu
    Dan Dascalescu over 7 years
    Works in Ubuntu 16.04.1, but you should edit the .desktop files it create and further edit the Name and Icon properties.
  • MWB
    MWB over 7 years
    @david6 the "dragging" should have been part of the answer instead of comments. Anyhow, I'm sad to report that Ubuntu seems to have removed this functionality in 14.04. Following an update, custom *desktop can still be dragged to the launcher, but they just don't show up :-(
  • Machtyn
    Machtyn over 6 years
    This worked for me in 16.04.
  • XavierStuvw
    XavierStuvw over 6 years
    Worked with 14.04. If you move the icon to the launcher, however, and then delete the parent icon on the desktop (for cosmetics), the icon on the launcher will disappear too.
  • Paulo Henrique
    Paulo Henrique almost 6 years
    Work for me on Ubuntu 18.04. Thanks
  • Diego
    Diego over 5 years
    This works for Ubuntu 18.04 as of now. Instead of dragging and dropping to the Launcher Bar you can find the launcher icon and then "add to Favorites".
  • rubo77
    rubo77 about 4 years
    Maybe you have to add a line Path=/tmp/ so it works in Ubuntu 19.10 too. note, you cannot double click on the icon in nautilus, but you can search for it in dash and then right-click on it to add it to favorites