#Notifikationer
cmux understøtter desktopnotifikationer, der giver AI-agenter og scripts mulighed for at advare dig når de har brug for opmærksomhed.
#Livscyklus
- Modtaget: notifikation vises i panelet, desktopalert udløses (hvis ikke undertrykt)
- Ulæst: badge vises på workspace-fanen
- Læst: ryddes når du ser det workspace
- Ryddet: fjernet fra panelet
#Undertrykkelse
Desktopalarmer undertrykkes når:
- cmux-vinduet er fokuseret
- Det specifikke workspace der sender notifikationen er aktivt
- Notifikationspanelet er åbent
#Notifikationspanel
Tryk ⌘⇧I for at åbne notifikationspanelet. Klik på en notifikation for at springe til det workspace. Tryk ⌘⇧U for at springe direkte til workspace med den seneste ulæste notifikation.
#Brugerdefineret kommando
Kør en shell-kommando hver gang en notifikation planlægges. Indstil det i Indstillinger > App > Notifikationskommando. Kommandoen kører via /bin/sh -c med disse miljøvariabler:
| Variabel | Beskrivelse |
|---|---|
CMUX_NOTIFICATION_TITLE | Notifikationstitel (workspace-navn eller appnavn) |
CMUX_NOTIFICATION_SUBTITLE | Notifikationsundertitel |
CMUX_NOTIFICATION_BODY | Notifikationstekst |
# 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.logKommandoen kører uafhængigt af systemlydvælgeren. Sæt vælgeren til "Ingen" for kun at bruge den brugerdefinerede kommando, eller behold begge for en systemlyd plus en brugerdefineret handling.
#Notifikations-hooks
cmux.json kan definere notifikations-hooks, som modtager hver notifikationspolitik som JSON på stdin. Hvert hook returnerer JSON på stdout. Hooks er slået fra som standard; cmux kører dem kun, når notifications.hooks indeholder mindst ét aktiveret hook. cmux anvender den returnerede notifikationstekst og effekter, så hooks kan filtrere bannere, beholde eller springe sidebjælkens historik over, afspille lyde eller stoppe senere hooks.
{
"notifications": {
"hooks": [
{
"id": "quiet-docs",
"command": "sed 's/"desktop":true/"desktop":false/'",
"timeoutSeconds": 20
}
]
}
}{
"version": 1,
"notification": {
"workspaceId": "3B3F0D83-...",
"surfaceId": "7E9C1A02-...",
"title": "Codex",
"subtitle": "Waiting",
"body": "Agent needs input"
},
"context": {
"cwd": "/path/to/project",
"configPath": "/path/to/project/.cmux/cmux.json",
"hookId": "quiet-docs",
"appFocused": false,
"focusedPanel": false
},
"agent": {
"kind": "claude",
"category": "turn-complete",
"pending": false,
"isSubagent": true
},
"effects": {
"record": true,
"markUnread": true,
"reorderWorkspace": true,
"desktop": true,
"sound": true,
"command": true,
"paneFlash": true
}
}Hooks nedarves fra den globale ~/.config/cmux/cmux.json og projektets .cmux/cmux.json-filer fra overordnede mapper til det aktuelle workspace. Projekt-hooks bruger samme tillidsprompt som andre projektkommandoer i cmux.json, før de kører. Feed-godkendelsesbannere går også gennem disse hooks; deaktivering af desktop skjuler det native banner, mens Feed-elementet stadig er tilgængeligt i cmux. Sæt notifications.hooksMode til replace i en projektkonfiguration for at ignorere nedarvede hooks. Hvis et hook fejler, får timeout eller returnerer ugyldig JSON, bruger cmux standardnotifikationsadfærden og viser en hook-fejladvarsel.
#Agent-event context
Notifications that originate from an agent completion signal carry a read-only agent object: kind is the stable lowercase agent slug (claude, codex, grok, …), category is turn-complete, needs-permission, or idle-reminder, pending is true when the turn ended with background work still running, and isSubagent is true for nested subagent sessions. The object is omitted for non-agent notifications, and the same values are exported to the hook process as CMUX_NOTIFICATION_AGENT_KIND, CMUX_NOTIFICATION_AGENT_CATEGORY, CMUX_NOTIFICATION_AGENT_PENDING, and CMUX_NOTIFICATION_AGENT_IS_SUBAGENT. For example, this hook silences the banner, sound, and pane flash for subagent completions while leaving everything else untouched:
{
"notifications": {
"hooks": [
{
"id": "mute-subagent-completions",
"command": "if [ \"${CMUX_NOTIFICATION_AGENT_IS_SUBAGENT-0}\" = \"1\" ] && [ \"$CMUX_NOTIFICATION_AGENT_CATEGORY\" = \"turn-complete\" ]; then printf '{\"effects\":{\"desktop\":false,\"sound\":false,\"paneFlash\":false}}'; fi"
}
]
}
}With no hooks configured, notification behavior is exactly cmux's built-in default — configuring a hook is the explicit opt-in that hands the delivery decision to your script. Note that cmux's built-in subagent suppression (automation.suppressSubagentNotifications, on by default) drops subagent completion events before they reach hooks; turn it off if your hook should see subagent events and make its own decision.
#Afsendelse af notifikationer
#CLI
cmux notify --title "Task Complete" --body "Your build finished"
cmux notify --title "Claude Code" --subtitle "Waiting" --body "Agent needs input"#OSC 777 (simpel)
RXVT-protokollen bruger et fast format med titel og brødtekst:
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 (avanceret)
Kitty-protokollen understøtter undertitler og notifikations-ID'er:
# 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\\'| Funktion | OSC 99 | OSC 777 |
|---|---|---|
| Titel + tekst | Ja | Ja |
| Undertitel | Ja | Nej |
| Notifikations-ID | Ja | Nej |
| Kompleksitet | Højere | Lavere |
#Claude Code hooks
cmux integrerer med Claude Code via hooks for at notificere dig når opgaver er fuldført.
#1. Opret hook-scriptet
#!/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.sh#2. Konfigurér 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"
}
]
}
]
}
}Genstart Claude Code for at anvende hooks.
#GitHub Copilot CLI
Copilot CLI understøtter hooks, der kører shell-kommandoer ved livscyklushændelser som prompt-indsendelse, agent-stop og fejl.
{
"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
}
]
}
}For hooks på repo-niveau, opret en .github/hooks/notify.json-fil med samme struktur:
{
"version": 1,
"hooks": {
"userPromptSubmitted": [ ... ],
"agentStop": [ ... ]
}
}#Integrationseksempler
#Notificér efter lang kommando
# 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 build#Python
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');#tmux passthrough
Hvis du bruger tmux inde i cmux, aktivér passthrough:
set -g allow-passthrough onprintf '\ePtmux;\e\e]777;notify;Title;Body\a\e\\'