mpv reloads properly if it crashes
This commit is contained in:
parent
3e947c2199
commit
d52f821408
42
mpvmusic.sh
42
mpvmusic.sh
@ -27,34 +27,30 @@ handle_sigint() {
|
|||||||
|
|
||||||
trap handle_sigint SIGINT
|
trap handle_sigint SIGINT
|
||||||
while [ $quit_mpv = false ]; do
|
while [ $quit_mpv = false ]; do
|
||||||
#echo $quit_mpv
|
if [ -z "$(pidof mpv)" ] && [ $quit_mpv = false ]; then
|
||||||
mpv_running=$(pidof mpv)
|
|
||||||
if [ -z "$mpv_running" ] && [ $quit_mpv = false ]; then
|
|
||||||
echo "mpv process not found, (re)starting..."
|
echo "mpv process not found, (re)starting..."
|
||||||
mpv --shuffle --really-quiet $playlist_path --input-ipc-server=/tmp/mpvsocket &
|
mpv --shuffle --really-quiet $playlist_path --input-ipc-server=/tmp/mpvsocket &
|
||||||
|
sleep 0.5
|
||||||
fi
|
fi
|
||||||
sleep 0.5
|
path=$(echo '{ "command": ["get_property", "path"] }' | socat - "/tmp/mpvsocket" | jq -r '.data')
|
||||||
while [ $quit_mpv = false ]; do
|
if [[ $path != $previous_songs_path ]]; then
|
||||||
path=$(echo '{ "command": ["get_property", "path"] }' | socat - "/tmp/mpvsocket" | jq -r '.data')
|
clear
|
||||||
if [[ $path != $previous_songs_path ]]; then
|
name=$(exiftool -Title "$path" | awk -F: '{print $2}')
|
||||||
clear
|
artist=$(exiftool -Artist "$path" | awk -F: '{print $2}')
|
||||||
name=$(exiftool -Title "$path" | awk -F: '{print $2}')
|
|
||||||
artist=$(exiftool -Artist "$path" | awk -F: '{print $2}')
|
|
||||||
|
|
||||||
echo Song name: $name
|
echo Song name: $name
|
||||||
echo Artist: $artist
|
echo Artist: $artist
|
||||||
|
|
||||||
if [ -n $webpage_path ]; then
|
if [ -n $webpage_path ]; then
|
||||||
echo "<h1>Currently listening to:</h1>" > $webpage_path
|
echo "<h1>Currently listening to:</h1>" > $webpage_path
|
||||||
echo Name: $name"<br/>" >> $webpage_path
|
echo Name: $name"<br/>" >> $webpage_path
|
||||||
echo Artist: $artist"<br/>" >> $webpage_path
|
echo Artist: $artist"<br/>" >> $webpage_path
|
||||||
echo "<form action='/music/prev' id='media-control' method='post'><button>previous</button></form>" >> $webpage_path
|
echo "<form action='/music/prev' id='media-control' method='post'><button>previous</button></form>" >> $webpage_path
|
||||||
echo "<form action='/music/playpause' id='media-control' method='post'><button>play/pause</button></form>" >> $webpage_path
|
echo "<form action='/music/playpause' id='media-control' method='post'><button>play/pause</button></form>" >> $webpage_path
|
||||||
echo "<form action='/music/next' id='media-control' method='post'><button>next</button></form>" >> $webpage_path
|
echo "<form action='/music/next' id='media-control' method='post'><button>next</button></form>" >> $webpage_path
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
previous_songs_path=$path
|
fi
|
||||||
sleep 0.5
|
previous_songs_path=$path
|
||||||
done
|
sleep 0.5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user