A bare metal header-only library to convert ACPI events into signals, without using acpid or any other dependencies (e.g. libnetlink or libmnl):
Power off button -> ACPI -> netlink -> ragequit -> callback
button/power
Add support for your Thinkpad here.
The following snippet is taken from the test's init
process:
#define RAGEQUIT_IMPLEMENTATION
#include "ragequit.h"
static void power_off(void* opaque)
{
struct ragequit_state* st = opaque;
ragequit_deinitialize(st);
printf("good bye...\n");
(void)reboot(LINUX_REBOOT_CMD_POWER_OFF);
perror("reboot(.._POWER_OFF)"), exit(1);
}
int main(void)
{
printf("hello\n");
struct ragequit_state st;
ragequit_initialize(&st, power_off, &st);
ragequit_run_event_loop(&st);
}