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

20 lines
461 B
Bash
Raw Permalink Normal View History

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