Thursday, March 22, 2007

To Beep or not to Beep

Seems like Linux has done everything to prevent anyone from controlling the I/O devices under /dev, which includes you. I had a simple task, I wanted my "mail-notification" program to beep when I had mail. Under "When new mail arrives:", there was the command "play /path/to/some/sound.aiff" or something... I don't want any process interrupting my sound card because I'm running Fedora Linux, and I don't have JACK or another sound mixer which will mix sounds from multiple processes (maybe one day ALSA will work like this).

So anyway, I tried a million different commands...
echo -ne "\a"
which prints just a bell character, but it's interpretted by mail-notification (or nothing) and is lost--not sounded on the system beeper.

I tried a C program by Johnathan Nightingale, beep, which I had lying around, but it fails because the kernel doesn't like it touching the devices.

Finally, I thought "hmm, beep.c is just writing to /dev/console, why can't I?" and I tried
echo -ne "\a" > /dev/console
And it worked! It's not the same beep as Thunderbird/xterm/emacs, but it's fine with me!

No comments: