guix-dotfiles/home-config/waybar/modules/spotify.sh

19 lines
461 B
Bash
Executable file

#!/bin/sh
class=$(playerctl metadata --format '{{lc(status)}}')
icon="󰎆"
if [[ $class == "playing" ]]; then
info=$(playerctl metadata --format '{{artist}} - {{title}}')
if [[ ${#info} > 40 ]]; then
info=$(playerctl metadata --format '{{title}}' | cut -c1-40)"..."
fi
text=$info" "$icon
elif [[ $class == "paused" ]]; then
text=$icon
elif [[ $class == "stopped" ]]; then
text=""
fi
echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"