From f9f087f055dcca066b74da159a448ed227f26e7e Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Thu, 7 Sep 2023 23:50:02 -0400 Subject: [PATCH] added music info to waybar --- home-config/waybar/config | 4 ++-- home-config/waybar/modules/check-for-music.sh | 7 +++++++ home-config/waybar/modules/spotify.sh | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100755 home-config/waybar/modules/check-for-music.sh 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 @@ "interval": 2, "return-type": "json", "exec": "~/.config/waybar/modules/spotify.sh", - "exec-if": "pgrep spotifyd", + "exec-if": "~/.config/waybar/modules/check-for-music.sh", "escape": true, - "on-click": "~/.config/waybar/modules/spotify-play-pause.sh play-pause" + "on-click": "playerctl play-pause" }, "custom/storage": { "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 @@ +#!/bin/sh + +if [[ $(playerctl metadata --format '{{lc(status)}}' | grep playing) -eq 0 ]]; then + exit 0 +else + exit 1 +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 @@ #!/bin/sh -class=$(playerctl metadata --player=spotifyd --format '{{lc(status)}}') -icon="" +class=$(playerctl metadata --format '{{lc(status)}}') +icon="󰽴" if [[ $class == "playing" ]]; then - info=$(playerctl metadata --player=spotifyd --format '{{artist}} - {{title}}') + info=$(playerctl metadata --format '{{artist}} - {{title}}') if [[ ${#info} > 40 ]]; then - info=$(echo $info | cut -c1-40)"..." + info=$(playerctl metadata --format '{{title}}' | cut -c1-40)"..." fi text=$info" "$icon elif [[ $class == "paused" ]]; then