From ae33917e8a077032616dbeabd390e23702b09e5c Mon Sep 17 00:00:00 2001 From: Daniele Fucini Date: Sun, 4 Oct 2026 08:56:47 +0200 Subject: [PATCH] Make fwupdmgr hint conditional Only show fwupmgr hint if firmware updates are available Also fold that and git-monitor hint in a single notification --- update-notify | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/update-notify b/update-notify index 627fb17..f1b96e5 100755 --- a/update-notify +++ b/update-notify @@ -98,20 +98,30 @@ done # General updates threshold # --------------------------------------------------------------------------- if (( updates >= threshold )); then - notify_once "updates" "Updates available" "Arch: $arch_updates, AUR: $aur_updates" + reminders=() - hints=( - "git-monitor|Check git packages|Use git-monitor for git packages updates" - "fwupdmgr|Check firmware|Use fwupdmgr to check for firmware updates" - ) - 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" + # Always remind about git packages if git-monitor is installed + if command -v git-monitor >/dev/null 2>&1; then + reminders+=("git-monitor") + fi + + # 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 2>&1 + if (( $? == 0 )); then + reminders+=("fwupdmgr (firmware updates available)") fi - done + 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 clear_state "updates" - clear_state "hint-git-monitor" - clear_state "hint-fwupdmgr" fi