Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way to access the variables to edit via bash (or other libraries with bash or python)? Similar to how you can use 'gconftool-2' in bash to edit properties that would update them after edited.

For example, I would like to run a script to disable 'the file manager to handle the desktop' by terminal (bash or python) instead of opening this window each time.

I also have tried making 'show_desktop' to false in nautilus in gconf-editor but that doesn't do anything.

I am using Ubuntu 11.10 and compiz as the window manager on Gnome (2 I believe, or whatever comes with 11.10).

share|improve this question

1 Answer 1

We're going to use Gio to get the Base Key (the category the value is at). Once we get that value we're going to set a CheckBox on it to change the value. We then setup various signals to listen for changes in the setting and CheckBox. I know it's not the desktop one but you can plug it into the BASE_KEY. By the way, you shouldn't try and use GConf in GNOME 3, because it's been deprecated.

from gi.repository import Gio, Gtk

class GSettingsTest(object):
    BASE_KEY = "org.gnome.nautilus.preferences"
    def __init__(self):
        # Make a check button to change the value.
        settings = Gio.Settings(self.BASE_KEY)
        change_check = Gtk.CheckButton("Always Use Browser")
        change_check.set_active (settings.get_boolean("always-use-browser"))
        settings.connect("changed::always-use-browser", self.on_changed, change_check)
        change_check.connect('toggled', self.on_check_clicked, settings)

        window = Gtk.Window(type = Gtk.WindowType.TOPLEVEL)
        window.set_title("Change Nautilus")
        window.set_border_width(24)
        window.connect("delete-event", Gtk.main_quit)
        window.add(change_check)
        window.show_all()
        Gtk.main()

    def on_changed(self, settings, key, change_check):
        change_check.set_active(settings.get_boolean("always-use-browser"))

    def on_check_clicked(self, button, settings):
        settings.set_boolean("always-use-browser", button.get_active())


if __name__ == '__main__':
    app = GSettingsTest()

What the program looks like, with the settings synced.

share|improve this answer
    
Actually you did lead me to it. The actual key is 'show-desktop-icons'. Access it from 'org.gnome.desktop.background' -> show-desktop-icons. Thanks for your help! –  user654628 Feb 11 '12 at 19:28
    
No Problem:) Glad I could help –  Nicholos Tyler Feb 18 '12 at 14:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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