mocp rand
Posted by: nico on
Jul 23rd, 2009 |
Filed under: Console, Programming
-
#!/bin/bash
-
-
SEARCH_DIR=‘/home/nico/Música’
-
START_RANDOM=1
-
RAND_MAX=32767
-
-
while (( 1 )); do
-
NUM_DISCS=$(find $SEARCH_DIR -type d|wc -l)
-
RAND=$(($NUM_DISCS * $RANDOM / $RAND_MAX))
-
RAND_DISC=$(find $SEARCH_DIR -type d | head -n $RAND | tail -n 1)
-
-
# Wake up moc
-
mocp -FS 2>/dev/null >/dev/null &
-
mocp -pca "$RAND_DISC" &
-
echo "Playing $RAND_DISC"
-
-
# Start from a random file?
-
if (( $START_RANDOM )); then
-
mocp –on shuffle &
-
mocp -f &
-
mocp –off shuffle &
-
fi
-
-
read
-
done
| Of course, it requires mocp, my favorite music (on console) player. And obviously, you’ll have to configure SEARCH_DIR but I’m sure some bash hacking is not that hard. Beware though, using this + cron may have the undesired effect of awakening to the pleasant music of Cannibal Corpse. |
![]() |




Add A Comment