add garbage collection info to polybar

main
maia arson crimew 2022-06-03 19:32:24 +02:00
parent 80921d661b
commit 73900c6833
2 changed files with 49 additions and 1 deletions

View File

@ -57,7 +57,7 @@ font-1 = JetBrainsMono NerdFont;2
modules-left = bspwm xwindow modules-left = bspwm xwindow
modules-center = date modules-center = date
modules-right = eth pulseaudio xkeyboard memory cpu modules-right = real eth pulseaudio xkeyboard memory cpu
cursor-click = pointer cursor-click = pointer
cursor-scroll = ns-resize cursor-scroll = ns-resize
@ -243,6 +243,16 @@ ramp-capacity-3 = 
ramp-capacity-4 = ramp-capacity-4 =
ramp-capacity-foreground = ${colors.primary} ramp-capacity-foreground = ${colors.primary}
[module/real]
type = custom/script
interval = 10800
format-prefix = "屢 "
format-prefix-foreground = ${colors.primary}
exec = ~/.config/polybar/scripts/real.sh
[settings] [settings]
screenchange-reload = true screenchange-reload = true
pseudo-transparency = false pseudo-transparency = false

38
.config/polybar/scripts/real.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
gemeinde=13
sammelgebiet=1008
today="$(date +%Y-%m-%d)"
tomorrow="$(date --date='tomorrow' +%Y-%m-%d)"
this_year="$(date +%Y)"
next_year="$(date --date='next year' +%Y)"
function format_collections {
if [[ "$1" == *"Kehricht"* ]]; then
echo -n " "
fi
if [[ "$1" == *"Grüngut"* ]]; then
echo -n " "
fi
if [[ "$1" == *"Karton"* ]]; then
echo -n " "
fi
if [[ "$1" == *"Alteisen"* ]]; then
echo -n " "
fi
if [[ "$1" == *"Papier"* ]]; then
echo -n " "
fi
}
data="$(curl -s "https://www.real.sammelkalender.ch/app/appSammeldaten.php?nGem=$gemeinde&nAbar=null&nSage=$sammelgebiet&jahr1=$this_year&jahr2=$next_year")"
collection_today="$(echo "$data" | jq -r ".[] | select(.DATUM == \"$today\") | .AbarOne")"
collection_tomorrow="$(echo "$data" | jq -r ".[] | select(.DATUM == \"$tomorrow\") | .AbarOne")"
if [[ "$collection_today" != "null" ]]; then
format_collections $collection_today
fi
if [[ "$collection_tomorrow" != "null" ]]; then
echo "tomorrow: $(format_collections $collection_tomorrow)"
fi