home-config/waybar/modules/spotify.sh
9f69bb20dff2ee270d823e1d0688ab04c41435de
· 461 B · 19 lines
raw
| 1 | #!/bin/sh |
| 2 | |
| 3 | class=$(playerctl metadata --format '{{lc(status)}}') |
| 4 | icon="" |
| 5 | |
| 6 | if [[ $class == "playing" ]]; then |
| 7 | info=$(playerctl metadata --format '{{artist}} - {{title}}') |
| 8 | if [[ ${#info} > 40 ]]; then |
| 9 | info=$(playerctl metadata --format '{{title}}' | cut -c1-40)"..." |
| 10 | fi |
| 11 | text=$info" "$icon |
| 12 | elif [[ $class == "paused" ]]; then |
| 13 | text=$icon |
| 14 | elif [[ $class == "stopped" ]]; then |
| 15 | text="" |
| 16 | fi |
| 17 | |
| 18 | echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}" |
| 19 |