chezmoi/scripts/executable_mail.status.sh

27 lines
714 B
Bash

#!/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