diff options
Diffstat (limited to 'desktop/modules/ai/AiModule.qml')
| -rw-r--r-- | desktop/modules/ai/AiModule.qml | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/desktop/modules/ai/AiModule.qml b/desktop/modules/ai/AiModule.qml index a96f484..6df3d6b 100644 --- a/desktop/modules/ai/AiModule.qml +++ b/desktop/modules/ai/AiModule.qml @@ -49,10 +49,16 @@ Module { Quickshell.env("HOME") + "/Programming/GIT/desktop-assistant/assistant.sh" // Each project's own control. Fanfictioner has no start, a run needs a - // story file, and its stop needs the pid, see stop(). + // story file, and its stop needs the pid, see stop(). llamachat has no + // restart, and --quit answers before the app is gone, so a --daemon + // straight after would find it still running and do nothing: wait for + // --ping to fail first, up to 5s. readonly property var controls: ({ - assistant: { start: [assistantSh, "start"], stop: [assistantSh, "stop"] }, - chat: { start: ["llamachat", "--daemon"], stop: ["llamachat", "--quit"] }, + assistant: { start: [assistantSh, "start"], stop: [assistantSh, "stop"], + restart: [assistantSh, "restart"] }, + chat: { start: ["llamachat", "--daemon"], stop: ["llamachat", "--quit"], + restart: ["sh", "-c", "llamachat --quit; for _ in $(seq 50); do " + + "llamachat --ping || break; sleep 0.1; done; exec llamachat --daemon"] }, imggen: { start: ["imggen", "start"], stop: ["imggen", "stop"] }, }) @@ -62,6 +68,12 @@ Module { if (canStart(app)) exec(controls[app.name].start); } + function canRestart(app) { return controls[app.name]?.restart !== undefined; } + + function restart(app) { + if (canRestart(app)) exec(controls[app.name].restart); + } + function stop(app) { if (app.name !== "fanfic") { exec(controls[app.name].stop); |
