beeping under linux

Alexander Schmolck a.schmolck at gmx.net
Thu Nov 20 07:34:00 EST 2003


Ben Finney <bignose-hates-spam at and-benfinney-does-too.id.au> writes:

> 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.

Anything that works under a normal linux box will do.
 
> 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.

Yep -- and although mine does have a soundcard it has no speakers.

> 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.

Well, I happen to see myself as the ultimate authority on what my program's
job (especially when I'm the sole user) and I also fail to discern an obvious
relationship between my user-preference for visible/audible bells when working
with (i.e. in front of) a certain terminal and my desire to receive some
notification when a long-running process finishes that doesn't force me to
constantly monitor the monitor (because chances are I might be reading a
paper).

I could live with a solution that requires me to change comint's (viz Emacs's
py-shell's) and kterm's beeping behavior before and after my program runs, but
I have no idea to get either of them to beep audibly (kterms bell settings
e.g. don't seem much of a help).

The best reason I can see for trying to find a way to make '\a' work is that
it would be desirable to have beeping behavior also for remotely running
processes (so directly writing to /dev/* or some such wouldn't be ideal).

'as




More information about the Python-list mailing list