diff --git a/dot_dotfiles/polybar/config.tmpl b/dot_dotfiles/polybar/config.tmpl index d8292ae..da24b0b 100644 --- a/dot_dotfiles/polybar/config.tmpl +++ b/dot_dotfiles/polybar/config.tmpl @@ -103,7 +103,7 @@ bottom = false ;border-right-size = 16 ;unused modules - mpd xbacklight backlight-acpi alsa modules-left = i3 -modules-center = temperature battery xkeyboard memory cpu filesystem updates-arch reboot-check xbacklight top-process obelisk-status +modules-center = temperature battery xkeyboard memory cpu filesystem updates-arch reboot-check xbacklight top-process mail-status modules-right = net wifi0 vpn powermenu ; TRAY MANAGEMENT @@ -159,6 +159,12 @@ exec = ~/scripts/obelisk.status.sh tail = false interval = 10 +[module/mail-status] +type = custom/script +exec = ~/scripts/mail.status.sh +tail = false +interval = 10 + [module/top-process] type = custom/script format-prefix = " " diff --git a/scripts/executable_mail.status.sh b/scripts/executable_mail.status.sh new file mode 100644 index 0000000..67dbc05 --- /dev/null +++ b/scripts/executable_mail.status.sh @@ -0,0 +1,26 @@ +#!/bin/bash +STATUSURL=https://mail.nielandt.be +STATUS=$(curl -s -I $STATUSURL 2>/dev/null | head -n 1 | cut -d$' ' -f2) + +# colors +HEALTHY="#b8bb26" +DEGRADED="#fe8019" +FAILED="#fb4934" +UNKNOWN="#928374" + +# echo the status in polybar format +# the {F}x{F-} syntax allows you to color stuff +# could have failed completely (network down etc) +# -z tests for empty string +if [ -z $STATUS ]; then + echo "%{F$FAILED} %{F-}" +# expected statuses, healthy, degraded, failed +elif [ $STATUS = "200" ]; then + echo "%{F$HEALTHY} %{F-}" +#elif [ $STATUS = "degraded" ]; then +# echo "%{F$DEGRADED} %{F-}" +#elif [ $STATUS = "failed" ]; then +# echo "%{F$FAILED} %{F-}" +else + echo "%{F$FAILED} %{F-}" +fi