Workaround for a certain IOServiceOpen() call requiring root privileges
问题 Background It is possible to perform a software-controlled disconnection of the power adapter of a Mac laptop by creating an DisableInflow power management assertion. Code from this answer to an SO question can be used to create said assertion. The following is a working example that creates this assertion until the process is killed: #include <IOKit/pwr_mgt/IOPMLib.h> #include <unistd.h> int main() { IOPMAssertionID neverSleep = 0; IOPMAssertionCreateWithName(kIOPMAssertionTypeDisableInflow,