Cannot add custom launcher to Ubuntu Dock ('Add to Favorites' option does not show up)

Open Terminal and run

gsettings get org.gnome.shell favorite-apps

You should get the list of .desktop files associated to the apps pinned to Ubuntu dock in order, something like the following:

['appname-1.desktop', 'appname-2.desktop', 'appname-3.desktop', 'appname-4.desktop', 'appname-5.desktop']

Suppose you want to pin the app associated to the intellij.desktop file as the second item in the dock. In that case, run

gsettings set org.gnome.shell favorite-apps "['appname-1.desktop', 'intellij.desktop', 'appname-2.desktop', 'appname-3.desktop', 'appname-4.desktop', 'appname-5.desktop']"

The answer from @pomsky is correct, but there is an easier way: use

dconf-editor  

(install it with sudo apt-get install dconf-editor if not installed) and navigate to

org/gnome/shell/favorite-apps.

There it is possible to edit and rearrange the Launcher.


This can happen when the StartupWMClass doesn't correspond to the WMClass of the application. See this question for details on how it works and how to find the WMClass. In my case, setting the correct StartupWMClass in the .desktop file fixes this issue.