aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/boom
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-16 06:40:02 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-16 07:13:35 +0530
commitb8a973a91ac406266befcb36599ce8df64d096b9 (patch)
tree256fac02bace6a06cad239d37c19d1d400ee40e6 /plugins/boom
parenta2c2332fc549b43c91dce97f4c099bfa55762277 (diff)
downloadnnn-b8a973a91ac406266befcb36599ce8df64d096b9.tar.gz
Update plugins to support some env vars
Diffstat (limited to 'plugins/boom')
-rwxr-xr-xplugins/boom27
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/boom b/plugins/boom
index 460b9dd..14f481d 100755
--- a/plugins/boom
+++ b/plugins/boom
@@ -6,25 +6,36 @@
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-#GUIPLAYER=smplayer
-
-NUMTRACKS=100
+GUIPLAYER="${GUIPLAYER}"
+NUMTRACKS="${NUMTRACKS:-100}"
if [ ! -z "$GUIPLAYER" ]; then
- PLAYER="$GUIPLAYER"
- find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n $NUMTRACKS | xargs -d "\n" "$PLAYER" > /dev/null 2>&1 &
+ find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 &
# detach the player
sleep 1
elif which mocp >/dev/null 2>&1; then
- # start MOC server
- mocp -S
+ cmd=$(pgrep -x mocp 2>/dev/null)
+ ret=$cmd
+
+ if [ -z "$ret" ]; then
+ # start MOC server
+ mocp -S
+ else
+ # mocp running, check if it's playing
+ state=$(mocp -i | grep "State:" | cut -d' ' -f2)
+ if [ "$state" = 'PLAY' ]; then
+ # add up to 100 random audio files
+ find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
+ exit
+ fi
+ fi
# clear MOC playlist
mocp -c
# add up to 100 random audio files
- find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n $NUMTRACKS | xargs -d "\n" mocp -a
+ find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
# start playing
mocp -p