현재 Gjs에 간단한 응용 프로그램을 작성하고 있습니다.이 응용 프로그램은 gnome-shell의 배경 이미지를 변경해야합니다. gsettings
도구를 사용하여이 작업을 수행하는 방법에 대한 해결책은 here입니다.GSettings로 dconf-entry를 바꿀 수 없습니다
나는 그 주위에 데스크톱 응용 프로그램을 만들고 싶기 때문에 Gio의 GSettings
-class을 사용하여 org.gnome.desktop.background.picture-uri
-key를 변경하려고합니다. 그러나 set_X()
- 방법을 사용하면 키 값이 변경되지 않습니다.
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";
예상대로 값을 읽기하는 작업을 수행, true
을 반환하고 set_string()
-method도 true
을 반환 -method is_writable()
:
이
는 gsettings 값을 변경하려면 코드입니다."지연 적용"모드가 아니며 키에 GVariantType
문자열이 포함되어 있으므로 set_string()
-method가 작동해야합니다.
정상적인 gsettings
(링크 된 게시물에 설명 된대로) 명령 줄 도구를 사용하면 정상적으로 작동합니다.
문제가 무엇인지 파악할 수 없으며 로그 나 다른 것을 찾을 수있는 곳이 있습니까?
나는 어제부터이 문제에 대해 머리를 터뜨 렸고 결국 해결책을 찾게되어 기쁘다. 감사! – Serrano