zed/crates/gpui_linux
Ian Chamberlain 971775e3b2
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
2026-04-01 02:50:01 +00:00
..
src gpui: Implement audible system bell (#47531) 2026-04-01 02:50:01 +00:00
Cargo.toml wGPU: Select more specifically (#50528) 2026-03-02 13:30:40 -07:00
LICENSE-APACHE