summaryrefslogtreecommitdiff
path: root/bin/extra/append2mpv
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-11-19 16:30:21 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-11-19 16:30:21 +0100
commitac82416ba14d4cfc2f47ab1d607501bfd899781f (patch)
treeac0ecd986284f5ae73b413143739281b9f8577bd /bin/extra/append2mpv
parentff3a8bb2d62f5a7e1759eb3d9e0834f4396e833d (diff)
parent822f8dbf4db697c7a2bfbd675374bfaa7080ce82 (diff)
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin/extra/append2mpv')
-rwxr-xr-xbin/extra/append2mpv30
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/extra/append2mpv b/bin/extra/append2mpv
new file mode 100755
index 0000000..28c3916
--- /dev/null
+++ b/bin/extra/append2mpv
@@ -0,0 +1,30 @@
+#!/bin/sh
+IPC="/tmp/mpvsocket"
+
+die () { >&2 printf '%s\n' "$@"; exit 1; }
+append_to_mpv()
+{
+ file="$(readlink -f "$1")"
+ if [ ! -r "$file" ]
+ then
+ >&2 printf '%s\n' "'$file' not found"
+ return
+ fi
+
+ echo '{ "command": ["loadfile", "'"$file"'", "append"] }' |
+ socat - "$IPC"
+}
+
+[ -S "$IPC" ] || die "$IPC is not a socket or doesn't exist"
+which socat > /dev/null || exit 1
+
+
+if [ -t 0 ]
+then
+ append_to_mpv "$1"
+else
+ while read -r file
+ do
+ append_to_mpv "$file"
+ done
+fi