diff options
Diffstat (limited to 'desktop/assistant/Assistant.qml')
| -rw-r--r-- | desktop/assistant/Assistant.qml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/desktop/assistant/Assistant.qml b/desktop/assistant/Assistant.qml index a4fda72..d6863a0 100644 --- a/desktop/assistant/Assistant.qml +++ b/desktop/assistant/Assistant.qml @@ -293,6 +293,40 @@ Scope { } } + // deck-it's Assistant tab look, from its config's [assistant] keys: the + // backdrop picture, the user's avatar, and where the assistant's face is + // in the backdrop ([centre x, centre y, size] in its pixels). Empty: no + // backdrop, plain circles. + // ponytail: read once at startup; a qs restart picks up a config edit. + property string backdrop: "" + property string avatar: "" + property var face: [] + function fileUrl(p) { return p ? "file://" + p.split("/").map(encodeURIComponent).join("/") : ""; } + + Process { + running: true + command: ["/usr/bin/python3", "-c", ` +import json, os, tomllib +p = os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"), "deck-it", "config.toml") +try: + a = tomllib.load(open(p, "rb")).get("assistant", {}) +except (OSError, tomllib.TOMLDecodeError): + a = {} +f = a.get("face") +ok = isinstance(f, list) and len(f) == 3 and all(isinstance(v, (int, float)) for v in f) +print(json.dumps({"bg": os.path.expanduser(a.get("background") or ""), + "avatar": os.path.expanduser(a.get("user_avatar") or ""), + "face": f if ok else []}))`] + stdout: StdioCollector { + onStreamFinished: { + try { + const c = JSON.parse(text); + root.backdrop = c.bg; root.avatar = c.avatar; root.face = c.face; + } catch (e) {} + } + } + } + // A file whose name says nothing (a script with no suffix) is "other" // until file(1) has read it. One run for all of them; the daemon makes // its own call on the content when the question is sent. |
