1
1
mirror of https://github.com/nboughton/dotfiles synced 2024-11-22 23:51:57 +01:00
github.com-nboughton-dotfiles/waybar/modules/spotify.sh
2020-12-02 20:13:47 +00:00

20 lines
508 B
Bash
Executable File

#!/bin/bash
class=$(playerctl metadata --player=spotify --format '{{lc(status)}}')
icon=""
limit=100
if [[ $class == "playing" ]]; then
info=$(playerctl metadata --player=spotify --format '{{artist}} {{album}} - {{title}}' | sed 's/"//g')
if [[ ${#info} -gt $limit ]]; then
info=$(echo $info | cut -c1-$limit)"..."
fi
text=$icon" "$info
elif [[ $class == "paused" ]]; then
text=$icon
elif [[ $class == "stopped" ]]; then
text=""
fi
echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"