I looked a bit into how to have grub selecting different defaults based
on the wake-up cause, and I want to share this as others might have a
similar need:
I found that grub has the smbios command which can look into the smbios
structure. Specification here:
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.8.0.pdf
Under "System - Wake-up Type" there's a nice list of supported causes:
"LAN Remote", etc.
I tried to add the following lines to my Debian /etc/grub.d/40_custom:
# Select a different default if woken by WOL-package.
smbios --type 1 --get-byte 0x18 --set WAKE_CAUSE
if [ $WAKE_CAUSE -eq 5 ]; then
set default="2"
fi
#---
It basically worked, and different causes booted different entries.
However, on my motherboard (Asus X670E) this seemed to be flawed in
several ways. Perhaps my 2023 firmware is too old - Will try update it
at another time...
Powerdown from Debian caused the machine to wake immediately - I have no
idea why!
Wake on LAN gave the previous Wake-up cause, I think - It didn't seem
consistent, but based on the powerdown-immediate-poweron-issue I think
the firmware is at fault.
Anyway, I hope this may be of some value to others.
~Per