Results 1 to 4 of 4

Thread: [SOLVED] How to play a short audio clip from BASH

  1. #1
    Join Date
    Jul 2008
    Beans
    13
    Distro
    Xubuntu 8.10 Intrepid Ibex

    [SOLVED] How to play a short audio clip from BASH

    What's the best way to play a short audio clip (e.g., an alarm bell) from a BASH script? At the moment I'm using totem, but it's overkill to have its GUI start up! I'd prefer just a simple command for one-off playing of an audio clip.

  2. #2
    Join Date
    Jul 2006
    Location
    Lancashire
    Beans
    Hidden!
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: How to play a short audio clip from BASH

    Hi
    You could use mplayer, like this:-
    Code:
    mplayer <filename>

  3. #3
    Join Date
    Jul 2008
    Beans
    13
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How to play a short audio clip from BASH

    Thanks. Suppressing stdout and stderr, the following worked just fine:

    #!/bin/bash
    (sleep ${1:-240}; mplayer /usr/share/sounds/phone.wav >/dev/null 2>&1) &
    Last edited by minus24; July 22nd, 2008 at 11:13 PM.

  4. #4
    Join Date
    Nov 2012
    Beans
    1

    Re: How to play a short audio clip from BASH

    Quote Originally Posted by minus24 View Post
    Thanks. Suppressing stdout and stderr, the following worked just fine:

    #!/bin/bash
    (sleep ${1:-240}; mplayer /usr/share/sounds/phone.wav >/dev/null 2>&1) &
    In OS X the player command is afplay
    More at http://hints.macworld.com/article.ph...81002080543392

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •