AppleScripting Sleep Monitor
Sleep Monitor 2.1 introduced AppleScript support. With this support you can now automate tasks such as generating reports, web site building, and applying complex queries against the events database.
Sample AppleScripts
Below are sample AppleScripts demonstrating how to use Sleep Monitor.
Every event and all the properties
tell application "DssW Sleep Monitor" -- get everything about the last recorded event set theProperties to properties of the last event -- which monitor recorded the middle event set theMonitor to monitor of the middle event -- count the number of restart events set howManyRestarts to number of (events where summary contains "restart") end tell
Focusing on today
tell application "DssW Sleep Monitor" -- talk to the visible slice of the database tell visibleSlice -- show the events for today set the startDay to (current date) set the endDay to (current date) end tell end tell
Exporting the graph to disk
set myFilename to "sleepmonitor-chart.png" tell application "DssW Sleep Monitor" set myPath to ((path to desktop) & myFilename) as string export graph visibleSlice to myPath border no title no end tell