[Linux-Anyway] Re: New issue: Playing music stops my mail

  • From: Godwin Stewart <gstewart@xxxxxxxxxxx>
  • To: Linux-Anyway@xxxxxxxxxxxxx
  • Date: Fri, 5 Nov 2004 10:58:37 +0100

On Thu, 4 Nov 2004 15:47:55 -0800 (PST), Meph Istopheles <Meph@xxxxxxxxxxx>
wrote:

> # Play default sound on receive
> :0 ic
> | $HOME/bin/mailnotify.pl DennisLeary-FuckYou.wav default 
> &>/dev/null

I'm assuming your "mailnotify.pl" script runs synchronously, right? IOW,
procmail invokes it, it waits 'till the .wav file is played back, exits, and
procmail can continue the job of delivering the mail to your inbox.

Make it asynchronous.

Wrap it in a script, called "playsound" for example, which looks like this:

#!/bin/bash
$HOME/bin/mailnotify.pl DennisLeary-FuckYou.wav default > /dev/null &

This will "queue" the execution of the script until the sound device is
available again and then exit immediately, allowing procmail to continue.
Your recipe will now be:

# Play default sound on receive
:0 ic
| $HOME/bin/playsound

Now, if you only want the sound to be played if nothing else is already
being played, then you need to see whether or not /dev/dsp is in use.

fuser /dev/dsp

This will print out stuff relative to the process(es) using /dev/dsp if any
are, or nothing if /dev/dsp isn't in use. Furthermore, the exit code will be
0 if /dev/dsp is in use or 1 if not. It's the exit code we'd need.

Modify your "playsound" script so that it's like this:

#!/bin/bash
# Exit now if /dev/dsp is in use:
fuser /dev/dsp >/dev/null 2>&1 && exit 0
# Now play back the sound async'ly:
$HOME/bin/mailnotify.pl DennisLeary-FuckYou.wav default > /dev/null &

-- 
BOFH excuse #203:

Write-only-memory subsystem too slow for this machine, contact your local
dealer
To unsubcribe send e-mail with the word unsubscribe in the body to:   
Linux-Anyway-Request@xxxxxxxxxxxxx?body=unsubscribe

Other related posts: