Categories
DailyOps

How to define favorite applications on Ubuntu desktop

Define favorite applications on Ubuntu desktop using command-line utility.

Get current favorite applications.

$ gsettings get org.gnome.shell favorite-apps
['org.gnome.Nautilus.desktop', 'chromium_chromium.desktop', 'code_code.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop']

List available desktop entries for applicatons.

$ ls /usr/share/applications/  ~/.local/share/applications/
/home/milosz/.local/share/applications/:

/usr/share/applications/:
apport-gtk.desktop                 gnome-location-panel.desktop          im-config.desktop                                  org.gnome.eog.desktop                     rygel.desktop
apturl.desktop                     gnome-lock-panel.desktop              info.desktop                                       org.gnome.Evince.desktop                  shotwell.desktop
bluetooth-sendto.desktop           gnome-microphone-panel.desktop        io.snapcraft.SessionAgent.desktop                  org.gnome.Evince-previewer.desktop        shotwell-viewer.desktop
defaults.list                      gnome-mouse-panel.desktop             libreoffice-calc.desktop                           org.gnome.Evolution-alarm-notify.desktop  simple-scan.desktop
evolution-calendar.desktop         gnome-network-panel.desktop           libreoffice-draw.desktop                           org.gnome.FileRoller.desktop              snap-handle-link.desktop
firefox.desktop                    gnome-notifications-panel.desktop     libreoffice-impress.desktop                        org.gnome.font-viewer.desktop             software-properties-drivers.desktop
gcr-prompter.desktop               gnome-online-accounts-panel.desktop   libreoffice-math.desktop                           org.gnome.gedit.desktop                   software-properties-gtk.desktop
gcr-viewer.desktop                 gnome-power-panel.desktop             libreoffice-startcenter.desktop                    org.gnome.Logs.desktop                    software-properties-livepatch.desktop
geoclue-demo-agent.desktop         gnome-printers-panel.desktop          libreoffice-writer.desktop                         org.gnome.Mahjongg.desktop                solaar.desktop
gkbd-keyboard-display.desktop      gnome-region-panel.desktop            libreoffice-xsltfilter.desktop                     org.gnome.Mines.desktop                   sol.desktop
gnome-applications-panel.desktop   gnome-removable-media-panel.desktop   mc.desktop                                         org.gnome.Nautilus.desktop                system-config-printer.desktop
gnome-background-panel.desktop     gnome-search-panel.desktop            mcedit.desktop                                     org.gnome.PowerStats.desktop              thunderbird.desktop
gnome-bluetooth-panel.desktop      gnome-session-properties.desktop      mimeinfo.cache                                     org.gnome.Screenshot.desktop              transmission-gtk.desktop
gnome-camera-panel.desktop         gnome-sharing-panel.desktop           nautilus-autorun-software.desktop                  org.gnome.seahorse.Application.desktop    update-manager.desktop
gnome-color-panel.desktop          gnome-sound-panel.desktop             nm-applet.desktop                                  org.gnome.Shell.desktop                   usb-creator-gtk.desktop
gnome-connectivity-panel.desktop   gnome-system-monitor.desktop          nm-connection-editor.desktop                       org.gnome.Shell.Extensions.desktop        vim.desktop
gnome-control-center.desktop       gnome-system-monitor-kde.desktop      nvidia-settings.desktop                            org.gnome.Shell.PortalHelper.desktop      x2goclient.desktop
gnome-datetime-panel.desktop       gnome-thunderbolt-panel.desktop       org.freedesktop.IBus.Panel.Emojier.desktop         org.gnome.Sudoku.desktop                  xdg-desktop-portal-gtk.desktop
gnome-default-apps-panel.desktop   gnome-ubuntu-panel.desktop            org.freedesktop.IBus.Panel.Extension.Gtk3.desktop  org.gnome.Terminal.desktop                xpra.desktop
gnome-diagnostics-panel.desktop    gnome-universal-access-panel.desktop  org.freedesktop.IBus.Setup.desktop                 org.gnome.Todo.desktop                    xpra-gui.desktop
gnome-disk-image-mounter.desktop   gnome-usage-panel.desktop             org.gnome.baobab.desktop                           org.gnome.Totem.desktop                   xpra-launcher.desktop
gnome-disk-image-writer.desktop    gnome-user-accounts-panel.desktop     org.gnome.Calculator.desktop                       org.remmina.Remmina.desktop               xpra-shadow.desktop
gnome-display-panel.desktop        gnome-wacom-panel.desktop             org.gnome.Calendar.desktop                         python3.9.desktop                         yelp.desktop
gnome-info-overview-panel.desktop  gnome-wifi-panel.desktop              org.gnome.Characters.desktop                       remmina-file.desktop
gnome-initial-setup.desktop        hplj1020.desktop                      org.gnome.Cheese.desktop                           remmina-gnome.desktop
gnome-keyboard-panel.desktop       htop.desktop                          org.gnome.DejaDup.desktop                          rhythmbox.desktop
gnome-language-selector.desktop    ibus-setup-table.desktop              org.gnome.DiskUtility.desktop                      rhythmbox-device.desktop

Inspect sample desktop entry.

$ cat /usr/share/applications/org.gnome.gedit.desktop 
[Desktop Entry]
Name=Text Editor
Comment=Edit text files
Exec=gedit %U
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
# TRANSLATORS: Do NOT translate or transliterate this text!
#              This is an icon file name.
Icon=org.gnome.gedit
Categories=GNOME;GTK;Utility;TextEditor;
Actions=new-window;new-document;
# TRANSLATORS: Do NOT translate or localize the semicolons!
#              The list MUST also end with a semicolon!
#              Search terms to find this application.
Keywords=Text;Editor;Plaintext;Write;gedit;
DBusActivatable=true
X-Ubuntu-Gettext-Domain=gedit

[Desktop Action new-window]
Name=New Window
Exec=gedit --new-window

[Desktop Action new-document]
Name=New Document
Exec=gedit --new-document

Define a new list of favorite applications.

$ gsettings set org.gnome.shell favorite-apps \
    "['org.gnome.Nautilus.desktop', 'chromium_chromium.desktop', 'code_code.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop']"

Alternatively, manipulate dconf database directly.

$ dconf read /org/gnome/shell/favorite-apps
['org.gnome.Nautilus.desktop', 'chromium_chromium.desktop', 'code_code.desktop', 'org.gnome.Terminal.desktop']
$ dconf write /org/gnome/shell/favorite-apps \
    "['org.gnome.Nautilus.desktop', 'chromium_chromium.desktop', 'code_code.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop']"