mirror of
https://git.korhonen.cc/FunctionalHacker/dotfiles.git
synced 2024-11-04 18:00:20 +00:00
6bf2c1cafc
Fixes #3
31 lines
683 B
Bash
Executable File
31 lines
683 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
notify="notify-send -i mpv -a mpv"
|
|
url="$1"
|
|
|
|
# NOTE: You need to configure mpv to
|
|
# enable ipc server on this path (see my mpv config for an example)
|
|
MPVSOCKET="/tmp/mpvsocket"
|
|
|
|
# See if MPV is already running
|
|
if [ -z "$(pidof mpv)" ]; then
|
|
# mpv is not running
|
|
|
|
# pause other players
|
|
playerctl pause
|
|
|
|
# start mpv
|
|
/usr/bin/mpv --no-terminal "$url" & disown
|
|
|
|
# Wait for mpv to be up before adding anything else to playlist
|
|
while [ -z "$(pidof mpv)" ]; do
|
|
sleep 1
|
|
done
|
|
$notify "Playing $url"
|
|
|
|
else
|
|
# mpv is running, so add stuff to playlist
|
|
$notify "Adding $url"
|
|
echo "{\"command\": [\"loadfile\", \"$url\", \"append\"]}" | socat - /tmp/mpvsocket
|
|
fi
|