Skip to content

Instantly share code, notes, and snippets.

@Wohlstand
Last active August 12, 2016 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wohlstand/d531e9c891591c234ec6d7edc137a45e to your computer and use it in GitHub Desktop.
Save Wohlstand/d531e9c891591c234ec6d7edc137a45e to your computer and use it in GitHub Desktop.
A simple sequential playlist to change playing music every 3 minutes or by key-press (looking for making shuffle)
#!/bin/bash
MAXTIME=180
PLAYER=/your/path/here/pge_musplay
PLAYDIR=$PWD/*.mid
ord() {
LC_CTYPE=C printf '%d' "'$1"
}
for f in $PLAYDIR; do
echo "================================================================================"
echo "PLAY $f..."
$PLAYER "$f";
echo "================================================================================"
TIME="0"
echo
while [ $TIME != $MAXTIME ];
do
printf "\e[33m\r$TIME/$MAXTIME\e[0m"
if read -r -s -n 1 -t 1 key
then
Akey=$(ord $key)
if ((Akey == 112)) ; then
printf "\rpaused"
read -n 1
printf "\r "
else
TIME=$MAXTIME
fi
else
TIME=$(($TIME+1))
fi
done
printf "\r "
sleep 1s
printf "\n\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment