Skip to content

Instantly share code, notes, and snippets.

@4np
Last active January 2, 2016 09:39
Show Gist options
  • Save 4np/8284393 to your computer and use it in GitHub Desktop.
Save 4np/8284393 to your computer and use it in GitHub Desktop.
play 'push it' sample in Mac OS X
#!/bin/sh
# get / set volume
volume() {
if [ -z $1 ]; then
local volume=`osascript -e 'output volume of (get volume settings)'`
local muted=`osascript -e 'output muted of (get volume settings)'`
echo $volume $muted
else
osascript -e 'set volume output volume '$1
if [ ! -z $2 ]; then
muted $2
fi
fi
}
# get / set muted
muted() {
if [ -z $1 ]; then
osascript -e 'output muted of (get volume settings)'
else
osascript -e 'set volume output muted '$1
fi
}
nowPushIt() {
if [ ! -f /tmp/pushit.wav ]; then
curl -s -o /tmp/pushit.wav https://dl.dropboxusercontent.com/s/zd45mxzb2e3btwe/nowpushit.wav?dl=1
fi
# play push it sample
if [ `which afplay ` ]; then
# get current volume
local volume=$(volume)
# set full volume
volume 100 false
# play the sample
afplay /tmp/pushit.wav
# restore volume settings
volume $volume
fi
}
# push it real good!
nowPushIt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment