from gi.repository import Gio,GLib
class GnomeScreenLock:
IDLE_DELAY_SCHEMA = 'org.gnome.desktop.session'
IDLE_DELAY_KEY = 'idle-delay'
IDLE_ACTIVATION_SCHEMA = 'org.gnome.desktop.screensaver'
IDLE_ACTIVATION_KEY = 'idle-activation-enabled'
def getIdleDelay(self):
gsettings = Gio.Settings.new(self.IDLE_DELAY_SCHEMA)
return gsettings.get_value(self.IDLE_DELAY_KEY).get_uint32()
def setIdleDelay(self,delaySeconds):
gsettings = Gio.Settings.new(self.IDLE_DELAY_SCHEMA)
gsettings.set_value(self.IDLE_DELAY_KEY,GLib.Variant.new_uint32(delaySeconds))
def isIdleActivationEnabled(self):
gsettings = Gio.Settings.new(self.IDLE_ACTIVATION_SCHEMA)
return gsettings.get_boolean(self.IDLE_ACTIVATION_KEY)
def setIdleActivationStatus(self,activation):
gsettings = Gio.Settings.new(self.IDLE_ACTIVATION_SCHEMA)
gsettings.set_boolean(self.IDLE_ACTIVATION_KEY,activation)
Tuesday 14 June 2011
Reading and writing GSettings from Python
Here's the class I wrote to read/write the screensaver settings from GSettings. It's probably not in the best Python style, but it illustrates the idea.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment