aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-08-15 04:01:53 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-08-15 04:01:53 +0530
commit8fff4643f50d37d90a1e7efde32d80436aa8e00a (patch)
treed3923af519bba583667d80615f97563114bcec29
parent5c591422dca97671eb23404e8fcde37c09353ed2 (diff)
downloadnnn-8fff4643f50d37d90a1e7efde32d80436aa8e00a.tar.gz
Detect if MOC is playing
-rwxr-xr-xplugins/mocplay24
1 files changed, 17 insertions, 7 deletions
diff --git a/plugins/mocplay b/plugins/mocplay
index 9057827..d93536a 100755
--- a/plugins/mocplay
+++ b/plugins/mocplay
@@ -59,15 +59,25 @@ fi
if [ -z "$ret" ]; then
# mocp not running
mocp -S
-
- # clear selection and play
- mocp -c
- mocp_add "$1"
- mocp -p
else
- # mocp running, just append
- mocp_add "$1"
+ # mocp running, check if it's playing
+ state=$(mocp -i | grep "State:" | cut -d' ' -f2)
+
+ if [ $state = 'PLAY' ]; then
+ # add to playlist and exit
+ mocp_add "$1"
+
+ # uncomment the line below to show mocp interface after appending
+ # mocp
+
+ exit
+ fi
fi
+# clear selection and play
+mocp -c
+mocp_add "$1"
+mocp -p
+
# uncomment the line below to show mocp interface after appending
# mocp