Theme quick reload
This commit is contained in:
+37
-2
@@ -25,6 +25,7 @@ QtObject {
|
||||
property string borderColor: ""
|
||||
|
||||
property bool loaded: false
|
||||
readonly property string configPath: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/omni-launcher/config.json"
|
||||
|
||||
function _apply(obj) {
|
||||
if (typeof obj.fontFamily === "string" && obj.fontFamily.length > 0) fontFamily = obj.fontFamily;
|
||||
@@ -46,9 +47,43 @@ QtObject {
|
||||
if (typeof colors.border === "string" && colors.border.length > 0) borderColor = colors.border;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
_load();
|
||||
_startWatcher();
|
||||
}
|
||||
|
||||
function _load() {
|
||||
_loader.running = false;
|
||||
_loader.command = ["cat", configPath];
|
||||
_loader.running = true;
|
||||
}
|
||||
|
||||
function _startWatcher() {
|
||||
_watcher.running = false;
|
||||
_watcher.command = [
|
||||
"sh", "-c",
|
||||
"while inotifywait -q -e close_write " + JSON.stringify(configPath) + " 2>/dev/null; do echo CHANGED; done"
|
||||
];
|
||||
_watcher.running = true;
|
||||
}
|
||||
|
||||
property Process _watcher: Process {
|
||||
running: false
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\n"
|
||||
onRead: line => {
|
||||
if (line.indexOf("CHANGED") >= 0) {
|
||||
console.log("omni-launcher: config changed, reloading");
|
||||
root._load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: root._startWatcher()
|
||||
}
|
||||
|
||||
property Process _loader: Process {
|
||||
running: true
|
||||
command: ["sh", "-c", "cat \"${XDG_CONFIG_HOME:-$HOME/.config}/omni-launcher/config.json\" 2>/dev/null"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const text = (this.text || "").trim();
|
||||
|
||||
Reference in New Issue
Block a user