diff --git a/README.md b/README.md index e5effaf..8906e5a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ + light + pactl + playerctl -+ spicetify-cli ### Nvim LSP diff --git a/files/.config/polybar/config b/files/.config/polybar/config index 6d362f1..d1a395d 100644 --- a/files/.config/polybar/config +++ b/files/.config/polybar/config @@ -43,7 +43,7 @@ fixed-center = true line-size = 3 -module-margin= 2 +module-margin = 2 font-0 = "Product Sans:pixelsize=9:weight=regular;2" font-1 = "Product Sans:pixelsize=9:weight=bold;2" @@ -68,8 +68,8 @@ modules-left = i3 [bar/info] inherit = bar/main -width = 16% -offset-x = 84%:-133px +width = 17% +offset-x = 83%:-133px modules-center = cpu memory volume date @@ -96,8 +96,6 @@ tray-padding = 1 [bar/music] inherit = bar/main -background = ${colors.background} - width = 18% offset-x = 41% @@ -237,10 +235,12 @@ format-underline = ${colors.accent} [module/spotify] type = custom/script -exec = python ~/.config/polybar/scripts/spotify_status.py -f '{artist}: {song}' +#exec = python ~/.config/polybar/scripts/spotify_status.py -f '{artist}: {song} ' +exec = ~/.config/polybar/scripts/song.sh 2>/dev/null || echo "No player found" interval = 1 +tail = true -format-prefix = "󰓇 " +format-prefix = " 󰓇 " format-underline = ${colors.accent} [module/cpu] diff --git a/files/.config/polybar/scripts/song.sh b/files/.config/polybar/scripts/song.sh new file mode 100755 index 0000000..62a5fa8 --- /dev/null +++ b/files/.config/polybar/scripts/song.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +function scroll () { + prefix="$1" + scrolling="$2" + temp="$(echo "$scrolling"| sed "s/^\(.\{20\}\)\(.*\)$/\1[\2]/"| sed "s/\[ *\]$//"| sed "s/\[.*\]$//")" + suffix="$3" + if [ "$(echo -n $scrolling |wc -c)" -gt 20 ]; then + echo "$prefix%{T7}$temp%{T-}$suffix" + sleep 0.5 + + zscroll -l 20 \ + --delay 0.2 \ + --before-text "$prefix%{T7}" \ + --after-text "%{T-}$suffix" \ + --scroll-padding " " \ + --update-check true "echo '$(get_title)'" & + + wait + else + echo "$prefix%{T8} $temp %{T-}$suffix" + fi +} # + +function get_artist () { + echo "$(playerctl -p spotify metadata --format "{{ artist }}"| sed -e "s/[[(]....*[])]*//g" | sed "s/ *$//"| sed "s/^\(.\{20\}[^ ]*\)\(.*\)$/\1[\2]/"| sed "s/\[ *\]$//"| sed "s/\[.*\]$/.../")" +} # + +function get_title () { + echo "$(playerctl -p spotify metadata --format "{{title}}" | sed 's/'\''/\\'\''/g')" +} # + +[ ! -z "$(playerctl -p spotify status 2>/dev/null)" ] \ + && artist=$(get_artist) \ + && title=$(get_title) \ + && ([ -z "$artist$title" ] && scroll "" "Spotify is not connected on this pc" "" || scroll "%{F#79e6f3}$artist%{F#FFF} [" "$title" "]%{F-}" ) \ + || exit 1