Add spotify to polybar
This commit is contained in:
BIN
dotfiles/fonts/Inconsolata Regular Nerd Font Complete.ttf
Normal file
BIN
dotfiles/fonts/Inconsolata Regular Nerd Font Complete.ttf
Normal file
Binary file not shown.
Binary file not shown.
@@ -4,7 +4,7 @@ green = #00d3a8
|
|||||||
|
|
||||||
accent = ${self.green}
|
accent = ${self.green}
|
||||||
background = #18191E
|
background = #18191E
|
||||||
foreground = #000000
|
foreground = #fff
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
[font]
|
[font]
|
||||||
@@ -25,14 +25,14 @@ height = 35
|
|||||||
#padding-left = 0.5
|
#padding-left = 0.5
|
||||||
padding-right = 1
|
padding-right = 1
|
||||||
|
|
||||||
foreground = ${colors.background}
|
foreground = ${colors.foreground}
|
||||||
background = ${colors.background}
|
background = ${colors.background}
|
||||||
|
|
||||||
module-margin = 1
|
module-margin = 1
|
||||||
|
|
||||||
modules-left = i3tabs title
|
modules-left = i3tabs title
|
||||||
modules-center = date
|
modules-center = date
|
||||||
modules-right = backlight network volume battery
|
modules-right = spotify backlight network volume battery
|
||||||
separator =
|
separator =
|
||||||
|
|
||||||
dim-value = 1.0
|
dim-value = 1.0
|
||||||
@@ -89,13 +89,15 @@ enable-click = true
|
|||||||
enable-scroll = false
|
enable-scroll = false
|
||||||
wrapping-scroll = false
|
wrapping-scroll = false
|
||||||
|
|
||||||
|
format = <label-state> <label-mode>
|
||||||
|
|
||||||
foreground = ${colors.accent}
|
foreground = ${colors.accent}
|
||||||
background = #383D41
|
background = #383D41
|
||||||
|
|
||||||
label-focused = %index%
|
label-focused = %index%
|
||||||
label-focused-foreground = ${self.foreground}
|
label-focused-foreground = ${self.foreground}
|
||||||
label-focused-background = ${self.background}
|
label-focused-background = ${self.background}
|
||||||
label-focused-underline = #fba922
|
label-focused-underline = #fff
|
||||||
label-focused-padding = 2
|
label-focused-padding = 2
|
||||||
|
|
||||||
label-unfocused = %index%
|
label-unfocused = %index%
|
||||||
@@ -214,3 +216,10 @@ bar-width = 10
|
|||||||
bar-indicator = |
|
bar-indicator = |
|
||||||
bar-fill = -
|
bar-fill = -
|
||||||
bar-empty = -
|
bar-empty = -
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
[module/spotify]
|
||||||
|
type = custom/script
|
||||||
|
exec = ~/.config/polybar/spotify.sh %artist% - %title%
|
||||||
|
tail = true
|
||||||
|
interval = 2
|
||||||
|
|||||||
23
dotfiles/polybar/spotify.sh
Executable file
23
dotfiles/polybar/spotify.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if ! pgrep -x spotify >/dev/null; then
|
||||||
|
echo ""; exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd="org.freedesktop.DBus.Properties.Get"
|
||||||
|
domain="org.mpris.MediaPlayer2"
|
||||||
|
path="/org/mpris/MediaPlayer2"
|
||||||
|
|
||||||
|
meta=$(dbus-send --print-reply --dest=${domain}.spotify \
|
||||||
|
/org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:${domain}.Player string:Metadata)
|
||||||
|
|
||||||
|
artist=$(echo "$meta" | sed -nr '/xesam:artist"/,+2s/^ +string "(.*)"$/\1/p' | tail -1 | sed 's/\&/\\&/g' | sed 's#\/#\\/#g')
|
||||||
|
album=$(echo "$meta" | sed -nr '/xesam:album"/,+2s/^ +variant +string "(.*)"$/\1/p' | tail -1| sed 's/\&/\\&/g'| sed 's#\/#\\/#g')
|
||||||
|
title=$(echo "$meta" | sed -nr '/xesam:title"/,+2s/^ +variant +string "(.*)"$/\1/p' | tail -1 | sed 's/\&/\\&/g'| sed 's#\/#\\/#g')
|
||||||
|
|
||||||
|
echo "${*:-%artist% - %title%}" | sed "s/%artist%/$artist/g;s/%title%/$title/g;s/%album%/$album/g"i | sed "s/\&/\&/g" | sed "s#\/#\/#g"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user