updated waybar and added settings for cn-mate
This commit is contained in:
28
.config/waybar/scripts/alhp.sh
Executable file
28
.config/waybar/scripts/alhp.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Retrieve JSON output from alhp.utils.
|
||||
readonly ALHP_OUTPUT=$(alhp.utils -j)
|
||||
|
||||
# Extract "total" as a string and read "packages" into a Bash array.
|
||||
readonly total=$(echo "$ALHP_OUTPUT" | jq -r '.total | tostring')
|
||||
readarray -t packages < <(echo "$ALHP_OUTPUT" | jq -r '.packages[]?')
|
||||
|
||||
# Initialize default tooltip and class.
|
||||
tooltip=''
|
||||
class='good'
|
||||
|
||||
# Use arithmetic evaluation to check if total is greater than 0.
|
||||
if (( total > 0 )); then
|
||||
class='bad'
|
||||
fi
|
||||
|
||||
# If there are any packages, join them with newline as separator.
|
||||
if (( ${#packages[@]} > 0 )); then
|
||||
tooltip=$(IFS=$'\n'; echo "${packages[*]}")
|
||||
else
|
||||
tooltip="All good"
|
||||
fi
|
||||
|
||||
# Generate compact JSON output (all in one line) with jq.
|
||||
jq -nc --arg text "$total" --arg class "$class" --arg tooltip "$tooltip" \
|
||||
'{text: $text, class: $class, tooltip: $tooltip}'
|
Reference in New Issue
Block a user