aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-16 12:51:04 +0200
committerDanilo M. <danix@danix.xyz>2026-10-16 12:51:04 +0200
commitfb2f4dc1b2bea257be1f6dc5afa2f3a3b626df71 (patch)
treea46c41e46e064a5a4d981d6149749d12649f0e65
parentf6c4f3639409369b1f3954e53f48b6d86e3d85f6 (diff)
downloaddesktop-assistant-fb2f4dc1b2bea257be1f6dc5afa2f3a3b626df71.tar.gz
desktop-assistant-fb2f4dc1b2bea257be1f6dc5afa2f3a3b626df71.zip
assistant.sh: manage the daemon only
The overlay is gone from the quickshell repo, and the canvas that replaces it lives in the desktop shell, which has its own lifecycle. status now reports the process, the socket and the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rwxr-xr-xassistant.sh48
1 files changed, 14 insertions, 34 deletions
diff --git a/assistant.sh b/assistant.sh
index e288afd..315829e 100755
--- a/assistant.sh
+++ b/assistant.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# desktop-assistant: start, stop, restart or check the voice loop.
+# desktop-assistant: start, stop, restart or check the daemon.
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
#
# This program is free software; you can redistribute it and/or modify it
@@ -17,23 +17,17 @@
#
# assistant.sh start|stop|restart|status
#
-# stop: SIGTERM any running assistant.py (whisper-server and amixer die
-# with it through PDEATHSIG), SIGKILL after 10 s; same for the quickshell
-# overlay (OVERLAY, default the quickshell repo next to this one).
-# start: run both in their own session, detached from the terminal,
-# logging where the Hyprland autostart does; does nothing for one already
-# running. restart: stop, then start. status: processes, children, stray
-# recorders, socket, pause flags and the log's tail; exit 1 if either is
-# down. Run it from the login session: it needs its
-# audio, bus, Wayland display and XDG_RUNTIME_DIR.
+# stop: SIGTERM any running assistant.py, SIGKILL after 10 s. start: run it
+# in its own session, detached from the terminal, logging where the
+# Hyprland autostart does; does nothing for one already running. restart:
+# stop, then start. status: the process, the socket and the log's tail;
+# exit 1 when it is down.
set -eu
dir=$(cd "$(dirname "$0")" && pwd)
log="${XDG_RUNTIME_DIR:?not in a login session}/desktop-assistant.log"
-overlay=$(realpath -m "${OVERLAY:-$dir/../quickshell/assistant}")
pat='^\S*python3 (-u )?\S*assistant\.py'
-qpat="^qs -p $overlay\$"
kill_wait() {
pkill -u "$USER" -f "$1" || return 0
@@ -48,41 +42,27 @@ running() { pgrep -u "$USER" -f "$1" >/dev/null; }
stop() {
kill_wait "$pat"
- kill_wait "$qpat"
}
start() {
cd "$dir"
running "$pat" || setsid -f python3 -u "$dir/assistant.py" >>"$log" 2>&1 </dev/null
- running "$qpat" || setsid -f qs -p "$overlay" >/dev/null 2>&1 </dev/null
sleep 0.5
status
}
-show() {
- local pid
- pid=$(pgrep -u "$USER" -of "$2") || { echo "$1: not running"; return 1; }
- echo "$1: running"
- ps -o pid=,etime=,rss=,args= -p "$pid" |
- awk '{ printf " pid %s, up %s, %d MB\n %s", $1, $2, $3 / 1024, $4
- for (i = 5; i <= NF; i++) printf " %s", $i; print "" }'
- [ "$1" = assistant ] || return 0
- pgrep -a -P "$pid" | sed 's/^/ child /'
-}
-
status() {
- local rc=0 f
- show assistant "$pat" || rc=1
- show overlay "$qpat" || rc=1
- # Children get PDEATHSIG; one left over means the assistant died under it.
- pgrep -u "$USER" -af "^arecord .*desktop-assistant\.raw" | sed 's/^/stray: /' || true
+ local pid
+ if pid=$(pgrep -u "$USER" -of "$pat"); then
+ echo "assistant: running"
+ ps -o pid=,etime=,rss= -p "$pid" | awk '{ printf " pid %s, up %s, %d MB\n", $1, $2, $3 / 1024 }'
+ else
+ echo "assistant: not running"
+ fi
[ -S "$XDG_RUNTIME_DIR/desktop-assistant.sock" ] && echo "socket: present" || echo "socket: missing"
- for f in presentation gaming; do
- [ "$(cat "$XDG_RUNTIME_DIR/status.$f" 2>/dev/null)" = 1 ] && echo "paused: $f mode on"
- done
echo "log: $log"
tail -n 5 "$log" 2>/dev/null | sed 's/^/ /'
- return $rc
+ [ -n "$pid" ]
}
case "${1:-}" in