commit ba5205e

hovercats  ·  2026-08-19 21:42:13 +0000 UTC
parent 21669af
add flag to delete current song from default playlist | move reading the filename into a function
1 files changed,  +9, -2
M ampv
M ampv
+9, -2
 1@@ -3,15 +3,22 @@
 2 musicdir=$HOME/usr/Music
 3 socket=/tmp/.mpvsocket
 4 playlist=$home/usr/ampv-playlist
 5+tmpfile=/tmp/.ampv.tmp
 6 
 7 fn player {mpv '--input-ipc-server='$socket $*}
 8 fn njetcat {nc -UN $socket}
 9+fn getfilepath {
10+	printf '{ "command": ["get_property", "path"] }\n' | \
11+			njetcat | awk -F '"' '{print $4}'}
12 
13 switch($1) {
14 	case add
15-		file=`{printf '{ "command": ["get_property", "path"] }\n' | \
16-			njetcat | awk -F '"' '{print $4}'}
17+		file=`{getfilepath}
18 		printf '%s\n' $"file >> $playlist
19+	case del
20+		file=`{getfilepath}
21+		grep -v $"file $playlist > $tmpfile
22+		mv -f $tmpfile $playlist
23 	case next
24 		printf 'playlist-next\n' | njetcat
25 	case pause