News for hackers. Stuff that matters.
Re:Happy Git Commits by swah on Wednesday August 04, 2010 @10:41AM (#1574574)
Suggestion accepted. Now I only I could play a random sound...
Re:Happy Git Commits by mapleoin on Wednesday August 04, 2010 @11:05AM (#1574640)
You could try something like this:

  timeout 3s cat /dev/urandom > /dev/dsp
Re:Happy Git Commits by ciupicri on Wednesday August 04, 2010 @04:20PM (#1575746)
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).
Re:Happy Git Commits by jeebusroxors on Wednesday August 04, 2010 @12:02PM (#1574793)
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
Re:Happy Git Commits by slug on Wednesday August 04, 2010 @12:50PM (#1574962)
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.

Re:Happy Git Commits by muitocomplicado on Wednesday August 04, 2010 @02:51PM (#1575414)

  #!/bin/sh

  SOUND=$(ls ~/Sounds |sort -R |tail -1)
  afplay ~/Sounds/$SOUND > /dev/null 2>&1 &