Added spotify to polybar

main
guusvanmeerveld 2 years ago
parent f472e1cf60
commit 1131349511

@ -6,8 +6,9 @@
# Chromium
- ungoogled-chromium
# Spotifyd
- spotify-tui-bin
# Spotify
- spotify
- spicetify-cli
- spotifyd
- discord

@ -33,29 +33,6 @@ alert = #bd2c40
[constants]
height = 40
margin-top = 10
[bar/workspace]
font-0 = Roboto:pixelsize=13;1
font-1 = Material Icons:pixelsize=15;4
width = 390
height = ${constants.height}
radius = 20
fixed-center = true
offset-x = 5
offset-y = ${constants.margin-top}
background = ${colors.background}
foreground = ${colors.foreground}
modules-center = bspwm
wm-restack = bspwm
cursor-click = pointer
[bar/system]
font-0 = Roboto:pixelsize=13;1
@ -64,51 +41,23 @@ font-1 = Material Icons:pixelsize=15;4
background = ${colors.background}
foreground = ${colors.foreground}
radius = 20
fixed-center = true
offset-y = ${constants.margin-top}
offset-x = 70%:10
padding-right = 5
width = 26.5%
height = ${constants.height}
module-margin-right = 2
module-margin-left = 2
modules-right = temperature memory cpu battery wlan eth date
modules-left = bspwm
modules-center = spotify spotify-prev spotify-play-pause spotify-next
modules-right = temperature memory cpu battery wlan eth date powermenu
wm-restack = bspwm
cursor-click = pointer
[bar/power]
font-0 = Roboto:pixelsize=13;1
font-1 = Material Icons:pixelsize=15;4
background = ${colors.primary}
foreground = ${colors.foreground}
radius = 20
fixed-center = true
offset-y = ${constants.margin-top}
offset-x = 97%:10
width = ${constants.height}
height = ${constants.height}
modules-center = powermenu
wm-restack = bspwm
cursor-click = pointer
cursor-scroll = default
click-left = ~/.config/polybar/scripts/power-menu.sh &
[settings]
screenchange-reload = true

@ -0,0 +1,26 @@
[module/spotify]
type = custom/script
tail = true
format-prefix = 
format = <label>
exec = ~/.config/polybar/scripts/scroll_spotify_status.sh
[module/spotify-prev]
type = custom/script
exec = echo 
format = <label>
click-left = playerctl previous -p spotify
[module/spotify-play-pause]
type = custom/ipc
hook-0 = echo 
hook-1 = echo 
initial = 1
click-left = playerctl play-pause -p spotify
[module/spotify-next]
type = custom/script
exec = echo 
format = <label>
click-left = playerctl next -p spotify

@ -46,7 +46,9 @@ interface = enp1s0
interval = 3.0
label-connected = 
label-connected =  %downspeed%
format-connected = <label-connected>
label-disconnected = 

@ -0,0 +1,50 @@
#!/bin/bash
# The name of polybar bar which houses the main spotify module and the control modules.
PARENT_BAR="now-playing"
PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
# Set the source audio player here.
# Players supporting the MPRIS spec are supported.
# Examples: spotify, vlc, chrome, mpv and others.
# Use `playerctld` to always detect the latest player.
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
PLAYER="spotify"
# Format of the information displayed
# Eg. {{ artist }} - {{ album }} - {{ title }}
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
FORMAT="{{ title }} - {{ artist }}"
# Sends $2 as message to all polybar PIDs that are part of $1
update_hooks() {
while IFS= read -r id
do
polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
done < <(echo "$1")
}
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
STATUS=$PLAYERCTL_STATUS
else
STATUS="No player is running"
fi
if [ "$1" == "--status" ]; then
echo "$STATUS"
else
if [ "$STATUS" = "Stopped" ]; then
echo "No music is playing"
elif [ "$STATUS" = "Paused" ]; then
update_hooks "$PARENT_BAR_PID" 2
playerctl --player=$PLAYER metadata --format "$FORMAT"
elif [ "$STATUS" = "No player is running" ]; then
echo "$STATUS"
else
update_hooks "$PARENT_BAR_PID" 1
playerctl --player=$PLAYER metadata --format "$FORMAT"
fi
fi

@ -0,0 +1,12 @@
#!/bin/bash
# see man zscroll for documentation of the following parameters
zscroll -l 30 \
--delay 0.1 \
--scroll-padding "  " \
--match-command "`dirname $0`/get_spotify_status.sh --status" \
--match-text "Playing" "--scroll 1" \
--match-text "Paused" "--scroll 0" \
--update-check true "`dirname $0`/get_spotify_status.sh" &
wait

@ -22,6 +22,7 @@
- rofi
- papirus-icon-theme
- playerctl
- zscroll-git
# Qt
- qt5-graphicaleffects