#Varsler

cmux støtter skrivebordsvarsler, slik at AI-agenter og skript kan varsle deg når de trenger oppmerksomhet.

#Livssyklus

  1. Mottatt: varselet vises i panelet, skrivebordsvarsel utløses (hvis ikke undertrykt)
  2. Ulest: merke vist på arbeidsområdefanen
  3. Lest: fjernet når du ser på det arbeidsområdet
  4. Fjernet: fjernet fra panelet

#Undertrykking

Skrivebordsvarsler undertrykkes når:

  • cmux-vinduet er fokusert
  • Det spesifikke arbeidsområdet som sender varselet er aktivt
  • Varselpanelet er åpent

#Varselpanel

Trykk ⌘⇧I for å åpne varselpanelet. Klikk et varsel for å hoppe til det arbeidsområdet. Trykk ⌘⇧U for å hoppe direkte til arbeidsområdet med det nyeste uleste varselet.

#Egendefinert kommando

Kjør en shell-kommando hver gang et varsel planlegges. Sett den i Innstillinger > App > Varselkommando. Kommandoen kjøres via /bin/sh -c med disse miljøvariablene:

VariabelBeskrivelse
CMUX_NOTIFICATION_TITLEVarselstittel (arbeidsområdenavn eller appnavn)
CMUX_NOTIFICATION_SUBTITLEVarselsundertittel
CMUX_NOTIFICATION_BODYVarselsbrødtekst
Examples
# 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.log

Kommandoen kjøres uavhengig av systemlydvelgeren. Sett velgeren til "Ingen" for å kun bruke den egendefinerte kommandoen, eller behold begge for en systemlyd pluss en egendefinert handling.

#Varslings-hooks

cmux.json kan definere varslings-hooks som mottar hver varslingspolicy som JSON på stdin. Hver hook returnerer JSON på stdout. Hooks er av som standard; cmux kjører dem bare når notifications.hooks inneholder minst én aktivert hook. cmux bruker den returnerte varslingsteksten og effektene, slik at hooks kan filtrere bannere, beholde eller hoppe over sidepanelhistorikk, spille av lyder eller stoppe senere hooks.

cmux.json
{
  "notifications": {
    "hooks": [
      {
        "id": "quiet-docs",
        "command": "sed 's/"desktop":true/"desktop":false/'",
        "timeoutSeconds": 20
      }
    ]
  }
}
Hook-inndata og -utdata
{
  "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
  },
  "effects": {
    "record": true,
    "markUnread": true,
    "reorderWorkspace": true,
    "desktop": true,
    "sound": true,
    "command": true,
    "paneFlash": true
  }
}

Hooks arves fra global ~/.config/cmux/cmux.json og prosjektfilene .cmux/cmux.json fra overordnede mapper til gjeldende workspace. Prosjekt-hooks bruker samme tillitsdialog som andre prosjektkommandoer i cmux.json før de kjører. Feed-godkjenningsbannere går også gjennom disse hookene; å deaktivere desktop skjuler det innebygde banneret mens Feed-elementet fortsatt er tilgjengelig i cmux. Sett notifications.hooksMode til replace i en prosjektkonfigurasjon for å ignorere arvede hooks. Hvis en hook feiler, får tidsavbrudd eller returnerer ugyldig JSON, bruker cmux standard varslingsatferd og viser et hook-feilvarsel.

#Sende varsler

#CLI

cmux notify --title "Task Complete" --body "Your build finished"
cmux notify --title "Claude Code" --subtitle "Waiting" --body "Agent needs input"

#OSC 777 (enkel)

RXVT-protokollen bruker et fast format med tittel og brødtekst:

printf '\e]777;notify;My Title;Message body here\a'
Shell function
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 (rik)

Kitty-protokollen støtter undertitler og varsel-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\\'
FunksjonOSC 99OSC 777
Tittel + brødtekstJaJa
UndertittelJaNei
Varsel-IDJaNei
KompleksitetHøyereLavere
Bruk OSC 777 for enkle varsler. Bruk OSC 99 når du trenger undertitler eller varsel-ID-er. Bruk CLI (cmux notify) for enklest integrasjon.

#Claude Code hooks

cmux integrerer med Claude Code via hooks for å varsle deg når oppgaver fullføres.

#1. Opprett hook-skriptet

~/.claude/hooks/cmux-notify.sh
#!/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"
        ;;
esac
chmod +x ~/.claude/hooks/cmux-notify.sh

#2. Konfigurer Claude Code

~/.claude/settings.json
{
  "hooks": {
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/cmux-notify.sh"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Task",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/cmux-notify.sh"
          }
        ]
      }
    ]
  }
}

Start Claude Code på nytt for å bruke hooksene.

#GitHub Copilot CLI

Copilot CLI støtter hooks som kjører shell-kommandoer ved livssyklushendelser som prompt-innsending, agent-stopp og feil.

~/.copilot/config.json
{
  "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-nivå, opprett en .github/hooks/notify.json-fil med samme struktur:

.github/hooks/notify.json
{
  "version": 1,
  "hooks": {
    "userPromptSubmitted": [ ... ],
    "agentStop": [ ... ]
  }
}

#Integrasjonseksempler

#Varsel etter lang kommando

~/.zshrc
# 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

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

node
function notify(title, body) {
  process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
}

notify('Build Done', 'webpack finished');

#tmux-passthrough

Hvis du bruker tmux inne i cmux, aktiver passthrough:

.tmux.conf
set -g allow-passthrough on
printf '\ePtmux;\e\e]777;notify;Title;Body\a\e\\'