213

How can I add new programs to the launcher (or the dock in Ubuntu 17.10 and later) in Ubuntu?

pomsky
  • 68,507

2 Answers2

204

To add applications to the Dash (then you press the windows key), Go to ~/.local/share/applications and create your .desktop files there.

For example:

  • Open Nautilus (also called Files (the file manager))
  • Browse to ~/.local/share/applications (ctrl + h to show hidden folders/files)
  • Right click and choose create empty document
  • Name the file testing.desktop
  • Enter in a valid desktop contents (sample below)
  • Save it and now that entry will show when you press the windows key under applications.

A much easier way...

sudo apt-get install alacarte

Then run alacarte and create menu entries as you like. They will show in the unity launcher.


Sample desktop file (from sublime text 2)

#!/usr/bin/env xdg-open  

[Desktop Entry]
Version=1.0
Name=Sublime Text 2
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Text Editor
Exec=subl
Terminal=false
Icon="/opt/Sublime Text 2/Icon/48x48/sublime_text.png"
Type=Application
Categories=TextEditor;IDE;Development
X-Ayatana-Desktop-Shortcuts=NewWindow
Icon[en_US]=/opt/Sublime Text 2/Icon/128x128/sublime_text.png

[NewWindow Shortcut Group]
Name=New Window
Exec=subl -n
TargetEnvironment=Unity
Zanna
  • 70,465
coteyr
  • 18,288
  • 3
    By "Launcher Thingy (then you press the windows key)", do you mean the dash? – iBelieve Nov 30 '12 at 21:15
  • 6
    Yes...... That's what i said dash (hunts for the edit link) – coteyr Nov 30 '12 at 21:20
  • 11
    Here is a link to more details about creating desktop files: https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles. – iBelieve Nov 30 '12 at 21:28
  • 1
    After this, reload the files using http://askubuntu.com/a/463963/125111. –  May 31 '15 at 10:45
  • If it doesn't show up, drag the desktop file on unity. (Ubuntu 15.10) – Quazi Irfan Nov 19 '15 at 07:39
  • 1
    Why not lead with the easier way, and put the hard way after the divider? And for that matter, are there any advantages to the hard way? If so, I think you should spell them out (or at least summarize them), and if not, I would just get rid of the hard way altogether. – yshavit Aug 06 '16 at 20:39
  • 7
    Easier and hard are opnions. I find editing the .desktop files eaiser. – coteyr Aug 07 '16 at 03:51
  • 1
    I think it would ruin this excellent answer to remove the 'hard' way. The hard way explains how it actually works, not a shortcut to get to the end. – Dan Nissenbaum Jul 16 '17 at 14:01
  • I did the editing the desktop. :) thanks a lot :) – Woppi Jan 31 '18 at 08:07
  • 5
    So much hassle for something that should be built into the OS GUI. Reason why people don't want to try Linux. – JohnyTex Mar 18 '20 at 18:32
96

Just launch the application you want to attach to the Unity Launcher or Ubuntu Dock; right click the icon and depending on your version of Ubuntu select the method below.

On Ubuntu 17.10 and later (with GNOME 3)

Select "Add to Favorites":


(click to enlarge)

Alternatively, click the "Show Applications" icon, browse to the icon of the program you want to add, right click the program icon and you will see the option "Add To Favorites". Selecting that option places the icon in the dock.

You can also drag applications directly from the Dash (or the 'Show Applications' list / 'Activities' overview) into the Ubuntu dock.

Before Ubuntu 17.10 (with Unity 7)

Select "Lock to Launcher":

enter image description here

pomsky
  • 68,507
Goddard
  • 4,724
  • 2
  • 33
  • 51
  • 3
    There's a wrinkle here for applications that run in a terminal (e.g. iPython), since they appear in the launcher as a terminal rather than with their own icon. However, you can simply drag the icon from the dash into the launcher. – Ned Sep 12 '13 at 11:04
  • I tried this trick but when I closed the application, the launch button disappeared from launcher and I have to start my application from the terminal again. Please help. – Marta Cz-C Jul 29 '14 at 11:18
  • This didn't work for me. The icons didn't persist when I rebooted. The other answer fixed the problem – k_g Feb 03 '16 at 05:55
  • 3
    this fails on Ubuntu 18.04 – Scott Stensland Mar 04 '18 at 13:37
  • 13
    The only thing I see on Ubuntu 18.04 is a window list and Quit when I right-click. – Michael Mior May 17 '18 at 17:13
  • 6
    In Ubuntu 18.04, the location of the application launcher needs to be known by Gnome for the "Add to favorites" button to appear. With this in mind, the procedure to add an application to the launcher is as follows. First create a .desktop file for the application using gnome-desktop-item-edit ~/Desktop/ --create-new. Then move this .desktop file into either /usr/share/applications or ~/.local/share/applications, which are the two locations Gnome will look for applications. If you run the program and right-click on its icon in the dock, the "Add to favorites" button should be available. – anon1802 Sep 21 '18 at 13:29
  • For Ubuntu 19.10 or higher, follow this advice to create a .desktop file: https://askubuntu.com/a/1184737/978690 – Stefan_EOX Jan 21 '21 at 08:03