Add app to favorites from command line

Solution 1:

Unfortunately, as an end-user you can only "read" and "write" (also reset) the array that dictates the list of favourite apps by using dconf/gsettings. For example, as mentioned here, you can get the value by running

gsettings get org.gnome.shell favorite-apps

and write a new value by a suitable gsettings set command. There is no straightforward way to append to the array, you can only overwrite.

But you can combine these two and have a custom command. You need to know the name of the .desktop launcher associated to the application you want to add to the favourites first. Let's say it is appname.desktop. Then you can run the following to add the application associated to appname.desktop to the favourites:

gsettings set org.gnome.shell favorite-apps "$(gsettings get org.gnome.shell favorite-apps | sed s/.$//), 'appname.desktop']"

Solution 2:

The path for dconf is: /org/gnome/shell/favorite-apps. For example

dconf read /org/gnome/shell/favorite-apps

Which for me produces

['org.gnome.Nautilus.desktop', 'firefox.desktop', 'vivaldi-stable.desktop', 'steam.desktop']

So in theory you could use dconf write to adjust these values