Use the included efiwake tool.
Get the current wake time:
```
#include <errno.h>$ /usr/sbin/efiwake
#include <fcntl.h>Current EFI time: 2023-04-24T15:56:29
#include <stdio.h>EFI wake time: 2023-04-23T22:00:00; enabled=1, pending=0
#include <stdlib.h>
#include <string.h>
#include <sys/efiio.h>```
int main(int argc __unused, char **argv __unused)Set a valid wake time:
{```
int efi_fd = open("/dev/efi", O_RDWR);$ /usr/sbin/efiwake -e 2023-10-24T22:00:00
if (efi_fd < 0)Current EFI time: 2023-04-24T16:00:32
{EFI wake time: 2023-04-24T22:00:00; enabled=1, pending=0
printf("Error: cannot open /dev/efi\n");
return 1;
}```
struct efi_tm now;Set an invalid wake time (31st of Apr does not exist):
int rv = ioctl(efi_fd, EFIIOC_GET_TIME, &now);```
printf("rv = %i, errno = %i = %s\n", rv, errno, strerror(errno));$ /usr/sbin/efiwake -e 2023-04-31T22:00:00
printf("EFI says now is: %i.%i.%i %i:%i:%i (%i)\n\n",Current EFI time: 2023-04-24T16:01:22
now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, now.tm_tz);
struct efi_waketime_ioc wt;efiwake: cannot enable EFI wake time: Invalid argument
rv = ioctl(efi_fd, EFIIOC_GET_WAKETIME, &wt);
printf("rv = %i, errno = %i = %s\n", rv, errno, strerror(errno));
printf("EFI wake time is: %i.%i.%i %i:%i:%i (%i); enabled=%i, pending=%i\n\n",
wt.waketime.tm_year, wt.waketime.tm_mon, wt.waketime.tm_mday, wt.waketime.tm_hour,
wt.waketime.tm_min, wt.waketime.tm_sec, wt.waketime.tm_tz, wt.enabled, wt.pending);```
wt.enabled = 1;Disable wake time:
wt.waketime = now;```
wt.waketime.tm_min = (wt.waketime.tm_min + 5) % 60;
rv = ioctl(efi_fd, EFIIOC_SET_WAKETIME, &wt);$ /usr/sbin/efiwake -d
printf("rv = %i, errno = %i = %s\n\n", rv, errno, strerror(errno));
return 0;Current EFI time: 2023-04-24T16:02:06
}
```EFI wake time: 2023-04-24T16:02:06; enabled=0, pending=0
Tested on laptop: reports unsupported.```
Tested on NAS: reports everything is fine, including enabled, pending etc. BUT: does not actually wake from S3.
So no idea if this actually works...