Add polybar mpris script

This commit is contained in:
Tobias Reisinger 2022-03-02 16:58:03 +01:00
parent c8008bc611
commit b804c8b447
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
3 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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}

View file

@ -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