feat: add kernel ACPI support for querying battery percentage, add battery indicator to desktop, move log state to 0:/state directory

This commit is contained in:
daniel committed 2026-09-11 07:11:48 +02:00
1 parent 0a18b2cf2d
commit e641500b40
34 files changed
+2461 -100

No files matched your search

+23
View File
@@ -343,6 +343,9 @@ namespace montauk::abi {
touch in full (image decode, heap slabs). */
static constexpr uint64_t SYS_ALLOC_EAGER = 187; // (bytes) -> va, 0 on failure
/* Battery.hpp -- ACPI battery status */
static constexpr uint64_t SYS_BATTERYINFO = 188; // (BatteryInfo*) -> 0, -1 no battery device
/* Kernel-owned process capabilities. User identities may namespace
per-user resources, but never participate in authorization decisions. */
static constexpr uint64_t CAP_PROCESS_ADMIN = 1ULL << 0;
@@ -881,6 +884,26 @@ namespace montauk::abi {
uint32_t apIdleHint; // MWAIT hint used for AP deep idle
};
// Battery status (returned by SYS_BATTERYINFO). A machine with no battery
// device fails the call outright; `present` distinguishes a laptop with the
// pack removed from one that is running on it.
struct BatteryInfo {
uint8_t present; // a battery is installed
uint8_t charging;
uint8_t discharging;
uint8_t critical;
uint8_t acOnline; // AC adapter connected
uint8_t hasAcAdapter; // an AC adapter device exists at all
uint8_t percent; // 0..100, 0 when capacity is unknown
uint8_t powerUnitMilliAmps; // capacities are mAh/mA, not mWh/mW
uint32_t remainingCapacity;
uint32_t fullCapacity; // last full charge capacity
uint32_t designCapacity;
uint32_t presentRate; // mW or mA, 0 when unknown
uint32_t voltageMv;
int32_t minutesRemaining; // -1 when not estimable (e.g. charging)
};
// Crash report (filled by kernel on process fault, returned via SYS_CRASH_REPORT)
struct CrashReportInfo {
int pid;