Created
August 6, 2009 03:26
-
-
Save radhikalism/163101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/dash | |
volume=10 | |
shuffle=0 | |
search_paths="" | |
while getopts :v:p:s opt; do | |
case $opt in | |
v) | |
echo "volume:" $OPTARG | |
volume="$OPTARG" | |
;; | |
p) | |
echo "path:" $OPTARG | |
if [ "$search_paths" = "" ]; then | |
search_paths="$OPTARG" | |
else | |
search_paths="$search_paths:$OPTARG" | |
fi | |
;; | |
s) | |
echo "shuffle enabled" | |
shuffle=1 | |
;; | |
\?) | |
echo "Unrecognised option:" -$OPTARG >&2 | |
exit 1 | |
;; | |
:) | |
echo "Argument missing for:" $OPTARG >&2 | |
exit 1 | |
;; | |
esac | |
done | |
files="" | |
IFS=: | |
for p in $search_paths; do | |
f="$(find $p -iname '*.ogg' -or -iname '*.mp3' -or -iname '*.mp4' -or -iname '*.flv' -or -iname '*.flac' -or -iname '*.mpg')" | |
if [ "$files" = "" ]; then | |
files="$f" | |
else | |
files="$files\n$f" | |
fi | |
done | |
if [ "$shuffle" = 1 ]; then | |
files=$(echo "$files" | shuf) | |
fi | |
if [ ! -d /tmp/music ]; then | |
mkdir /tmp/music | |
fi | |
rm -rf /tmp/music/* | |
tmp=$(mktemp --tmpdir music/playlist.XXXXXXXXX) | |
echo Using temp file "$tmp"... | |
echo "$files" > $tmp | |
mplayer -volume $volume -softvol -vo null -playlist $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment