Re: Using $PROMPT_COMMAND to beep depending on success/failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim, thanks.  I have an application in mind for this.
What I've been doing so far to test network connected status was:
ping -c 5 www.google.com|grep %
That returns a line of output giving packet thruput statistics and if I have 0 percent packet loss I know my network is up. I just need to figure out how to itegrate this.

On Wed, 20 Apr 2016, Tim Chase wrote:

Date: Wed, 20 Apr 2016 14:41:11
From: Tim Chase <blinux.list@xxxxxxxxxxxxx>
Reply-To: Linux for blind general discussion <blinux-list@xxxxxxxxxx>
To: Linux for blind general discussion <blinux-list@xxxxxxxxxx>
Subject: Using $PROMPT_COMMAND to beep depending on success/failure

Stumbled on this one today thanks to @climagic on Twitter.  If you
want to have your machine give you one tone if the previous command
succeeded (had an exit-status of 0) and a different tone if the
previous command failed (had a non-zero exit status), you can put the
following one-liner in your .bashrc file:

PROMPT_COMMAND='[ "$?" == 0 ] && play -qn synth sin F3 trim 0 0 0.1
fade 0 0.1 0.05 vol 0.2 || play -qn synth square F4 trim 0 0.1 fade 0
0.1 0.05'

This uses the `play` command from the `sox` package.  There are a
number of tweaks you can make to change the tones, timbres,
wave-form, volume, duration, etc.  The above uses an F3 sine-wave at
20% volume for success and an F4 square-wave at 100% volume for
failure.

To test it out, use the `true` and `false` commands (they don't do
anything other than exit with a particular zero/non-zero exit code).

But here's hoping someone here finds it useful.

-tim



_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list


--

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list



[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]