Using $PROMPT_COMMAND to beep depending on success/failure

Linux for blind general discussion blinux-list at redhat.com
Thu Jun 27 13:10:54 UTC 2019


I like this idea, but it needs some debugging on my end.

Firstly, I did make sure to get all that code on one line in my .bashrc.
However, I get this error:

play WARN alsa: can't encode 0-bit Unknown or not applicable

Tim Chase writes:
> 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/blinux-list

-- 

Janina Sajka

Linux Foundation Fellow
Executive Chair, Accessibility Workgroup:	http://a11y.org

The World Wide Web Consortium (W3C), Web Accessibility Initiative (WAI)
Chair, Accessible Platform Architectures	http://www.w3.org/wai/apa




More information about the Blinux-list mailing list