Make fwupdmgr hint conditional

Only show fwupmgr hint if firmware updates are available
Also fold that and git-monitor hint in a single notification
This commit is contained in:
Daniele Fucini
2026-10-04 08:56:47 +02:00
parent eabaa962dc
commit 9f343d98fc
+22 -12
View File
@@ -98,20 +98,30 @@ done
# General updates threshold # General updates threshold
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
if (( updates >= threshold )); then if (( updates >= threshold )); then
notify_once "updates" "Updates available" "Arch: $arch_updates, AUR: $aur_updates" reminders=()
hints=( # Always remind about git packages if git-monitor is installed
"git-monitor|Check git packages|Use git-monitor for git packages updates" if command -v git-monitor >/dev/null 2>&1; then
"fwupdmgr|Check firmware|Use fwupdmgr to check for firmware updates" reminders+=("git-monitor")
)
for hint in "${hints[@]}"; do
IFS='|' read -r cmd title body <<< "$hint"
if command -v "$cmd" >/dev/null 2>&1; then
notify_once "hint-$cmd" "$title" "$body"
fi fi
done
# Firmware: only mention it when updates actually exist.
# fwupdmgr get-updates exits 0 when updates are available, 2 when there are none.
# --no-metadata-check avoids prompting/refreshing; the fwupd-refresh timer keeps metadata fresh.
if command -v fwupdmgr >/dev/null 2>&1; then
timeout 30 fwupdmgr get-updates --no-metadata-check </dev/null >/dev/null 2>&1
if (( $? == 0 )); then
reminders+=("fwupdmgr (firmware updates available)")
fi
fi
body="Arch: $arch_updates, AUR: $aur_updates"
if (( ${#reminders[@]} )); then
printf -v list '%s, ' "${reminders[@]}"
body+=$'\n'"Also check: ${list%, }"
fi
notify_once "updates" "Updates available" "$body"
else else
clear_state "updates" clear_state "updates"
clear_state "hint-git-monitor"
clear_state "hint-fwupdmgr"
fi fi