summaryrefslogtreecommitdiff
path: root/home-config/waybar/modules/spotify.sh
diff options
context:
space:
mode:
Diffstat (limited to 'home-config/waybar/modules/spotify.sh')
-rwxr-xr-xhome-config/waybar/modules/spotify.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/home-config/waybar/modules/spotify.sh b/home-config/waybar/modules/spotify.sh
new file mode 100755
index 0000000..a75136c
--- /dev/null
+++ b/home-config/waybar/modules/spotify.sh
@@ -0,0 +1,19 @@
1#!/bin/sh
2
3class=$(playerctl metadata --player=spotifyd --format '{{lc(status)}}')
4icon=""
5
6if [[ $class == "playing" ]]; then
7 info=$(playerctl metadata --player=spotifyd --format '{{artist}} - {{title}}')
8 if [[ ${#info} > 40 ]]; then
9 info=$(echo $info | cut -c1-40)"..."
10 fi
11 text=$info" "$icon
12elif [[ $class == "paused" ]]; then
13 text=$icon
14elif [[ $class == "stopped" ]]; then
15 text=""
16fi
17
18echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"
19