【发布时间】:2012-04-16 15:03:42
【问题描述】:
我目前正在Gjs 上构建一个简单的应用程序,它应该会更改我的 gnome-shell 的背景图像。关于如何使用gsettings-工具完成此操作的解决方案可以在here 找到。
由于我想围绕它构建一个桌面应用程序,我想通过使用 Gio 的 GSettings-class 来更改 org.gnome.desktop.background.picture-uri-key。但是使用set_X()-方法不会改变key的值。
这是我更改 gsettings 值的代码:
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";
读取值确实按预期工作,is_writable()-方法返回true,set_string()-方法也返回true。
我检查了我没有处于“延迟应用”模式,并且密钥有一个GVariantType 字符串,所以set_string()-方法应该可以工作。
使用普通的gsettings 命令行工具(如链接帖子中所述)可以正常工作。
我不知道是什么问题,有什么地方可以查找日志什么的吗?
【问题讨论】:
标签: javascript gio gnome-shell gjs