updated script and styles to show when service is down

This commit is contained in:
2025-05-12 19:36:26 +02:00
parent 516781cf15
commit ca357f2771
3 changed files with 41 additions and 25 deletions

View File

@@ -2,35 +2,45 @@
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
ALHP_OUTPUT=$(alhp.utils -j)
total=$(jq -r '.total' <<<"$ALHP_OUTPUT")
mirror_stale=$(jq -r '.mirror_out_of_date' <<<"$ALHP_OUTPUT")
# defaults # defaults
text="" text=""
tooltip='All good' tooltip='All good'
class='good' class='good'
# safe array even if packages is null # Check if alhp.utils command exists, if not consider it as down
readarray -t packages < <( if ! command -v alhp.utils &> /dev/null; then
jq -r '.packages // [] | .[]' <<<"$ALHP_OUTPUT" tooltip="Service unavailable"
) text=""
class="down"
else
ALHP_OUTPUT=$(alhp.utils -j)
mirror_stale=$(jq -r '.mirror_out_of_date' <<<"$ALHP_OUTPUT")
# 1) Mirror stale? highest priority total=$(jq -r '.total' <<<"$ALHP_OUTPUT")
if [[ "$mirror_stale" == "true" ]]; then mirror_stale=$(jq -r '.mirror_out_of_date' <<<"$ALHP_OUTPUT")
class="stale"
tooltip="Mirror is out of date" # safe array even if packages is null
# 2) Any pending PKGBUILDs? readarray -t packages < <(
elif (( total > 0 )); then jq -r '.packages // [] | .[]' <<<"$ALHP_OUTPUT"
class="bad" )
text="$total"
tooltip=$(printf "%s\n" "${packages[@]}") # 1) Mirror stale? highest priority
if [[ "$mirror_stale" == "true" ]]; then
class="stale"
tooltip="Mirror is out of date"
# 2) Any pending PKGBUILDs?
elif (( total > 0 )); then
class="bad"
text="$total"
tooltip=$(printf "%s\n" "${packages[@]}")
fi
fi fi
case "$class" in case "$class" in
good) icon="";; good) icon="";;
stale) icon="󰏖";; stale) icon="󰏖";;
bad) icon="󰏗";; bad) icon="󰏗";;
down) icon="x";;
esac esac
# Emit compact JSON for Statusbar # Emit compact JSON for Statusbar

View File

@@ -194,11 +194,14 @@ tooltip label {
padding-right: 5px; padding-right: 5px;
} }
#custom-alhp.good { #custom-alhp.good {
border-bottom: 1px solid greenyellow; border-bottom: 1px solid #adff2f;
} }
#custom-alhp.stale { #custom-alhp.stale {
border-bottom: 1px solid yellow; border-bottom: 1px solid #f6ac00;
} }
#custom-alhp.bad { #custom-alhp.bad {
border-bottom: 1px solid orangered; border-bottom: 1px solid #ff4500;
}
#custom-alhp.down {
border-bottom: 1px solid #800000;
} }

View File

@@ -191,15 +191,18 @@ tooltip label{
} }
#custom-alhp { #custom-alhp {
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
} }
#custom-alhp.good { #custom-alhp.good {
border-bottom: 1px solid greenyellow; border-bottom: 1px solid #adff2f;
} }
#custom-alhp.stale { #custom-alhp.stale {
border-bottom: 1px solid yellow; border-bottom: 1px solid #f6ac00;
} }
#custom-alhp.bad { #custom-alhp.bad {
border-bottom: 1px solid orangered; border-bottom: 1px solid #ff4500;
}
#custom-alhp.down {
border-bottom: 1px solid #800000;
} }