# ជូនដំណឹង

cmux គាំទ្រជូនដំណឹងផ្ទៃតុ, អនុញ្ញាតឱ្យ AI agent និងស្គ្រីបជូនដំណឹងអ្នកនៅពេលពួកវាត្រូវការការយកចិត្តទុកដាក់។

## វដ្តជីវិត

1.  បានទទួល: ជូនដំណឹងបង្ហាញក្នុង panel, ការជូនដំណឹងផ្ទៃតុដំណើរការ (ប្រសិនបើមិនត្រូវបានបង្ហាប់)
2.  មិនទាន់អាន: ស្លាកបង្ហាញនៅលើផ្ទាំង workspace
3.  បានអាន: សម្អាតនៅពេលអ្នកមើល workspace នោះ
4.  បានសម្អាត: លុបចេញពី panel

### ការបង្ហាប់

ការជូនដំណឹងផ្ទៃតុត្រូវបានបង្ហាប់នៅពេល:

-   បង្អួច cmux កំពុងផ្ដោត
-   workspace ជាក់លាក់ដែលផ្ញើជូនដំណឹងកំពុងដំណើរការ
-   ផ្ទាំងជូនដំណឹងកំពុងបើក

### ផ្ទាំងជូនដំណឹង

ចុច `⌘⇧I` ដើម្បីបើកផ្ទាំងជូនដំណឹង។ ចុចជូនដំណឹងដើម្បីលោតទៅ workspace នោះ។ ចុច `⌘⇧U` ដើម្បីលោតផ្ទាល់ទៅ workspace ដែលមានជូនដំណឹងមិនទាន់អានថ្មីបំផុត។

## ពាក្យបញ្ជាផ្ទាល់ខ្លួន

ដំណើរការពាក្យបញ្ជា shell រាល់ពេលជូនដំណឹងត្រូវបានកំណត់។ កំណត់វាក្នុងការកំណត់ > កម្មវិធី > ពាក្យបញ្ជាជូនដំណឹង។ ពាក្យបញ្ជាដំណើរការតាមរយៈ /bin/sh -c ជាមួយអថេរបរិស្ថានទាំងនេះ:

