Systemd-bootloader won't remember latest kernel

Greetings lovely people,

I have both linux and linux-lts kernels installed. I usually just boot into the main kernel and use linux-lts only if I encounter any major issues with the latest kernel, which isn’t that often, at least on my hardware. On boot, systemd-bootoader always defaults to the linux-lts kernel. I’d like to have it set up so that on boot, reboot, or even on kernel/nvidia updates I’d like to always have the latest kernel selected.

My problem now is I’ve tried a few different ways, but I’ve failed or come up short each time. If I set the “D” key on systemd-bootloader (I’ve also tried @saved as well) it will default to that selected kernel, which is great, but only fixes part of what I want. However when using that option, when you update to a new kernel, my system keeps that older kernel, since it was set as the default, so now instead of having 2 kernels after an update and a reboot, i have 3 kernels, and one of them is an older one I don’t plan on using, I’d rather pacman just auto deletes it, but setting the “D” key I guess ignores that script or something.

tl;dr, i want systemd-bootloader to always select the latest kernel (highest version number), I don’t want it to select linux-lts, but I also want older kernels automatically deleted so I don’t have to keep manually removing kernels. It’s not a big deal, but I’m just trying to automate as much as I can and I’m pretty sure I have this working just fine like a year or so ago, but I can’t remember what I had.

sudo nano /efi/loader/loader.conf
  GNU nano 9.0                  /efi/loader/loader.conf                             
default default a718c5c3b60c42aa9332ecb00ebf37f6-*-arch1-1.conf
timeout 5
console-mode auto
reboot-for-bitlocker 1
scott@endeavourOS:~$ sudo ls /efi/loader/entries/
a718c5c3b60c42aa9332ecb00ebf37f6-6.18.24-1-lts.conf
a718c5c3b60c42aa9332ecb00ebf37f6-6.18.24-1-lts-fallback.conf
a718c5c3b60c42aa9332ecb00ebf37f6-6.19.13-arch1-1.conf
a718c5c3b60c42aa9332ecb00ebf37f6-6.19.13-arch1-1-fallback.conf
scott@endeavourOS:~$ 

If this is even possible please let me know, if not no worries, just thought I’d ask for this communities excellent knowledge. And if you need me to paste any other terminal commands just ask. Thank you for helping me :slight_smile:

edit: my solution per dalto’s suggestion, I removed the duplicate “default” and changed that string to look like this default a718c5c3b60c42aa9332ecb00ebf37f6-*-arch?-?.conf and now everything I wanted is good to go! :purple_heart:

Yes, as you say, using @saved and pressing d only work until an update.

You can set the default entry with a wildcard. The wiki shows exactly how to do that.

https://discovery.endeavouros.com/system-rescue/systemd-boot/2022/12/

You have default twice

Ah good old human error on my part! And thanks for the link, I should’ve remembered that, but my brain’s not working as good lately. Thanks again @dalto.