expand pauseallmpv to also accept more args
This commit is contained in:
+33
-6
@@ -1,10 +1,37 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# You might notice all mpv commands are aliased to have this input-ipc-server
|
# Send a command to every running mpv instance via its IPC socket
|
||||||
# thing. That's just for this particular command, which allows us to pause
|
# (created by the mpvSockets.lua script in ~/.config/mpv/scripts).
|
||||||
# every single one of them with one command! This is bound to super + shift + p
|
#
|
||||||
# (with other things) by default and is used in some other places.
|
# Usage: pauseallmpv [subcommand]
|
||||||
|
# (no arg) pause all mpv instances (original behavior)
|
||||||
|
# toggle toggle pause
|
||||||
|
# play unpause
|
||||||
|
# next playlist-next
|
||||||
|
# prev playlist-prev
|
||||||
|
# stop stop playback
|
||||||
|
# seek-fwd seek +10s
|
||||||
|
# seek-back seek -10s
|
||||||
|
#
|
||||||
|
# Exit status: 0 if at least one mpv instance was reached, 1 otherwise.
|
||||||
|
|
||||||
for i in $(ls /tmp/mpvSockets/*); do
|
case "${1:-pause}" in
|
||||||
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i";
|
pause) cmd='["set_property","pause",true]' ;;
|
||||||
|
toggle) cmd='["cycle","pause"]' ;;
|
||||||
|
play) cmd='["set_property","pause",false]' ;;
|
||||||
|
next) cmd='["playlist-next"]' ;;
|
||||||
|
prev) cmd='["playlist-prev"]' ;;
|
||||||
|
stop) cmd='["stop"]' ;;
|
||||||
|
seek-fwd) cmd='["seek",10]' ;;
|
||||||
|
seek-back) cmd='["seek",-10]' ;;
|
||||||
|
*) echo "Usage: $0 [pause|toggle|play|next|prev|stop|seek-fwd|seek-back]" >&2; exit 2 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
rc=1
|
||||||
|
for s in /tmp/mpvSockets/*; do
|
||||||
|
[ -S "$s" ] || continue
|
||||||
|
rc=0
|
||||||
|
printf '{"command":%s}\n' "$cmd" | socat - "$s" >/dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
|
exit $rc
|
||||||
|
|||||||
Reference in New Issue
Block a user