Touch most recent kernel on update to set default for rEFInd

Hi everyone :slight_smile:

I’ve been very happy with Manjaro for more than two years at this point, but I’ve been annoyed that when I do a kernel update, rEFInd switches to an older version as it’s often an older version, that is the last to be modified during an update.

I wanted to fix this issue by running a hook after the kernel update, which touches the latest version, as I think that would solve the issue. I put the hook in /etc/pacman.d/hooks/, but when I updated the kernel earlier today it did not touch the kernel as expected (I’m not sure the hook was actually triggered).

Are there any reason the hook didn’t function as expected? Alternatively, is there a smarter way to get rEFInd to pick the latest kernel version as default that doesn’t require a hook?

Pacman hook:

Operation = Upgrade
Operation = Install
Type = Package
Target = linux

Description = Touch most recent vmlinuz when kernel is updated or installed
When = PostTransaction
Exec = touch $(ls /boot/vmlinuz* | sort -V | tail -n1)

In not sure 100% but if I recall it right, it should be

Type = Path
Target = /boot/vmlinuz*

Check Arch Wiki’s pages for Secure Boot, systemd-boot, etc, there should be some examples of pacman hooks of this sort.