| អថេរ | ការពិពណ៌នា |
| --- | --- |
| `CMUX_NOTIFICATION_TITLE` | ចំណងជើងជូនដំណឹង (ឈ្មោះ workspace ឬឈ្មោះកម្មវិធី) |
| `CMUX_NOTIFICATION_SUBTITLE` | ចំណងជើងរងជូនដំណឹង |
| `CMUX_NOTIFICATION_BODY` | អត្ថបទមាតិកាជូនដំណឹង |

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
```

ពាក្យបញ្ជាដំណើរការដោយឯករាជ្យពីឧបករណ៍ជ្រើសរើសសម្លេងប្រព័ន្ធ។ កំណត់ឧបករណ៍ជ្រើសរើសទៅ "គ្មាន" ដើម្បីប្រើតែពាក្យបញ្ជាផ្ទាល់ខ្លួន ឬរក្សាទាំងពីរសម្រាប់សម្លេងប្រព័ន្ធនិងសកម្មភាពផ្ទាល់ខ្លួន។

## Notification hooks

`cmux.json` can define notification hooks that receive every notification policy as JSON on stdin. Each hook returns JSON on stdout. Hooks are off by default; cmux only runs them when `notifications.hooks` contains at least one enabled hook. cmux applies the returned notification text and effects, so hooks can filter banners, keep or skip sidebar history, run sounds, or stop later hooks.

cmux.json

```
{
  "notifications": {
    "hooks": [
      {
        "id": "quiet-docs",
        "command": "sed 's/"desktop":true/"desktop":false/'",
        "timeoutSeconds": 20
      }
    ]
  }
}
```

Hook input and output

```
{
  "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 are inherited from global `~/.config/cmux/cmux.json` and project `.cmux/cmux.json` files from parent directories to the current workspace. Project hooks use the same trust prompt as other project `cmux.json` commands before they run. Feed approval banners also pass through these hooks; disabling `desktop` suppresses the native banner while keeping the Feed item available in cmux. Set `notifications.hooksMode` to `replace` in a project config to ignore inherited hooks. If a hook fails, times out, or returns invalid JSON, cmux uses the default notification behavior and posts a hook failure alert.

### 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:

Silence subagent completions

```
{
  "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.

## ការផ្ញើជូនដំណឹង

### CLI

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

### OSC 777 (សាមញ្ញ)

ពិធីការ RXVT ប្រើទម្រង់ថេរជាមួយចំណងជើងនិងមាតិកា:

```
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 (សម្បូរ)

ពិធីការ Kitty គាំទ្រចំណងជើងរង និង ID ជូនដំណឹង:

```
# 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\\'
```

| មុខងារ | OSC 99 | OSC 777 |
| --- | --- | --- |
| ចំណងជើង + មាតិកា | បាទ/ចាស | បាទ/ចាស |
| ចំណងជើងរង | បាទ/ចាស | ទេ |
| ID ជូនដំណឹង | បាទ/ចាស | ទេ |
| ភាពស្មុគស្មាញ | ខ្ពស់ជាង | ទាបជាង |

ប្រើ OSC 777 សម្រាប់ជូនដំណឹងសាមញ្ញ។ ប្រើ OSC 99 នៅពេលអ្នកត្រូវការចំណងជើងរង ឬ ID ជូនដំណឹង។ ប្រើ CLI (cmux notify) សម្រាប់ការរួមបញ្ចូលងាយស្រួលបំផុត។

## Claude Code hooks

cmux រួមបញ្ចូលជាមួយ [Claude Code](https://docs.anthropic.com/en/docs/claude-code) តាមរយៈ hooks ដើម្បីជូនដំណឹងអ្នកនៅពេលភារកិច្ចបានបញ្ចប់។

### 1\. បង្កើត hook script

~/.claude/hooks/cmux-notify.sh

```
#!/bin/bash
# Outside cmux there is no socket to talk to, so do nothing.
[ -S /tmp/cmux.sock ] || exit 0

payload=$(cat)
field() { printf '%s' "$payload" | jq -r "$1 // empty"; }

event=$(field .hook_event_name)
if [ "$event" = "Stop" ]; then
    cmux notify --title "Claude Code" --body "Session complete"
elif [ "$event" = "SubagentStop" ]; then
    cmux notify --title "Claude Code" --body "Agent finished"
fi
```

```
chmod +x ~/.claude/hooks/cmux-notify.sh
```

### 2\. កំណត់រចនាសម្ព័ន្ធ Claude Code

~/.claude/settings.json

```
{
  "hooks": {
    "SubagentStop": [
      {
        "hooks": [{ "type": "command", "command": "~/.claude/hooks/cmux-notify.sh" }]
      }
    ],
    "Stop": [
      {
        "hooks": [{ "type": "command", "command": "~/.claude/hooks/cmux-notify.sh" }]
      }
    ]
  }
}
```

ចាប់ផ្ដើម Claude Code ឡើងវិញដើម្បីអនុវត្ត hooks។

## GitHub Copilot CLI

Copilot CLI គាំទ្រ[hooks](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/use-hooks) ដែលដំណើរការពាក្យបញ្ជា shell នៅព្រឹត្តិការណ៍វដ្តជីវិតដូចជាការបញ្ជូន prompt ការបញ្ឈប់ agent និងកំហុស។

~/.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
      }
    ]
  }
}
```

សម្រាប់ hooks កម្រិត repo សូមបង្កើតឯកសារ .github/hooks/notify.json ដោយមានរចនាសម្ព័ន្ធដូចគ្នា:

.github/hooks/notify.json

```
{
  "version": 1,
  "hooks": {
    "userPromptSubmitted": [ ... ],
    "agentStop": [ ... ]
  }
}
```

## ឧទាហរណ៍ការរួមបញ្ចូល

### ជូនដំណឹងបន្ទាប់ពីពាក្យបញ្ជាយូរ

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

ប្រសិនបើប្រើ tmux ក្នុង cmux, បើក passthrough:

.tmux.conf

```
set -g allow-passthrough on
```

```
printf '\ePtmux;\e\e]777;notify;Title;Body\a\e\\'
```

Canonical: https://cmux.com/km/docs/notifications

Documentation index: https://cmux.com/llms.txt
