commit fc57703
hovercats
·
2026-09-02 06:31:04 +0000 UTC
parent 4128454
add flag to add as next in queue
1 files changed,
+14,
-2
M
ampv
M
ampv
+14,
-2
1@@ -9,14 +9,17 @@ menu=(dmenu -i -l 20)
2 fn player {exec mpv '--input-ipc-server='$socket $*}
3 fn tosocket {printf '{ "command": '$*' }\n' | nc -UN $socket}
4 fn getfilepath {tosocket '["get_property", "path"]' | awk -F '"' '{print $4}'}
5+fn addtolist {
6+ find $musicdir -type f -name *.opus | $menu >$tmpfile
7+ printf 'loadlist '$tmpfile' append\n' | nc -UN $socket
8+}
9
10 switch($1) {
11 case -a
12 songfile=`{getfilepath}
13 printf '%s\n' $"songfile >> $playlist
14 case -A
15- find $musicdir -type f -name *.opus | $menu >$tmpfile
16- printf 'loadlist '$tmpfile' append\n' | nc -UN $socket
17+ addtolist
18 case -d
19 songfile=`{getfilepath}
20 grep -v $"songfile $playlist > $tmpfile
21@@ -31,6 +34,15 @@ switch($1) {
22 -e 's/_/ /g' -e 's/":/: /g' -e 's/,"/\n/g' -e 's/"//g'
23 case -n
24 tosocket '["playlist-next"]'
25+ case -N
26+ addtolist
27+ tosocket '["get_property", "playlist-pos"]' | awk -F '"' '{print $3}' | \
28+ sed -e 's/://' -e 's/,//' >$tmpfile
29+ pos=`{awk <$tmpfile '{print $1 + 1}'}
30+ tosocket '["get_property", "playlist-count"]' | awk -F '"' '{print $3}' | \
31+ sed -e 's/://' -e 's/,//' >$tmpfile
32+ count=`{awk <$tmpfile '{print $1 - 1}'}
33+ printf 'playlist-move '$count' '$pos\n | nc -UN $socket
34 case -p
35 tosocket '["cycle", "pause"]'
36 case -P