admin管理员组文章数量:1434904
I'm currently building a simple application on Gjs, which should change the background-image of my gnome-shell. A solution on how this can be done using the gsettings
-tool can be found here.
Since I want to build a desktop-application around it, I want to change the org.gnome.desktop.background.picture-uri
-key by using Gio's GSettings
-class. But using the set_X()
-method does not change the value of the key.
This is my code to change the gsettings value:
var gio = imports.gi.Gio;
// Get the GSettings-object for the background-schema:
var background = new gio.Settings({schema: "org.gnome.desktop.background"});
// Read the current Background-Image:
print( "Current Background-Image: "+background.get_string("picture-uri") );
if (background.is_writable("picture-uri")){
// Set a new Background-Image (should show up immediately):
if (background.set_string("picture-uri", "file:///path/to/some/pic.jpg")){
print("Success!");
}
else throw "Couldn't set the key!";
} else throw "The key is not writable";
Reading the value does work as expected, the is_writable()
-method returns true
and the set_string()
-method also returns true
.
I have checked that I'm not in "delay-apply" mode and the key has a GVariantType
of string, so the set_string()
-method should work.
Using the normal gsettings
mand-line tool (as explained in the linked post) works just fine.
I can't figure out what the problem is, is there any place I can look for logs or something?
I'm currently building a simple application on Gjs, which should change the background-image of my gnome-shell. A solution on how this can be done using the gsettings
-tool can be found here.
Since I want to build a desktop-application around it, I want to change the org.gnome.desktop.background.picture-uri
-key by using Gio's GSettings
-class. But using the set_X()
-method does not change the value of the key.
This is my code to change the gsettings value:
var gio = imports.gi.Gio;
// Get the GSettings-object for the background-schema:
var background = new gio.Settings({schema: "org.gnome.desktop.background"});
// Read the current Background-Image:
print( "Current Background-Image: "+background.get_string("picture-uri") );
if (background.is_writable("picture-uri")){
// Set a new Background-Image (should show up immediately):
if (background.set_string("picture-uri", "file:///path/to/some/pic.jpg")){
print("Success!");
}
else throw "Couldn't set the key!";
} else throw "The key is not writable";
Reading the value does work as expected, the is_writable()
-method returns true
and the set_string()
-method also returns true
.
I have checked that I'm not in "delay-apply" mode and the key has a GVariantType
of string, so the set_string()
-method should work.
Using the normal gsettings
mand-line tool (as explained in the linked post) works just fine.
I can't figure out what the problem is, is there any place I can look for logs or something?
Share Improve this question asked Apr 2, 2012 at 23:19 Lukas KnuthLukas Knuth 25.8k16 gold badges87 silver badges114 bronze badges1 Answer
Reset to default 8After not getting any responses here I asked the same question on the gjs-mailing list.
It turned out that the writes to dconf were not yet on the disk when my script exited, so they were never really applied.
The solution was to call the g_settings_sync()
function (JsDoc) right after the set_string()
function, to ensure that all writes had finished.
if (background.set_string("picture-uri", "file:///path/to/some/pic.jpg")){
gio.Settings.sync()
print("Success!");
}
Thanks to Johan Dahlin and his answer.
本文标签: javascriptCan39t change dconfentry with GSettingsStack Overflow
版权声明:本文标题:javascript - Can't change dconf-entry with GSettings - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745638068a2667683.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论