diff options
| author | 2019-06-03 18:26:53 +0530 | |
|---|---|---|
| committer | 2019-06-03 18:26:53 +0530 | |
| commit | edf587a48f9dfdee92399b713d5ae0e39789bf70 (patch) | |
| tree | 9f814ea226bde0b2c00a417d60425e20b8ca827e /plugins/mocplay | |
| parent | 971129736279cf62cd7473af99fcbd354385821b (diff) | |
| download | nnn-edf587a48f9dfdee92399b713d5ae0e39789bf70.tar.gz | |
Add plugin to play music in MOC
Diffstat (limited to 'plugins/mocplay')
| -rwxr-xr-x | plugins/mocplay | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/mocplay b/plugins/mocplay new file mode 100755 index 0000000..b883b83 --- /dev/null +++ b/plugins/mocplay @@ -0,0 +1,42 @@ +#!/usr/bin/env sh + +# Description: Appends and optionally plays music in MOC +# +# Notes: +# - if selection is available, plays it, else plays the current file or directory +# - appends tracks and exits is MOC is running, else clears playlist and adds tracks +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +selection=~/.config/nnn/.selection +cmd=$(pgrep -x mocp 2>/dev/null) +ret=$cmd + +if [ -s "$selection" ]; then + # try selection first + if [ -z "$ret" ]; then + # mocp not running + mocp -S + + # clear selection and play + cat "$selection" | xargs -0 mocp -acp + else + # mocp running, just append + cat "$selection" | xargs -0 mocp -a + fi +else + # ensure a file/dir is passed + if ! [ -z "$1" ]; then + if [ -z "$ret" ]; then + # mocp not running + mocp -S + + # clear selection and play + mocp -acp "$1" + else + # mocp running, just append + mocp -a "$1" + fi + fi +fi |