#!/bin/bash # # Dependencies: # MPV # exiftool # jq # #set -x config_path="$HOME/.config/mpvmusic/config.sh" if [ -f $config_path ]; then echo "config exists" else install -Dv example_config.sh $config_path fi source $config_path previous_songs_path="" export quit_mpv=false kill -9 $(pidof mpv) > /dev/null 2>&1 handle_sigint() { echo "Quitting..." export quit_mpv=true echo $quit_mpv pkill -9 $$ kill -9 $(pgrep mpv) exit 0 } trap handle_sigint SIGINT while [ $quit_mpv = false ]; do 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 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 if [ -n $webpage_path ]; then echo "