#!/bin/sh
set -eu

CUR_PATH="$HOME/.cache/andreh/mpris-player.txt"
mkdir -p "$(dirname "$CUR_PATH")"
touch "$CUR_PATH"

while true; do
  CUR="$(cat "$CUR_PATH")"
  if [ "$(playerctl --player="$CUR" status)" = 'Paused' ]; then
    printf '%s\n' "$CUR"
  else
    printf "%s: %s\n" "$CUR" "$(playerctl --player="$CUR" metadata xesam:title)"
  fi
  sleep 1
done
