Update Polybar

This commit is contained in:
Marco Thomas
2021-02-10 09:17:40 +01:00
parent f2d5836710
commit 873f33b14f
3 changed files with 44 additions and 8 deletions

View File

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

View File

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