blob: 8e0f92ae1fc59c4c668f952a07aa11261f4329b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/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=${XDG_CONFIG_HOME:-$HOME/.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
# uncomment the line below to show mocp interface after appending
# mocp
|