summaryrefslogtreecommitdiff
path: root/home-config/waybar/modules/spotify.sh
blob: fc732a1f2e68e0052824df7ecfc88b1fe4327380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

class=$(playerctl metadata --format '{{lc(status)}}')
icon="󰎆"

if [[ $class == "playing" ]]; then
  info=$(playerctl metadata --format '{{artist}} - {{title}}')
  if [[ ${#info} > 40 ]]; then
    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"\"}"