From 73900c6833138a37355c69da96eede62e543638d Mon Sep 17 00:00:00 2001 From: maia arson crimew Date: Fri, 3 Jun 2022 19:32:24 +0200 Subject: [PATCH] add garbage collection info to polybar --- .config/polybar/config.ini | 12 ++++++++++- .config/polybar/scripts/real.sh | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 .config/polybar/scripts/real.sh diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index 57ffde8..23085da 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -57,7 +57,7 @@ font-1 = JetBrainsMono NerdFont;2 modules-left = bspwm xwindow modules-center = date -modules-right = eth pulseaudio xkeyboard memory cpu +modules-right = real eth pulseaudio xkeyboard memory cpu cursor-click = pointer cursor-scroll = ns-resize @@ -243,6 +243,16 @@ ramp-capacity-3 =  ramp-capacity-4 =  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] screenchange-reload = true pseudo-transparency = false diff --git a/.config/polybar/scripts/real.sh b/.config/polybar/scripts/real.sh new file mode 100755 index 0000000..a496dc2 --- /dev/null +++ b/.config/polybar/scripts/real.sh @@ -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