extended awk scripts to return partentid

This commit is contained in:
2025-08-28 13:26:47 +02:00
parent 28f6dc67ba
commit f2383c3803
9 changed files with 133 additions and 119 deletions

69
src/sh/mpv.sh Normal file
View File

@@ -0,0 +1,69 @@
__mpv_command() {
printf "{ \"command\": [\"%s\"] }\n" "$1" | $SOCAT - "$MPV_SOCKET"
}
__mpv_command_with_arg() {
printf "{ \"command\": [\"%s\", \"%s\"] }\n" "$1" "$2" | $SOCAT - "$MPV_SOCKET"
}
__mpv_command_with_args2() {
printf "{ \"command\": [\"%s\", \"%s\", \"%s\"] }\n" "$1" "$2" "$3" | $SOCAT - "$MPV_SOCKET"
}
__mpv_get() {
__mpv_command_with_arg "expand-text" "$1" | $JQ -r '.data'
}
mpv_playlist_count() {
__mpv_get '${playlist-count}'
}
mpv_playlist_position() {
__mpv_get '${playlist-pos}'
}
mpv_quit() {
__mpv_command "quit"
}
mpv_start() {
MPV_SOCKET="$(mktemp --suffix=.sock)"
trap 'mpv_quit >/dev/null; rm -f "$MPV_SOCKET"' EXIT INT
$MPV --no-config --no-terminal --input-ipc-server="$MPV_SOCKET" --idle --no-osc --no-input-default-bindings &
}
mpv_play_file() {
__mpv_command_with_arg "loadfile" "$1"
}
mpv_queue_file() {
__mpv_command_with_args2 "loadfile" "$1" "append-play"
}
mpv_play_list() {
__mpv_command_with_arg "loadlist" "$1"
}
mpv_queue_list() {
__mpv_command_with_arg "loadlist" "$1" "append-play"
}
mpv_next() {
__mpv_command "playlist-next"
}
mpv_prev() {
__mpv_command "playlist-prev"
}
mpv_seek_forward() {
__mpv_command_with_arg "seek" "10"
}
mpv_seek_backward() {
__mpv_command_with_arg "seek" "-10"
}
mpv_toggle_pause() {
__mpv_command_with_arg "cycle" "pause"
}