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

20 lines
461 B
Bash
Raw Normal View History

#!/bin/sh
2023-09-08 03:50:02 +00:00
class=$(playerctl metadata --format '{{lc(status)}}')
2023-09-09 00:50:02 +00:00
icon="󰎆"
if [[ $class == "playing" ]]; then
2023-09-08 03:50:02 +00:00
info=$(playerctl metadata --format '{{artist}} - {{title}}')
if [[ ${#info} > 40 ]]; then
2023-09-08 03:50:02 +00:00
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"\"}"