#!/bin/sh

playerctlstatus=$(playerctl status 2> /dev/null)
track="$(playerctl metadata "xesam:artist") - $(playerctl metadata "xesam:title")"
track=$(echo "$track" | cut -c1-40)
loop=$(playerctl loop)
shuffle=$(playerctl shuffle)

if [ "$loop" = "Playlist" ]
then
    loop_icon=""
elif [ "$loop" = "Track" ]
then
    loop_icon=""
elif [ "$loop" = "None" ]
then
    loop_icon=""
fi

if [ "$shuffle" = "Off" ]
then
    shuffle_icon=""
elif [ "$shuffle" = "On" ]
then
    shuffle_icon=""
fi


if [ "$playerctlstatus" = "" ]
then
    echo ""
elif [ "$playerctlstatus" = "Playing" ]
then
    echo "$track ^b#282828^^c#dfdfdf^ ▶️  $loop_icon  $shuffle_icon ^d^"
elif [ "$playerctlstatus" = "Paused" ]
then
    echo "^b#282828^^c#dfdfdf^   $loop_icon  $shuffle_icon ^d^"
fi