Notifications
cmux supporte les notifications bureau, permettant aux agents IA et aux scripts de vous alerter quand ils ont besoin d'attention.
Cycle de vie
- Reçue : la notification apparaît dans le panneau, l'alerte bureau se déclenche (si non supprimée)
- Non lue : badge affiché sur l'onglet de l'espace de travail
- Lue : effacée quand vous consultez cet espace de travail
- Effacée : supprimée du panneau
Suppression
Les alertes bureau sont supprimées quand :
- La fenêtre cmux est active
- L'espace de travail spécifique qui envoie la notification est actif
- Le panneau de notifications est ouvert
Panneau de notifications
Appuyez sur ⌘⇧I pour ouvrir le panneau de notifications. Cliquez sur une notification pour aller à cet espace de travail. Appuyez sur ⌘⇧U pour aller directement à l'espace de travail avec la notification non lue la plus récente.
Commande personnalisée
Exécutez une commande shell à chaque fois qu'une notification est planifiée. Définissez-la dans Réglages > App > Commande de notification. La commande s'exécute via /bin/sh -c avec ces variables d'environnement :
| Variable | Description |
|---|---|
CMUX_NOTIFICATION_TITLE | Titre de la notification (nom de l'espace de travail ou nom de l'app) |
CMUX_NOTIFICATION_SUBTITLE | Sous-titre de la notification |
CMUX_NOTIFICATION_BODY | Texte du corps de la notification |
# Text-to-speech
say "$CMUX_NOTIFICATION_TITLE"
# Custom sound file
afplay /path/to/sound.aiff
# Log to file
echo "$CMUX_NOTIFICATION_TITLE: $CMUX_NOTIFICATION_BODY" >> ~/notifications.logLa commande s'exécute indépendamment du sélecteur de son système. Définissez le sélecteur sur « Aucun » pour utiliser uniquement la commande personnalisée, ou gardez les deux pour un son système plus une action personnalisée.
Envoyer des notifications
CLI
cmux notify --title "Task Complete" --body "Your build finished"
cmux notify --title "Claude Code" --subtitle "Waiting" --body "Agent needs input"OSC 777 (simple)
Le protocole RXVT utilise un format fixe avec titre et corps :
printf '\e]777;notify;My Title;Message body here\a'notify_osc777() {
local title="$1"
local body="$2"
printf '\e]777;notify;%s;%s\a' "$title" "$body"
}
notify_osc777 "Build Complete" "All tests passed"OSC 99 (riche)
Le protocole Kitty supporte les sous-titres et les IDs de notification :
# Format: ESC ] 99 ; <params> ; <payload> ESC \
# Simple notification
printf '\e]99;i=1;e=1;d=0:Hello World\e\\'
# With title, subtitle, and body
printf '\e]99;i=1;e=1;d=0;p=title:Build Complete\e\\'
printf '\e]99;i=1;e=1;d=0;p=subtitle:Project X\e\\'
printf '\e]99;i=1;e=1;d=1;p=body:All tests passed\e\\'| Fonctionnalité | OSC 99 | OSC 777 |
|---|---|---|
| Titre + corps | Oui | Oui |
| Sous-titre | Oui | Non |
| ID de notification | Oui | Non |
| Complexité | Plus élevée | Plus basse |
Hooks Claude Code
cmux s'intègre avec Claude Code via des hooks pour vous notifier quand les tâches sont terminées.
1. Créer le script de hook
#!/bin/bash
# Skip if not in cmux
[ -S /tmp/cmux.sock ] || exit 0
EVENT=$(cat)
EVENT_TYPE=$(echo "$EVENT" | jq -r '.hook_event_name // "unknown"')
TOOL=$(echo "$EVENT" | jq -r '.tool_name // ""')
case "$EVENT_TYPE" in
"Stop")
cmux notify --title "Claude Code" --body "Session complete"
;;
"PostToolUse")
[ "$TOOL" = "Task" ] && cmux notify --title "Claude Code" --body "Agent finished"
;;
esacchmod +x ~/.claude/hooks/cmux-notify.sh2. Configurer Claude Code
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/cmux-notify.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Task",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/cmux-notify.sh"
}
]
}
]
}
}Redémarrez Claude Code pour appliquer les hooks.
GitHub Copilot CLI
Copilot CLI prend en charge les hooks qui exécutent des commandes shell lors d'événements du cycle de vie comme la soumission de prompts, l'arrêt de l'agent et les erreurs.
{
"hooks": {
"userPromptSubmitted": [
{
"type": "command",
"bash": "if command -v cmux &>/dev/null; then cmux set-status copilot_cli Running; fi",
"timeoutSec": 3
}
],
"agentStop": [
{
"type": "command",
"bash": "if command -v cmux &>/dev/null; then cmux notify --title 'Copilot CLI' --body 'Done'; cmux set-status copilot_cli Idle; fi",
"timeoutSec": 5
}
],
"errorOccurred": [
{
"type": "command",
"bash": "if command -v cmux &>/dev/null; then cmux notify --title 'Copilot CLI' --subtitle 'Error' --body 'An error occurred'; cmux set-status copilot_cli Error; fi",
"timeoutSec": 5
}
],
"sessionEnd": [
{
"type": "command",
"bash": "if command -v cmux &>/dev/null; then cmux clear-status copilot_cli; fi",
"timeoutSec": 3
}
]
}
}Pour les hooks au niveau du dépôt, créez un fichier .github/hooks/notify.json avec la même structure :
{
"version": 1,
"hooks": {
"userPromptSubmitted": [ ... ],
"agentStop": [ ... ]
}
}Exemples d'intégration
Notifier après une longue commande
# Add to your shell config
notify-after() {
"$@"
local exit_code=$?
if [ $exit_code -eq 0 ]; then
cmux notify --title "✓ Command Complete" --body "$1"
else
cmux notify --title "✗ Command Failed" --body "$1 (exit $exit_code)"
fi
return $exit_code
}
# Usage: notify-after npm run buildPython
import sys
def notify(title: str, body: str):
"""Send OSC 777 notification."""
sys.stdout.write(f'\x1b]777;notify;{title};{body}\x07')
sys.stdout.flush()
notify("Script Complete", "Processing finished")Node.js
function notify(title, body) {
process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
}
notify('Build Done', 'webpack finished');Passthrough tmux
Si vous utilisez tmux dans cmux, activez le passthrough :
set -g allow-passthrough onprintf '\ePtmux;\e\e]777;notify;Title;Body\a\e\\'