Extending Power Manager
Use Power Manager to get a head start with your own projects and let us do the heavy lifting.
Power Manager provides a complete Application Programming Interface (API) and Software Development Kit (SDK). The development kit is included in Power Manager's installer.
Install Power Manager;
Enjoy the examples and documentation at:
/Library/Application Support/Power Manager/Developer
An Example in a Few Languages
How easy is Power Manager to work with? Extremely. The following examples all request a list of events.
Events in AppleScript
A few of lines of AppleScript is enough to gather all the events in Power Manager.
tell application "Power Manager Scripting"
-- Get the names of all the Power Manager events
set myEvents to the events of the Event Store
Events in the Shell
Power Manager includes a command line tool called
pmctl. To make your scripts even easier to write,
pmctl's replies can be formatted in plist, perl, or json formats.
bash% cd /Library/Application\ Support/Power\ Manager/Tools/
bash% ./pmctl eventstore.events
Events in Objective-C
Power Manager's Objective-C interface follows the familiar design ethos of Apple's own Foundation classes.
// Create a connection to the local Power Manager installation
DSSWPMConnection* connection = [DSSWPMConnection connection];
// Create a request
DSSWPMRequest* eventsRequest = [DSSWPMRequest requestWithRequest:kPMRPCEventStoreEvents];
// Send the request; the reply is sent to connection:didReply:info: as an NSArray* of NSDictionary*
BOOL validSend = [connection send:eventsRequest withTarget:self selector:@selector(connection:didReply:info:)];
Where to Learn More
The best way to learn how to work with Power Manager is to install a copy on your Mac, and refer to the Developer guide.