1
1
mirror of https://github.com/nboughton/dotfiles synced 2024-11-26 13:33:54 +01:00
github.com-nboughton-dotfiles/waybar/modules/spotify.sh

20 lines
508 B
Bash
Raw Permalink 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-12-02 21:13:47 +01:00
limit=100
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"\"}"