From: Arun Prakash Jana Date: Wed, 14 Aug 2019 22:31:53 +0000 (+0530) Subject: Detect if MOC is playing X-Git-Tag: v2.7~141 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=8fff4643f50d37d90a1e7efde32d80436aa8e00a;p=nnn.git Detect if MOC is playing --- diff --git a/plugins/mocplay b/plugins/mocplay index 9057827b..d93536ad 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