beeping under linux

Ben Finney bignose-hates-spam at
Thu Nov 20 00:21:16 CET 2003

On 19 Nov 2003 19:41:28 +0000, Alexander Schmolck wrote:
> This is only partly a python question, but what is the easiest way to
> get python to (reliably) beep under linux? By reliably I mean that
> ``print "\b"`` won't do because it depends on the terminal settings

Assuming you mean 'print "\a"' (ASCII BEL) rather than 'print "\b"'
(ASCII BS), this is the most portable way to sound the terminal bell.

Most responses have been talking about /dev/audio, which is unrelated to
the terminal bell and is not portable -- many systems, especially
headless ones, do not have any sound card.

> [The usage scenario is simply to have an effective way of signalling
> that a long running-process finshed, without me having to constantly
> look at the screen]

The correct way to do this is to send the ASCII BEL ("\a") character to
the terminal.  If the terminal's bell has been disabled somehow, it's
not the job of your program to revert that decision.

 \       "I always wanted to be somebody. I see now that I should have |
  `\                              been more specific."  -- Lily Tomlin |
_o__)                                                                  |
Ben Finney <>

More information about the Python-list mailing list