aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/uzbl/plugins/config.py
diff options
context:
space:
mode:
authorGravatar Mason Larobina <mason.larobina@gmail.com>2009-11-29 18:27:07 +0800
committerGravatar Mason Larobina <mason.larobina@gmail.com>2009-11-29 18:27:07 +0800
commit5cecb5d6570df33c2ce9c700c563fad8b787f13e (patch)
tree16a6ef9d7a0348b2e7156551edc04f7861bf35ff /examples/data/uzbl/plugins/config.py
parent6a33e0043932fbb2ab36d8e2557c5758d1f7004b (diff)
Add force option to set in config plugin.
Diffstat (limited to 'examples/data/uzbl/plugins/config.py')
-rw-r--r--examples/data/uzbl/plugins/config.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/data/uzbl/plugins/config.py b/examples/data/uzbl/plugins/config.py
index 57c2403..47b59f9 100644
--- a/examples/data/uzbl/plugins/config.py
+++ b/examples/data/uzbl/plugins/config.py
@@ -22,12 +22,16 @@ def get_config(uzbl):
return UZBLS[uzbl]
-def set(uzbl, key, value=''):
- '''Sends a: "set key = value" command to the uzbl instance.'''
+def set(uzbl, key, value='', force=True):
+ '''Sends a: "set key = value" command to the uzbl instance. If force is
+ False then only send a set command if the values aren't equal.'''
if type(value) == types.BooleanType:
value = int(value)
+ else:
+ value = unicode(value)
+
if not _VALIDSETKEY(key):
raise KeyError("%r" % key)
@@ -35,6 +39,11 @@ def set(uzbl, key, value=''):
if '\n' in value:
value = value.replace("\n", "\\n")
+ if not force:
+ config = get_config(uzbl)
+ if key in config and config[key] == value:
+ return
+
uzbl.send('set %s = %s' % (key, value))
@@ -61,8 +70,7 @@ class ConfigDict(dict):
def __setitem__(self, key, value):
'''Makes "config[key] = value" a wrapper for the set function.'''
- if key not in self or unicode(self[key]) != unicode(value):
- set(self._uzbl, key, value)
+ set(self._uzbl, key, value, force=False)
def variable_set(uzbl, args):