diff --git a/mpvmusic.sh b/mpvmusic.sh index 71d17a6..95a01b6 100755 --- a/mpvmusic.sh +++ b/mpvmusic.sh @@ -27,34 +27,30 @@ handle_sigint() { trap handle_sigint SIGINT while [ $quit_mpv = false ]; do - #echo $quit_mpv - mpv_running=$(pidof mpv) - if [ -z "$mpv_running" ] && [ $quit_mpv = false ]; then + if [ -z "$(pidof mpv)" ] && [ $quit_mpv = false ]; then echo "mpv process not found, (re)starting..." mpv --shuffle --really-quiet $playlist_path --input-ipc-server=/tmp/mpvsocket & + sleep 0.5 fi - sleep 0.5 - while [ $quit_mpv = false ]; do - path=$(echo '{ "command": ["get_property", "path"] }' | socat - "/tmp/mpvsocket" | jq -r '.data') - if [[ $path != $previous_songs_path ]]; then - clear - name=$(exiftool -Title "$path" | awk -F: '{print $2}') - artist=$(exiftool -Artist "$path" | awk -F: '{print $2}') + path=$(echo '{ "command": ["get_property", "path"] }' | socat - "/tmp/mpvsocket" | jq -r '.data') + if [[ $path != $previous_songs_path ]]; then + clear + name=$(exiftool -Title "$path" | awk -F: '{print $2}') + artist=$(exiftool -Artist "$path" | awk -F: '{print $2}') - echo Song name: $name - echo Artist: $artist + echo Song name: $name + echo Artist: $artist - if [ -n $webpage_path ]; then - echo "