Keep the configured threshold in the pending file

A threshold argument is a one-off override for the notification, so status bars
keep using THRESHOLD from the config.
This commit is contained in:
Daniele Fucini
2026-10-17 11:06:46 +02:00
parent da8505624f
commit ffb15c0954
2 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ systemctl --user enable --now update-notify.path
update-notify [threshold] update-notify [threshold]
``` ```
`threshold` is the minimum number of updates (repo + AUR) before update counts are shown. It overrides the `THRESHOLD` setting below. `threshold` is the minimum number of updates (repo + AUR) before update counts are shown. It overrides the `THRESHOLD` setting below for that run's notification only; the pending file keeps the configured value.
## Configuration ## Configuration
@@ -97,7 +97,7 @@ The content of the last notification is stored in `$XDG_STATE_HOME/update-notify
Each run also writes the pending updates to `$XDG_STATE_HOME/update-notify/pending`, whether or not the threshold is reached, for status bars such as xmobar to read: Each run also writes the pending updates to `$XDG_STATE_HOME/update-notify/pending`, whether or not the threshold is reached, for status bars such as xmobar to read:
``` ```
threshold 30 threshold <THRESHOLD from the config, not the argument>
repo <pkg> <newver> repo <pkg> <newver>
aur <pkg> <newver> aur <pkg> <newver>
kernel <custom-pkg> <stock-ver> kernel <custom-pkg> <stock-ver>
+8 -3
View File
@@ -19,10 +19,15 @@ if [[ -r $config_file ]]; then
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$config_file" source "$config_file"
fi fi
config_threshold=$THRESHOLD # written to the pending file, so a one-off argument doesn't change status bars
THRESHOLD=${1:-$THRESHOLD} THRESHOLD=${1:-$THRESHOLD}
[[ $THRESHOLD =~ ^[0-9]+$ ]] || { echo "Threshold must be a number" >&2; exit 1; } for t in "$config_threshold" "$THRESHOLD"; do
THRESHOLD=$((10#$THRESHOLD)) # force base 10, so e.g. "08" isn't read as octal [[ $t =~ ^[0-9]+$ ]] || { echo "Threshold must be a number" >&2; exit 1; }
done
# force base 10, so e.g. "08" isn't read as octal
config_threshold=$((10#$config_threshold))
THRESHOLD=$((10#$THRESHOLD))
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
@@ -130,7 +135,7 @@ done
# Pending list for status bars, one "<source> <pkg> <newver>" per line # Pending list for status bars, one "<source> <pkg> <newver>" per line
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
{ {
printf 'threshold %s\n' "$THRESHOLD" printf 'threshold %s\n' "$config_threshold"
for item in "${arch_list[@]}"; do for item in "${arch_list[@]}"; do
read -r pkg _ _ new <<< "$item" read -r pkg _ _ new <<< "$item"
printf 'repo %s %s\n' "$pkg" "$new" printf 'repo %s %s\n' "$pkg" "$new"