diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-05-10 12:18:10 +0200 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-05-10 12:18:10 +0200 |
commit | 8046ebb2cc9e84364a4f2f580499e7dbfa4e7b8a (patch) | |
tree | af04b2ba1a1b9d4564b8bb35396c6641828f1c42 /bin | |
parent | 70d1b330a7a09a555a1c66c17dc5111e08e77b8b (diff) | |
download | dconf-8046ebb2cc9e84364a4f2f580499e7dbfa4e7b8a.tar.gz |
cli: make 'dconf watch' actually write output
Diffstat (limited to 'bin')
-rw-r--r-- | bin/dconf.vala | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bin/dconf.vala b/bin/dconf.vala index a2d7a60..071d39e 100644 --- a/bin/dconf.vala +++ b/bin/dconf.vala @@ -215,8 +215,31 @@ void dconf_unlock (string?[] args) throws Error { client.set_locked (key, false); } +void show_path (DConf.Client client, string path) { + if (DConf.is_key (path)) { + var value = client.read (path); + + print (" %s\n", value != null ? value.print (true) : "unset"); + } +} + +void watch_function (DConf.Client client, string path, string[] items, string tag) { + if (items.length == 0) { + print ("%s\n", path); + show_path (client, path); + print ("\n"); + } else { + foreach (var item in items) { + var full = path + item; + print ("%s\n", full); + show_path (client, full); + } + print ("\n"); + } +} + void dconf_watch (string?[] args) throws Error { - var client = new DConf.Client (); + var client = new DConf.Client (null, watch_function); var path = args[2]; DConf.verify_path (path); |