dotfiles/waybar/.config/waybar/spotifyd.sh

16 lines
492 B
Bash
Executable File

#!/bin/sh
track_info () {
metadata="$(playerctl metadata -p 'spotifyd' --format '{{status}}|{{xesam:title}} - {{xesam:artist}}')"
state="$(echo -n "$metadata" | awk -F '|' '{print $1}')"
info="$(echo -n "$metadata" | awk -F '|' '{print $2}')"
if [ "$state" = "Paused" ]; then
echo -n "\uf28b $info"
elif [ "$state" = "Playing" ]; then
echo -n " $info"
fi
}
echo "{\"text\": \"$(track_info)\", \"class\": \"custom-spotifyd\", \"alt\": \"spotifyd\"}"