Arch Linux - Pacman Hooks

Place any of these in /etc/pacman.d/hooks.

Perform snapper snapshots before and after pacman operations

See snap-pac.

Clean pacman cache

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *

[Action]
Description = Cleaning pacman cache...
Depends = pacman-contrib
When = PostTransaction
Exec = /usr/bin/paccache -rv

Check for orphans

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *

[Action]
Description = Checking for orphans...
When = PostTransaction
Exec = /usr/bin/bash -c "for i in $(pacman -Qqtd); do echo '-->' $i; done"

Check for package removed from remote database

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *

[Action]
Description = Checking for packages not in sync databases...
When = PostTransaction
Exec = /usr/bin/bash -c "for i in $(pacman -Qqm); do echo '-->' $i; done"
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = linux

[Action]
Description = Symlinking old kernel modules...
When = PostTransaction
Exec = /usr/bin/bash -c "find /usr/lib/modules -xtype l -delete; ln -sv /.snapshots/$(snapper -c root list | awk 'END{print $1}')/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/"