feat(notifications): notify when long commands finish, with duration and exit status #37

Merged
BlackAngelTV merged 4 commits from feat/cmd-finish-notifications into main 2026-11-12 07:24:20 +01:00
Owner

Fixes #29

Ce que fait cette branche

L'essentiel de la demande existait déjà dans le fork : l'OSC 133;D;<code> est émis par les hooks bash, zsh et fish, l'option notify_on_cmd_finish gère les politiques never / unfocused / invisible / always avec un seuil de durée, et l'envoi passe par D-Bus (glfw/linux_notify.c + kitty/notifications.py), donc identique sous X11 et Wayland. Cette branche comble les manques constatés et rend la fonctionnalité utilisable sans configuration.

  • fix(notifications) : le statut affiché est celui réellement parsé, donc un shell qui termine une commande avec un 133;D nu n'affiche plus finished with status: . ni un %s vide dans l'action command.
  • feat(notifications) : la durée d'exécution apparaît enfin dans le texte (420ms, 5.0s, 1m 30s, 2h 2m), à côté de la ligne de commande et du code de sortie — elle était mesurée pour le seuil mais jamais montrée.
  • feat(options) : notify_on_cmd_finish passe de never à unfocused par défaut (seuil 5 s, action notify), pour que la fonctionnalité marche directement après un build, sans option en ligne de commande ni kitty.conf.
  • docs : documentation de l'option (contenu de la notification) et entrée de changelog.

Pas de nouvel OSC dédié durée + statut : 133;D porte déjà le code de sortie et kitty chronomètre de 133;C à 133;D, un code supplémentaire aurait obligé à modifier les trois scripts d'intégration shell pour la même information.

Comportement par défaut

Une commande de plus de 5 secondes qui se termine alors que son terminal n'a pas le focus (autre onglet ou autre fenêtre) déclenche « Command make -j8 finished in 42.7s with status: 0. ». Fenêtre focalisée, ou commande plus courte : aucune notification. notify_on_cmd_finish never désactive tout.

Vérifications

  • python3 test.py test_command_finish_duration_formatting : OK (bornes millisecondes / secondes / minutes / heures)
  • python3 test.py test_desktop_notify : OK (pas de régression sur la chaîne de notifications)
  • défaut réellement chargé par le binaire : NotifyOnCmdFinish(when='unfocused', duration=5.0, action='notify', ...), definition.py et types.py concordent

Limite : la notification n'a pas été observée à l'écran pendant le développement ; seuls le formatage, le filtrage focus et la chaîne D-Bus sont couverts.

Fixes #29 ## Ce que fait cette branche L'essentiel de la demande existait déjà dans le fork : l'OSC `133;D;<code>` est émis par les hooks bash, zsh et fish, l'option `notify_on_cmd_finish` gère les politiques `never` / `unfocused` / `invisible` / `always` avec un seuil de durée, et l'envoi passe par D-Bus (`glfw/linux_notify.c` + `kitty/notifications.py`), donc identique sous X11 et Wayland. Cette branche comble les manques constatés et rend la fonctionnalité utilisable sans configuration. - `fix(notifications)` : le statut affiché est celui réellement parsé, donc un shell qui termine une commande avec un `133;D` nu n'affiche plus `finished with status: .` ni un `%s` vide dans l'action `command`. - `feat(notifications)` : la durée d'exécution apparaît enfin dans le texte (`420ms`, `5.0s`, `1m 30s`, `2h 2m`), à côté de la ligne de commande et du code de sortie — elle était mesurée pour le seuil mais jamais montrée. - `feat(options)` : `notify_on_cmd_finish` passe de `never` à `unfocused` par défaut (seuil 5 s, action `notify`), pour que la fonctionnalité marche directement après un build, sans option en ligne de commande ni `kitty.conf`. - `docs` : documentation de l'option (contenu de la notification) et entrée de changelog. Pas de nouvel OSC dédié durée + statut : `133;D` porte déjà le code de sortie et kitty chronomètre de `133;C` à `133;D`, un code supplémentaire aurait obligé à modifier les trois scripts d'intégration shell pour la même information. ## Comportement par défaut Une commande de plus de 5 secondes qui se termine alors que son terminal n'a pas le focus (autre onglet ou autre fenêtre) déclenche « Command make -j8 finished in 42.7s with status: 0. ». Fenêtre focalisée, ou commande plus courte : aucune notification. `notify_on_cmd_finish never` désactive tout. ## Vérifications - `python3 test.py test_command_finish_duration_formatting` : OK (bornes millisecondes / secondes / minutes / heures) - `python3 test.py test_desktop_notify` : OK (pas de régression sur la chaîne de notifications) - défaut réellement chargé par le binaire : `NotifyOnCmdFinish(when='unfocused', duration=5.0, action='notify', ...)`, `definition.py` et `types.py` concordent Limite : la notification n'a pas été observée à l'écran pendant le développement ; seuls le formatage, le filtrage focus et la chaîne D-Bus sont couverts.
BlackAngelTV added 4 commits 2026-11-11 11:12:56 +01:00
A shell that ends a command with a bare OSC 133;D leaves the raw status string
empty, so the notification said "finished with status: ." and the command action
got an empty %s. Use the status already parsed for the event instead.
The duration was measured to decide whether a command was long enough to
warrant a notification, but it was never shown, so the notification could only
say that the command had ended. Report it next to the exit status, formatted
in milliseconds, seconds, minutes or hours depending on the length.
Mention the command line, the duration and the exit status in the option
documentation and record the new duration in the changelog.
The notification only happened if notify_on_cmd_finish was passed on the
command line or written in kitty.conf, so a fresh build looked like it had no
such feature at all. Long-running commands now notify by default once the
window loses focus; the 5 second threshold keeps short commands silent.
BlackAngelTV added this to the FWS - KITTY project 2026-11-11 11:16:30 +01:00
BlackAngelTV added the Kind/Feature label 2026-11-11 11:16:45 +01:00
BlackAngelTV moved this to In progress in FWS - KITTY on 2026-11-11 11:17:10 +01:00
angi was assigned by BlackAngelTV 2026-11-11 11:17:48 +01:00
nocode was assigned by BlackAngelTV 2026-11-11 11:17:49 +01:00
BlackAngelTV merged commit 5cc8785eba into main 2026-11-12 07:24:20 +01:00
BlackAngelTV deleted branch feat/cmd-finish-notifications 2026-11-12 07:33:41 +01:00
BlackAngelTV moved this to DONE in FWS - KITTY on 2026-11-12 12:21:39 +01:00
Sign in to join this conversation.
No Reviewers
No labels Kind/Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: FWS/FWS-Kitty#37