-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcplay
executable file
·53 lines (47 loc) · 1.16 KB
/
cplay
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
46
47
48
49
50
51
52
53
#!/bin/sh
# Fernando Carmona Varo <[email protected]
#----
# Script for controlling cmus music player
#
# + If no cmus is running, it will open it on a terminal
# + If run without arguments, it will toggle playback
# + If run with a playlist as argument, it will be loaded
# + If run with other files as argument, they will be added to current playlist
#
# Other arguments:
#
# --load-pl Show an Interactive dmenu to load a playlist
# from the directory set in the CPLAYDIR variable.
#
# --save-pl Asks for a name and saves the playlist in the
# playlist directory.
#----
CPLAYDIR=${CPLAYDIR:-"$HOME/.cmus/pls/"}
if ! pgrep "^cmus$" >/dev/null
then
${XTERM:-xterm} -e cmus &
while ! cmus-remote -C; do sleep 1; done
fi
if [ "$1" ]
then
case "$1" in
*.pl)
cmus-remote -c -P "$1"
;;
--load-pl)
cd $CPLAYDIR
cplay "$(find -iname "*.pl" | dmenu || exit)"
;;
--save-pl)
fname=$(echo | dmenu -p 'Name for the playlist (without .pl)')
[ "$fname" ] || exit
mkdir -p "$PLDIR"
cmus-remote -C "save -p -" > "${PLDIR}/${fname}.pl"
;;
*)
cmus-remote -q $@
;;
esac
else
cmus-remote -u
fi