26 comments

[ 5.2 ms ] story [ 75.6 ms ] thread
Suggestion accepted. Now I only I could play a random sound...
You could try something like this:

  timeout 3s cat /dev/urandom > /dev/dsp
There's no /dev/dsp on Fedora. This should be a more portable solution:

   dd if=/dev/urandom bs=176400 count=3 | play -t raw -r 44100 -e signed-integer -b 16 -c 2 -\
play is a part of the SoX software (Sound eXchange, the Swiss Army knife of audio manipulation).
Untested, but should get you close enough.

    #!/usr/bin/env bash
    F_NUM=$(($RANDOM % $(ls ~/.git/sounds/$i| wc -l)))
    n=0
    for i in *
      do
       if [[ n -eq $F_NUM ]]
         then
           afplay ~/.git/sounds/$i > /dev/null 2>&1 &
       fi
       n=$((n + 1))
    done
My version:

#!/bin/bash

  SOUNDPATH=${HOME}/.play-random/sounds

  if [ ! -d ${SOUNDPATH} ]; then
      echo "Create and populate '${SOUNDPATH}' directory"
      exit 1;
  fi

  SOUNDS=($(ls "${SOUNDPATH}"))
  NUM_SOUNDS=${#SOUNDS[*]}

  if [ ${NUM_SOUNDS} -eq 0 ]; then
      echo "No sound files found in '${SOUNDPATH}' directory"
      exit 1;
  fi

  # select which sound to play
  SOUND="${SOUNDPATH}/${SOUNDS[$((RANDOM%NUM_SOUNDS))]}"
  echo ${SOUND}

  /usr/bin/aplay ${SOUND}
code at: http://aeminium.org/slug/software/shell/#play.random.sh

There's a way of removing that ls ${DIR} and use an echo ${DIR}/* at the expense of making it a bit uglier to detect when there's no sound files.

  #!/bin/sh

  SOUND=$(ls ~/Sounds |sort -R |tail -1)
  afplay ~/Sounds/$SOUND > /dev/null 2>&1 &
You could also use a Nabaztag and let the rabbit dance on post-commit.
That thing is really creepy if you do a git-rebase with a lot of commits.
I have been playing around with doing something like this, but on deploy rather then commit, just to get some audible recognition of a successful deploy or failure.
I got this to work in Windows using msysgit. I downloaded sndrec32.exe (which used to come with Windows but no longer does, stand alone exe that can play wavs at the command line) and added this to my post-commit

/path/to/sndrec32.exe -play -close -embedding /path/to/happykids.wav

We do this at Notifo once we push committed code to GitHub. We get a message on our phones using Notifo and the GitHub hooks that plays, coincidentally, that same kids cheering sound. We also have a Commit Cam in the office which posts to DailyBooth to capture commit rapture. The first one came out perfect: http://dailybooth.com/jazzychad/6742332
I set up my svn commands to play the Super Mario Bros theme from 1-1 while committing.

If successful, it plays the level complete jingle, and if it fails, Mario dies.

I commit so often, I'm afraid the first cheer won't finish before the second starts.
Git hooks aside (MacOS's "say" command can also help here), I like the way Brandon's picture pops out from under the article. It is one of those pieces that's so fun to use that I end up using it a few times extra, like the cup holder in my former boss's Saab 9000 or the carrying handle of my girlfriend's Bernina sewing machine.
I'd really like to have this as the sound that plays whenever you do a successful merge in svn.