# Desktop Notification (OSC 9)

> Ask the terminal to show a desktop notification.

- **Sequence:** `OSC 9 ; Pt ST`
- **ECMA-48:** [§8.3.89 OSC – Operating System Command, p. 51](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n64/mode/1up)
- **Specification:** [Post a notification, iTerm2 documentation](https://iterm2.com/documentation-escape-codes.html)

`OSC 9 ; Pt ST` asks the terminal to show `Pt` in a notification on the
desktop, for instance when a long build finishes. It is iTerm2's, in its
[escape code documentation](https://iterm2.com/documentation-escape-codes.html).
A notification with a title as well is
[`OSC 777 ; notify ; title ; body ST`](https://control-codes.page/osc/rxvt/index.html.md), and kitty has its own,
richer [`OSC 99`](https://control-codes.page/osc/kitty/index.html.md).

`OSC 9` is also used by ConEmu, on Windows, for its own commands, each a
number after the `9`, the best known of which is the
[progress report](https://control-codes.page/osc/conemu/index.html.md), `OSC 9 ; 4`. A terminal that has both tells
them apart by what follows the `9`: one of ConEmu's numbers and a `;`, or
text.

It is not xterm's, and a default xterm ignores it
([the OSC numbers it knows](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L3476-L3504)).
The cases follow xterm.

libghostty-vt passes it to its host through the `DESKTOP_NOTIFICATION`
callback, which the runner does not install. What a case can see is that it
prints nothing, answers nothing and does not ring the bell, and
libghostty-vt passes.

## Validation

### OSC9-1: A notification changes nothing on screen

Input, one step per line:

```text
A
\e]9;Build finished\a
B
```

Expected screen:

```text
|AB____|
cursor 1,3
reply none
bell 0
```

---

This is the Markdown version of <https://control-codes.page/osc/notify/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
