summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Schanzenbacher <ryan@rschanz.org>2023-09-07 23:50:02 -0400
committerRyan Schanzenbacher <ryan@rschanz.org>2023-09-07 23:50:02 -0400
commitf9f087f055dcca066b74da159a448ed227f26e7e (patch)
treeba1f6fbe3369352cb76690209286dcbe1cea3fb0
parente8351e69e99e35c42e9a04551e2c3d7aabf870da (diff)
added music info to waybar
-rw-r--r--home-config/waybar/config4
-rwxr-xr-xhome-config/waybar/modules/check-for-music.sh7
-rwxr-xr-xhome-config/waybar/modules/spotify.sh8
3 files changed, 13 insertions, 6 deletions
diff --git a/home-config/waybar/config b/home-config/waybar/config
index 677c60c..731c119 100644
--- a/home-config/waybar/config
+++ b/home-config/waybar/config
@@ -75,9 +75,9 @@
75 "interval": 2, 75 "interval": 2,
76 "return-type": "json", 76 "return-type": "json",
77 "exec": "~/.config/waybar/modules/spotify.sh", 77 "exec": "~/.config/waybar/modules/spotify.sh",
78 "exec-if": "pgrep spotifyd", 78 "exec-if": "~/.config/waybar/modules/check-for-music.sh",
79 "escape": true, 79 "escape": true,
80 "on-click": "~/.config/waybar/modules/spotify-play-pause.sh play-pause" 80 "on-click": "playerctl play-pause"
81 }, 81 },
82 "custom/storage": { 82 "custom/storage": {
83 "format-alt": "{} ", 83 "format-alt": "{} ",
diff --git a/home-config/waybar/modules/check-for-music.sh b/home-config/waybar/modules/check-for-music.sh
new file mode 100755
index 0000000..3b735a2
--- /dev/null
+++ b/home-config/waybar/modules/check-for-music.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2
3if [[ $(playerctl metadata --format '{{lc(status)}}' | grep playing) -eq 0 ]]; then
4 exit 0
5else
6 exit 1
7fi
diff --git a/home-config/waybar/modules/spotify.sh b/home-config/waybar/modules/spotify.sh
index a75136c..3368d88 100755
--- a/home-config/waybar/modules/spotify.sh
+++ b/home-config/waybar/modules/spotify.sh
@@ -1,12 +1,12 @@
1#!/bin/sh 1#!/bin/sh
2 2
3class=$(playerctl metadata --player=spotifyd --format '{{lc(status)}}') 3class=$(playerctl metadata --format '{{lc(status)}}')
4icon="" 4icon="󰽴"
5 5
6if [[ $class == "playing" ]]; then 6if [[ $class == "playing" ]]; then
7 info=$(playerctl metadata --player=spotifyd --format '{{artist}} - {{title}}') 7 info=$(playerctl metadata --format '{{artist}} - {{title}}')
8 if [[ ${#info} > 40 ]]; then 8 if [[ ${#info} > 40 ]]; then
9 info=$(echo $info | cut -c1-40)"..." 9 info=$(playerctl metadata --format '{{title}}' | cut -c1-40)"..."
10 fi 10 fi
11 text=$info" "$icon 11 text=$info" "$icon
12elif [[ $class == "paused" ]]; then 12elif [[ $class == "paused" ]]; then