↓ 跳过正文
  1. 文章/

Ghostty 提示音不响:audio bell vs system bell 排查

Ghostty 音频 PulseAudio Linux 终端

目录
linux - 这篇文章属于一个选集。
§ 7: 本文
发生了什么

在 Ghostty 里按 Tab 补全没有提示音。以为是 Ghostty 的 bug,其实是终端 bell 的两种实现方式在打架。


背景
#

使用claude code 或 codex 时常常遇到等待coding不知道结束没有,这是就需要bell提示音。

我发现在ghostty上是不会提醒的。其他终端(比如 GNOME Terminal)是有的。所以不是系统问题,是 Ghostty 的配置问题。


终端 bell 的两种实现
#

终端的"提示音"有两种:

  1. Audio bell:终端自己播放一个音频文件(.wav 等)
  2. System bell:终端发送一个 BEL 字符(\x07),由系统处理

大多数终端用 system bell——发个 BEL 字符,PulseAudio/PipeWire 播放系统预设的声音。但 Ghostty 默认用 audio bell,它自己找音频文件播放。

为什么 Ghostty 默认用 audio bell

Ghostty 是跨平台的(Linux/macOS/Windows),system bell 的行为在不同系统上不一致。用自己的 audio bell 可以保证跨平台体验一致。但在 Linux 上,这反而可能出问题。


排查
#

1. 确认 bell 字符有发送
#

在 Ghostty 里按 Ctrl+G(这是手动发送 BEL 字符),有没有声音?

没有。

2. 检查 Ghostty 配置
#

cat ~/.config/ghostty/config | grep -i bell

发现没有 bell 相关配置。用默认值。

查 Ghostty 文档,默认是 audio-bell = true。Ghostty 会尝试播放内置的 bell 音频文件。

3. 检查音频系统
#

# PulseAudio/PipeWire 是否正常
pactl info

# 是否有 bell 相关的 sink 输入
pactl list sink-inputs

PipeWire 正常运行。但在按 Ctrl+G 时,pactl list sink-inputs 没有新的 sink input 出现——说明 Ghostty 根本没向音频系统发送声音。

4. 检查 Ghostty 的音频能力
#

# Ghostty 是否能找到 bell 音频文件
strace -e openat ./ghostty 2>&1 | grep -i bell

发现 Ghostty 在找 bell 音频文件,但路径不对——它找的是自己 AppImage 内部的路径,但 FUSE 挂载可能有问题(参考上一篇 AppImage FUSE 文章)。


修复
#

在 Ghostty 配置里明确指定 bell 类型:

# ~/.config/ghostty/config
bell-features = system

这样 Ghostty 会发送 BEL 字符给系统,由 PulseAudio/PipeWire 处理声音。

如果想用 audio bell 但 Ghostty 找不到音频文件,可以手动指定:

# ~/.config/ghostty/config
bell = audio
audio-bell-path = /usr/share/sounds/freedesktop/stereo/bell.oga
验证 bell 是否工作
# 在 Ghostty 里执行
echo -e '\a'

# 或者
tput bel

如果有声音,bell 配置正确。


额外:bash 的 bell 行为
#

bash 本身也有 bell 相关设置:

# 查看当前设置
bind -V | grep bell

# 补全失败时发出 bell
set bell-style audible

# 补全失败时什么都不做
set bell-style none

# 补全失败时闪屏(视觉 bell)
set bell-style visible

如果 Ghostty 的 bell 配好了但 bash 补全还是没声音,检查 bell-style:

echo "set bell-style audible" >> ~/.inputrc

总结
#

问题 原因 修复
Ghostty bell 没声音 默认用 audio bell,但音频文件路径可能不对 改成 bell = system
bash 补全没声音 bell-style 可能设成了 none set bell-style audible
有声音但太小 系统音量设置 pactl set-sink-volume @DEFAULT_SINK@ 100%
linux - 这篇文章属于一个选集。
§ 7: 本文

相关文章