feat(notify): Desktop-Benachrichtigung für den Ruhezeit-Toast
quiet_mode = "toast" war bisher nur eine Protokollzeile. Jetzt zeigt der Daemon eine Desktop-Benachrichtigung — über die Bordmittel des Systems, exec-basiert wie osbuiltin, ohne Bibliothek und ohne CGO: notify-send (Linux), osascript display notification (macOS), PowerShell Toast (Windows; Text base64, kein Quoting-Problem). Best effort: fehlt das Werkzeug, bleibt es bei der Protokollzeile plus Start-Warnung; `talk doctor` zeigt den Weg unter „Toast". Der Aufruf läuft asynchron, ein hängender Notification-Daemon blockiert die Queue nie. Queue: OnToast-Hook, gefeuert bei Toast-Verwurf beim Eintritt und im Worker (nie unter dem Mutex). Tests: notify-Paket mit fake notify-send im PATH, Prozessgrenze: Ruhezeit + toast → fake notify-send bekommt Titel und Text, der Provider keinen Treffer. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
a9ca32bed9
commit
9e2aa506a6
7 files changed
+279
-6
No files matched your search
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"code.m3ta.dev/m3tam3re/talk/internal/api"
|
||||
"code.m3ta.dev/m3tam3re/talk/internal/config"
|
||||
"code.m3ta.dev/m3tam3re/talk/internal/notify"
|
||||
"code.m3ta.dev/m3tam3re/talk/internal/provider"
|
||||
"code.m3ta.dev/m3tam3re/talk/internal/queue"
|
||||
"code.m3ta.dev/m3tam3re/talk/internal/speak"
|
||||
@@ -103,6 +104,23 @@ func Run(ctx context.Context, opts Options) error {
|
||||
return err
|
||||
}, lw)
|
||||
|
||||
// Ruhezeit-Toast: Desktop-Benachrichtigung statt Audio (quiet_mode =
|
||||
// "toast"); best effort, Fehler nur im Protokoll. Läuft asynchron, damit
|
||||
// ein hängender Notification-Daemon nie die Queue blockiert.
|
||||
if cfg.QuietMode == queue.QuietModeToast {
|
||||
if notify.Available() {
|
||||
q.OnToast(func(item queue.Item) {
|
||||
go func() {
|
||||
if err := notify.Show(context.Background(), item.Text); err != nil {
|
||||
logger.Printf("toast: %v", err)
|
||||
}
|
||||
}()
|
||||
})
|
||||
} else {
|
||||
logger.Printf("warnung: quiet_mode = toast, aber %s — Ruhezeit-Ansagen werden nur protokolliert", notify.Describe())
|
||||
}
|
||||
}
|
||||
|
||||
// Persistenter Mute-State und PID-Datei im Config-Dir. Ohne Config-Dir
|
||||
// läuft der Daemon ohne beides weiter (Warnung) statt zu scheitern.
|
||||
var mutePath, pidPath string
|
||||
|
||||
Reference in new issue
Block a user