From 54b2e84dcfb7e05840e3e1dd826b3bc2c0057bf4 Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Mon, 4 Nov 2024 22:39:30 +0000 Subject: [PATCH] checks if mpv is not running and if it isn't then it starts it (avoids crashes) --- mpvmusic.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mpvmusic.sh b/mpvmusic.sh index c5617b5..b76e891 100755 --- a/mpvmusic.sh +++ b/mpvmusic.sh @@ -17,7 +17,17 @@ source $config_path previous_songs_path="" #find $playlist_path -type f > song_list.txt -mpv --shuffle --really-quiet $playlist_path --input-ipc-server=/tmp/mpvsocket & +while [ 1 == 1 ]; do + mpv_running=$(pidof mpv) + if [ -z "$mpv_running" ]; then + echo "mpv process not found, (re)starting..." + mpv --shuffle --really-quiet $playlist_path --input-ipc-server=/tmp/mpvsocket & + else + echo "mpv is already running" + fi + sleep 1 +done & + sleep 1 while [ 1 == 1 ]; do