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.
This commit is contained in:
@@ -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 <pkg> <newver>
|
||||
kernel <custom-pkg> <stock-ver>
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
|
||||
Executable
+10
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user