diff --git a/.config/polybar/bars.ini b/.config/polybar/bars.ini index a5fb179..7f1376d 100644 --- a/.config/polybar/bars.ini +++ b/.config/polybar/bars.ini @@ -51,7 +51,7 @@ inherit = bar/base modules-left = bspwm - modules-center = mpd + modules-center = mpd player-mpris-simple modules-right = openweather memory cpu temperature eth check-arch-updates date eth-interface = enp0s31f6 diff --git a/.config/polybar/custom.ini b/.config/polybar/custom.ini index 1ac8663..1a38b6f 100644 --- a/.config/polybar/custom.ini +++ b/.config/polybar/custom.ini @@ -53,3 +53,14 @@ format-prefix-foreground = ${colors.foreground} format-underline = ${colors.green} + +[module/player-mpris-simple] + type = custom/script + exec = $HOME/.config/polybar/scripts/player-mpris-simple.sh + interval = 3 + click-left = playerctl previous & + click-right = playerctl next & + click-middle = playerctl play-pause & + + format-prefix-foreground = ${colors.foreground} + format-underline = ${colors.green} diff --git a/.config/polybar/scripts/player-mpris-simple.sh b/.config/polybar/scripts/player-mpris-simple.sh new file mode 100755 index 0000000..f8bee72 --- /dev/null +++ b/.config/polybar/scripts/player-mpris-simple.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +alias playerctl="playerctl -p spotifyd" + +player_status=$(playerctl status 2> /dev/null) + +if [ "$player_status" = "Playing" ]; then + echo " $(playerctl metadata -f '{{title}} - {{artist}} | {{duration(position)}}/{{duration(mpris:length)}}')" +elif [ "$player_status" = "Paused" ]; then + echo " $(playerctl metadata -f '{{title}} - {{artist}} | {{duration(position)}}/{{duration(mpris:length)}}')" +else + echo "" +fi