dotfiles/.config/waybar/spotify.sh
2022-02-25 06:15:40 -08:00

22 lines
454 B
Bash
Executable file

#!/usr/bin/bash
MCLASS=$(playerctl metadata --player=spotify --format '{{lc(status)}}')
MICON="🎵"
if [[ $MCLASS == "playing" ]]; then
MINFO=$(playerctl metadata --player=spotify --format '{{artist}} - {{title}}')
if [[ ${#MINFO} > 35 ]];
then
MINFO=$(echo $MINFO | cut -c1-35)"..."
fi
MTEXT=" "$MICON" "$MINFO" "
elif [[ $class == "paused" ]];
then
MTEXT=$MICON" (paused) "
elif [[ $class == "stopped" ]];
then
MTEXT=""
fi
printf "$MTEXT"