Accept zero-padded threshold, simplify fwupdmgr check
This commit is contained in:
+2
-2
@@ -15,6 +15,7 @@ declare -A KERNELS=(
|
|||||||
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/update-notify"
|
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/update-notify"
|
||||||
|
|
||||||
[[ $threshold =~ ^[0-9]+$ ]] || { echo "Threshold must be a number" >&2; exit 1; }
|
[[ $threshold =~ ^[0-9]+$ ]] || { echo "Threshold must be a number" >&2; exit 1; }
|
||||||
|
threshold=$((10#$threshold)) # force base 10, so e.g. "08" isn't read as octal
|
||||||
mkdir -p "$state_dir"
|
mkdir -p "$state_dir"
|
||||||
|
|
||||||
# notify-send from cron/systemd needs the session bus address
|
# notify-send from cron/systemd needs the session bus address
|
||||||
@@ -137,8 +138,7 @@ if (( over_threshold )); then
|
|||||||
# fwupdmgr get-updates exits 0 when updates are available, 2 when there are none.
|
# 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.
|
# --no-metadata-check avoids prompting/refreshing; the fwupd-refresh timer keeps metadata fresh.
|
||||||
if command -v fwupdmgr >/dev/null 2>&1; then
|
if command -v fwupdmgr >/dev/null 2>&1; then
|
||||||
timeout 30 fwupdmgr get-updates --no-metadata-check </dev/null >/dev/null 2>&1
|
if timeout 30 fwupdmgr get-updates --no-metadata-check </dev/null >/dev/null 2>&1; then
|
||||||
if (( $? == 0 )); then
|
|
||||||
reminders+=("fwupdmgr (firmware updates available)")
|
reminders+=("fwupdmgr (firmware updates available)")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user