# gpui: Implement audible system bell \(\#47531\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/971775e3b266950fbee99d97b863afe769374321)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 971775e3b266950fbee99d97b863afe769374321

Requested commit: 971775e3b266950fbee99d97b863afe769374321

Commit: 971775e3b266950fbee99d97b863afe769374321

Tree: cfbd507778fa68dec7284d2b2bf1078e9bed7035

Author: Ian Chamberlain

Committer: GitHub

## Message

```
gpui: Implement audible system bell (#47531)

Relates to #5303 and
https://github.com/zed-industries/zed/issues/40826#issuecomment-3684556858
although I haven't found anywhere an actual request for `gpui` itself to
support a system alert sound.

### What

Basically, this PR adds a function that triggers an OS-dependent alert
sound, commonly used by terminal applications for `\a` / `BEL`, and GUI
applications to indicate an action failed in some small way (e.g. no
search results found, unable to move cursor, button disabled).

Also updated the `input` example, which now plays the bell if the user
presses <kbd>backspace</kbd> with nothing behind the cursor to delete,
or <kbd>delete</kbd> with nothing in front of the cursor.

Test with `cargo run --example input --features gpui_platform/font-kit`.

### Why
If this is merged, I plan to take a second step:
- Add a new Zed setting (probably something like
`terminal.audible_bell`)
- If enabled, `printf '\a'`, `tput bel` etc. would call this new API to
play an audible sound

This isn't the super-shiny dream of #5303 but it would allow users to
more easily configure tasks to notify when done. Plus, any TUI/CLI apps
that expect this functionality will work. Also, I think many terminal
users expect something like this (WezTerm, iTerm, etc. almost all
support this).

### Notes
~I was only able to test on macOS and Windows, so if there are any Linux
users who could verify this works for X11 / Wayland that would be a huge
help! If not I can try~

Confirmed Wayland + X11 both working when I ran the example on a NixOS
desktop

Release Notes:

- N/A
```

## Parents

- [4087d9f2ca1d6fec171c6751dbf32adad019acc5](https://git.cafe/gitcafe/zed/commit/4087d9f2ca1d6fec171c6751dbf32adad019acc5?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/971775e3b266950fbee99d97b863afe769374321?format=markdown)
