[polybar] Add docker module and fix font issues

This commit is contained in:
Daniel Carrillo 2021-08-08 12:37:07 +02:00
parent 336bb86b35
commit 194c9f125a
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
4 changed files with 38 additions and 6 deletions

View File

@ -58,17 +58,18 @@ fixed-center = true
background = ${colors.background}
foreground = ${colors.foreground}
font-0 = "Droid Sans Mono:size=16:antialias=true;1"
font-0 = "RobotoMono-Regular:size=16:antialias=true;1"
; https://fontawesome.com/cheatsheet/free
font-1 = "FontAwesome:size=16:antialias=true;2"
font-2 = "Material Icons:size=16:antialias=true;1"
font-3 = NotoSans-Regular:size=18:weight=bold:antialias=true;2
font-4 = NotoSans-Regular:size=28:weight=bold:antialias=true;-12
font-3 = "NotoSans-Regular:size=18:weight=bold:antialias=true;2"
font-4 = "NotoSans-Regular:size=28:weight=bold:antialias=true;-12"
font-5 = "FontAwesome:size=21:antialias=true;4"
font-6 = "Font Awesome 5 Brands-Regular-400:size=32:antialias=true;1"
modules-left = polywins
modules-center = custom_date
modules-right = updates cpu_bar memory_bar vpn network_usage alsa_bar
modules-right = updates cpu_bar memory_bar docker vpn network_usage alsa_bar
cursor-click = pointer
cursor-scroll = ns-resize

View File

@ -174,3 +174,10 @@ label-charging = %percentage%% 
format-discharging = <label-discharging>
label-discharging = %percentage%% 
label-full =
[module/docker]
type = custom/script
exec = ~/.config/polybar/scripts/docker
exec-if = docker ps -q
interval = 30
label = "%output%"

24
.config/polybar/scripts/docker Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
declare -A STATUS=(
[running]=#43A047
[exited]=#A14242
[restarting]=#E53935
[dead]=#E53935
[created]=#1A4F76
[paused]=#654321
[removing]=#8E6995
)
output=""
containers=$(docker ps --all --format="{{.State}}")
if [ "$(echo "$containers" | wc -l)" -gt 0 ]; then
for status in "${!STATUS[@]}"; do
count=$(echo "$containers" | grep -c "$status")
if [ "$count" -gt 0 ]; then
output="$output %{F${STATUS[$status]}}$count%{F-}"
fi
done
fi
echo "$output"

View File

@ -58,9 +58,9 @@ while true; do
output=" 0.01 0.01"
fi
echo "$icon $output"
echo "$icon$output"
else
echo "$icon -- --"
echo "$icon-- --"
fi
echo "$current_values">$COUNTER_FILE