diff options
author | Ryan Schanzenbacher <ryan@rschanz.org> | 2023-09-07 23:50:02 -0400 |
---|---|---|
committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2023-09-07 23:50:02 -0400 |
commit | f9f087f055dcca066b74da159a448ed227f26e7e (patch) | |
tree | ba1f6fbe3369352cb76690209286dcbe1cea3fb0 | |
parent | e8351e69e99e35c42e9a04551e2c3d7aabf870da (diff) |
added music info to waybar
-rw-r--r-- | home-config/waybar/config | 4 | ||||
-rwxr-xr-x | home-config/waybar/modules/check-for-music.sh | 7 | ||||
-rwxr-xr-x | home-config/waybar/modules/spotify.sh | 8 |
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 | |||
3 | if [[ $(playerctl metadata --format '{{lc(status)}}' | grep playing) -eq 0 ]]; then | ||
4 | exit 0 | ||
5 | else | ||
6 | exit 1 | ||
7 | fi | ||
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 | ||
3 | class=$(playerctl metadata --player=spotifyd --format '{{lc(status)}}') | 3 | class=$(playerctl metadata --format '{{lc(status)}}') |
4 | icon="" | 4 | icon="" |
5 | 5 | ||
6 | if [[ $class == "playing" ]]; then | 6 | if [[ $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 |
12 | elif [[ $class == "paused" ]]; then | 12 | elif [[ $class == "paused" ]]; then |