From 7b30b247150af658900921bd085328c1d4e27565 Mon Sep 17 00:00:00 2001 From: Daniele Fucini Date: Fri, 16 Oct 2026 09:34:19 +0200 Subject: [PATCH] Refresh after pacman transactions and local repo builds Add a pacman hook that runs update-notify for each logged-in user with the timer active, and a path unit that users can point at their local repo databases to refresh after aur build. --- README.md | 24 +++++++++++++++++++++++- update-notify-refresh | 10 ++++++++++ update-notify.hook | 11 +++++++++++ update-notify.path | 10 ++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 update-notify-refresh create mode 100644 update-notify.hook create mode 100644 update-notify.path diff --git a/README.md b/README.md index 629516f..943ec2d 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,28 @@ systemctl --user enable --now update-notify.timer The timer runs 5 minutes after boot, then every 6 hours. +A pacman hook also runs update-notify after every pacman transaction, for each logged-in user whose timer is active, so the notification and the status bar file are current right after an upgrade. + +### Refresh after building packages + +Building into a local repository (`aur build`, `aur sync`) doesn't run pacman, so the hook can't catch it. To run update-notify whenever a repository changes, add the repository files to watch to `update-notify.path`: + +``` +systemctl --user edit update-notify.path +``` + +``` +[Path] +PathChanged=/home/aur-local/aur-local.db.tar.gz.sig +PathChanged=/home/custom-pkgs/custom-pkgs.db.tar.gz.sig +``` + +Watch the `.db.tar.gz.sig` file for signed repositories, or `.db.tar.gz` for unsigned ones (`.db` is a symlink). Then enable it: + +``` +systemctl --user enable --now update-notify.path +``` + ## Usage ``` @@ -80,7 +102,7 @@ aur kernel ``` -The file reflects the last run. To keep a bar current after an upgrade, drop entries whose installed version (`pacman -Q`) is no longer older than `newver`, or, for `kernel` lines, whose custom build has caught up with `stock-ver` (ignoring `pkgrel`). This only reads local data, so it's cheap to run often. +The file reflects the last run, which the pacman hook and `update-notify.path` keep close to current. To keep a bar current in between, drop entries whose installed version (`pacman -Q`) is no longer older than `newver`, or, for `kernel` lines, whose custom build has caught up with `stock-ver` (ignoring `pkgrel`). This only reads local data, so it's cheap to run often. ## License diff --git a/update-notify-refresh b/update-notify-refresh new file mode 100755 index 0000000..bc34b0a --- /dev/null +++ b/update-notify-refresh @@ -0,0 +1,10 @@ +#!/bin/bash +# Run update-notify for every logged-in user whose timer is active (called by the pacman hook as root) +systemctl list-units --plain --no-legend --state=running 'user@*.service' | +while read -r unit _; do + uid=${unit#user@} + uid=${uid%.service} + user=$(id -nu "$uid") || continue + systemctl --user -M "$user@" is-active --quiet update-notify.timer || continue + systemctl --user -M "$user@" start --no-block update-notify.service +done diff --git a/update-notify.hook b/update-notify.hook new file mode 100644 index 0000000..4cb0f18 --- /dev/null +++ b/update-notify.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Operation = Remove +Type = Package +Target = * + +[Action] +Description = Refreshing update-notify... +When = PostTransaction +Exec = /usr/lib/update-notify/refresh diff --git a/update-notify.path b/update-notify.path new file mode 100644 index 0000000..3734883 --- /dev/null +++ b/update-notify.path @@ -0,0 +1,10 @@ +[Unit] +Description=Run update-notify when a local repository changes + +# Add the repository files to watch with: systemctl --user edit update-notify.path +# e.g. PathChanged=/home/aur-local/aur-local.db.tar.gz.sig +[Path] +Unit=update-notify.service + +[Install] +WantedBy=default.target