61

I want to add a custom program to the favourites of Ubuntu dock, but there is no option for that.

enter image description here

Translating the text in this image (same as above) only says:

  1. All windows

  2. Quit

It also doesn't appear in "Show Applications":
enter image description here

Is there a way for adding the program to both Favourites and Applications menus?

pomsky
  • 68,507
Elgirhath
  • 713

1 Answers1

90

This is fairly easy. First, make a desktop application file that follows the freedesktop.org spec, e.g.

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=MyApplication
Comment=My fancy new application
Exec=my_application
Icon=my_application.png
Terminal=false

If you want this to be usable by anyone on your system, put it in /usr/share/applications. For personal use only, you can put it in ~/.local/share/applications. Look in /usr/share/applications for other examples. Add your icon image to the /usr/share/icons directory, or I assume the ~/.local/share/icons, although I have not tried that last location myself.

Then, you can search for the application by name and drag it to the launcher in the usual way!

Martin W
  • 2,545
  • 8
    This doesnt work anymore on 18.04 :( – Shervin Asgari Oct 14 '18 at 10:19
  • 5
    Shervin: I can verify that this still works on 18.04, both using /usr/share/applications or ~/.local/share/applications. You may need to restart gnome to update the cache. – Martin W Oct 16 '18 at 21:54
  • 19
    One step is missing from the description to make it work: the .desktop file needs to be executable, so run e.g. chmod a+x eclipse.desktop, see https://askubuntu.com/questions/1082340/how-to-add-eclipse-to-favorites – dariok Jul 17 '19 at 10:11
  • Work properly in 19.10, even did not need any cache cleanup, it instantly showed up in dock search results, plus now I can pin app, thanks! – PeterM Nov 15 '19 at 07:10
  • 23
    For anyone looking to do this from the command line, run dconf read /org/gnome/shell/favorite-apps, and you will get a list which starts like ['firefox.desktop', 'org.gnome.Nautilus.desktop']. Add your new .desktop file to the list and run the appropriately-modified command dconf write /org/gnome/shell/favorite-apps "['firefox.desktop', 'org.gnome.Nautilus.desktop', 'my-app.desktop']". (Be careful since you'll lose your existing favorites if you forget to include them with the dconf write command.) – Ben Mares Feb 17 '20 at 14:31
  • @BenMares Awesome! this worked for me when I tried to add Zoom to favorite. Thanks! btw just for other people, add the quote marks around the list otherwise it won't work, took me a while to notice haha – Kenivia Apr 01 '20 at 23:23
  • 1
    This answer misses that you have to set the executable bit + mark it as trusted: https://askubuntu.com/a/1152748/37881 – Robert May 25 '20 at 11:59
  • 1
    I had to do as @PeterM suggested implicitly and search for it from the dock search. I could pin it from there. Just double clicking on it from the applications directory didn't allow it to be pinned. – MrMas Jul 27 '20 at 16:18
  • @BenMares Thank you, it works. But just found another solution in SO: gio set </home/path/to/your/whatever.desktop> "metadata::trusted" yes – MortezaE Oct 21 '21 at 06:15
  • Click on the Configure option and click on “Create Desktop Entry” -> https://itsfoss.com/install-pycharm-ubuntu/ – Zhivko.Kostadinov Aug 11 '22 at 11:50
  • I followed the comment from @BenMares and it did work – KJA May 15 '23 at 06:52
  • @BenMares You should add that as an answer. – Reinstate Monica -- notmaynard Jun 09 '23 at 15:25