1
1
mirror of https://github.com/nboughton/dotfiles synced 2024-11-23 09:02:00 +01:00
github.com-nboughton-dotfiles/waybar/modules/spotify.sh

20 lines
507 B
Bash
Raw Normal View History

2020-11-29 03:47:19 +01:00
#!/bin/bash
2020-11-20 21:33:51 +01:00
class=$(playerctl metadata --player=spotify --format '{{lc(status)}}')
icon=""
2020-11-29 03:47:19 +01:00
limit=50
2020-11-20 21:33:51 +01:00
if [[ $class == "playing" ]]; then
info=$(playerctl metadata --player=spotify --format '{{artist}} {{album}} - {{title}}' | sed 's/"//g')
2020-11-29 03:47:19 +01:00
if [[ ${#info} -gt $limit ]]; then
info=$(echo $info | cut -c1-$limit)"..."
2020-11-20 21:33:51 +01:00
fi
text=$icon" "$info
elif [[ $class == "paused" ]]; then
text=$icon
elif [[ $class == "stopped" ]]; then
text=""
fi
echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"