]> Sergey Matveev's repositories - nnn.git/commitdiff
Detect if MOC is playing
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 14 Aug 2019 22:31:53 +0000 (04:01 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 14 Aug 2019 22:31:53 +0000 (04:01 +0530)
plugins/mocplay

index 9057827ba0bc232af5464bf5d26b46b9932eca92..d93536ad4a6727f42c25e2c1c36378ca1b40807b 100755 (executable)
@@ -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