Let the (terminal) bells ring out

2023Q4.
I simply wished to take a couple of minutes to argue that the venerable terminal bell
is a useful and maybe missed device for anybody who does loads of their
work out of a terminal window. First, an necessary clarification. Bells
ringing, chiming, or (as is acceptable for the season) jingling all sounds
very noisy – however though you may configure your terminal emulator to make
noise for the terminal bell, I am really advocating for configuring a
non-intrusive however persistent visible notification.
BEL
Our goal is to generate a visual indicator on demand (e.g. when a long-running
task has finished) and to do so with minimal fuss. This should work over ssh
and without worrying about forwarding connections to some notification
daemon. The ASCII BEL
control character (alternatively written as BELL
by
those willing to spend characters extravagantly) meets these requirements.
You’ll just need co-operation from your terminal emulator and window manager
to convert the bell to an appropriate notification.
BEL
is 7
in ASCII, but can be printed using a
in printf
(including
the /usr/bin/printf
you likely use from your shell, defined in
POSIX).
There’s even a Rosetta Code
page
on ringing the terminal bell from varied languages. Personally, I wish to
outline a shell alias similar to:
alias bell="printf 'aBELL!n'"
Printing some textual content alongside the bell is useful for confirming the bell was
triggered as anticipated even after it was dismissed. Then, if kicking off an extended
operation like an LLVM compile and check use one thing like:
cmake --build . && ./bin/llvm-lit -s check; bell
The ;
ensures the bell is produced whatever the exit code of the
earlier instructions. All being properly, this units the pressing trace on the X11 window
utilized by your terminal, and your window supervisor produces a delicate however
persistent visible indicator that’s dismissed after you subsequent give focus to the
supply of the bell. This is the way it appears to be like for me in
DWM:
The above instance reveals 9 workspaces (a few of them named), the place the llvm
workspace has been highlighted as a result of a bell was produced there. You may additionally
spot that I’ve a timers
workspace, which I have a tendency to make use of for miscellaneous
timers. e.g. a reminder earlier than a gathering is because of begin, or after I’m planning
to modify a process. I’ve a small device for this I’d share in a future submit.
A limitation versus triggering freedesktop.org Desktop
Notifications
is that there is not any payload / related message. For me this is not a giant deal,
such messages are distracting, and it is easy sufficient to see the total context
when switching workspaces. It is doable it is an issue on your most well-liked
workflow in fact.
You might put a
in your terminal immediate ($PS1
), which means a bell is
triggered after each command finishes. For me this could result in too many
notifications for instructions I did not need to fastidiously monitor the output for,
however your mileage could fluctuate.
Terminal emulator support
Unfortunately, setting the urgent hint upon a bell is not supported by
gnome-terminal, with a 15 year-old issue left
unresolved. It
is nevertheless supported by the in any other case very comparable xfce4-terminal (simply allow
the visible bell in preferences), and I switched solely attributable to this difficulty.
From what I can inform, that is the standing of visible bell help through setting
the X11 pressing trace:
- xfce4-terminal: Supported. In Preferences -> Superior guarantee “Visible bell”
is ticked. - xterm: Set
XTerm.vt100.bellIsUrgent: true
in your.Xresources
file. - rxvt-unicode (urxvt): Set
URxvt.urgentOnBell: true
in your.Xresources
file. - alacritty: Supported. Works out of the field with not extra configuration
wanted. - gnome-terminal: Not
supported. - konsole: So far as I can inform it is not supported. Creating a brand new profile and
setting the “Terminal bell mode” to “Visible Bell” does not appear to end in
the pressing trace being set.