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

Solution 1:

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 2:

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 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.