2019-04-20 17:43:13 +05:30
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2019-12-10 22:56:00 +05:30
|
|
|
# Description: Play random music from current directory. Identifies MP3, FLAC, M4A, WEBM, WMA.
|
2019-08-24 22:35:04 +05:30
|
|
|
# You may want to set GUIPLAYER.
|
2019-04-20 17:43:13 +05:30
|
|
|
#
|
|
|
|
# Shell: POSIX compliant
|
|
|
|
# Author: Arun Prakash Jana
|
|
|
|
|
2019-08-24 22:35:04 +05:30
|
|
|
#GUIPLAYER=smplayer
|
2019-04-20 17:43:13 +05:30
|
|
|
|
2019-08-25 06:16:31 +05:30
|
|
|
NUMTRACKS=100
|
|
|
|
|
2019-08-24 22:35:04 +05:30
|
|
|
if [ ! -z "$GUIPLAYER" ]; then
|
|
|
|
PLAYER="$GUIPLAYER"
|
2019-12-10 22:56:00 +05:30
|
|
|
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | sort -R | head -n $NUMTRACKS | xargs -d "\n" "$PLAYER" > /dev/null 2>&1 &
|
2019-08-24 22:35:04 +05:30
|
|
|
|
|
|
|
# detach the player
|
2019-11-22 02:14:25 +05:30
|
|
|
sleep 1
|
2019-08-24 22:35:04 +05:30
|
|
|
else
|
|
|
|
# start MOC server
|
|
|
|
mocp -S
|
|
|
|
|
|
|
|
# clear MOC playlist
|
|
|
|
mocp -c
|
|
|
|
|
|
|
|
# add up to 100 random audio files
|
2019-12-10 22:56:00 +05:30
|
|
|
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | sort -R | head -n $NUMTRACKS | xargs -d "\n" mocp -a
|
2019-08-24 22:35:04 +05:30
|
|
|
|
|
|
|
# start playing
|
|
|
|
mocp -p
|
|
|
|
fi
|