You are not logged in.
I have an old notebook. I use it for various purposes like Wireguard Server, Nextcloud etc.
I sometimes experience AC outage (another topic). I configured it to go to sleep on battery after 30 mins. What I'd like to do is for it to wake from sleep whenever AC power is restored.
ChatGPT gave me the combination of UDEV rules, .sh script or a systemd unit. Non of the two options worked.
I tried google-ing it, but all hits are "my PC wakes up instantaneously if plugged in".
I also read various wiki pages, but did not really find anything applicable to my case (or I'm noobie).
Thanks.
Offline
Ask the artificial idiot how to know whether you're using S3 or s2idle
cat /sys/power/mem_sleep
If it turns out to be S3 ("deep"), ask the artificial idiot how exactly a system currently in S3 is gonna exectute any udev rules or systemd units.
If the system is in S3 you'll have to enable a wakeup trigger in the ACPI that fires when you plug the AC.
cat /proc/acpi/wakeup
If it's s2idle, it would at least theoretically be able to wake the system if the AC plug generates an interrupt.
https://bugzilla.kernel.org/show_bug.cgi?id=206413#c4 but compare the values after un/plugging the AC, not an s2idle wake
No immediate idea how to do thin in prcactice, though.
And then stop askign the artificial idiot things - suggesting to use udev rules to pot. get out of an S3 implies it has no idea what it's talking.
As a generic solution, you could rtcwake the system (ie. send it to sleep, but only for eg. 30 minutes) and this way periodically check whether the AC has been restored - otherwise go back to sleep for another 30m.
I sometimes experience AC outage (another topic).
Offline