8

I'm guessing I need to edit one of the schemas available in gsettings but I don't know which one. and when I listed all the schemas, there's just too many of them.

10

The key you want is favorite-apps, the schema ID is org.gnome.shell. Now to list your favorite apps you can simply run

gsettings get org.gnome.shell favorite-apps

or

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

These will return an array of strings e.g.

['firefox.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.gedit.desktop', 'gnome-calculator.desktop']

Now, to remove a value from that array you could use text processing tools like sed/awk to check if an item is in that list and remove it keeping the same format (not that trivial though definitely doable) and once you get it right just write the new settings to the database e.g. assuming you wanted to remove org.gnome.Nautilus.desktop you would run (note the double quotes):

gsettings set org.gnome.shell favorite-apps "['firefox.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop', 'gnome-calculator.desktop']"

or

dconf write /org/gnome/shell/favorite-apps "['firefox.desktop', 'org.gnome.Terminal.desktop', 'org.gnome.gedit.desktop', 'gnome-calculator.desktop']"

Still, it's easier to write your own utility (using gsettings API) that will accept one or more desktop file names as positional parameters and remove them from favorites; to get you started, here is a very basic example in python that accepts one param (run as script.py firefox.desktop):

#!/usr/bin/env python

from sys import argv
from gi.repository import Gio,GLib
item=argv[1]
gschema = Gio.Settings('org.gnome.shell')
gvalues=gschema.get_value('favorite-apps').unpack()
if item in gvalues: gvalues.remove(item)
gschema.set_value('favorite-apps', GLib.Variant('as', gvalues))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.