I wrote a new e-book AppleScript. PDF 57 pages (In Japanese).
https://piyomarusoft.booth.pm/items/6372143
The functions of the power control system, such as sleeping, shutting down, specifying the wake date and time, retrieving the remaining battery level, and determining the power supply type, are a “nifty” spice to accompany AppleScript. Let’s take a closer look at some of the power control features that are useful to know and fun to operate.
Now, the MacBooks can be powered by battery all day long, so I feel that the situation where severe calculations are required has decreased, but even so, the process of obtaining the remaining battery level is indispensable even with AppleScript. Power control is an interesting process to use and operate.
■Table Of Contents
■ First: Make sure to turn off Stage Manager first on macOS 13 or later
macOS 13.x
macOS 14.x
macOS 15.x
Other features that you might want to turn off
■ Power control related function list
Various power control functions in macOS
Sleep execution from AppleScript
Wake up at a specified date and time
Determination of power supply type
Battery level data acquisition
■ Sleep
2 Sleep Processes
Sleep processing
Display off processing
■ Wake
Wake (Schedule Registration)
AppleScript for wake date and time setting (1) to (3)
■ Wake detection
Wake Detection, 2 Ways
The simplest wake detection
Wake detection using system notifications (1) to (3)
■ Power off
Power off is 2 courses
■ Power supply type determination
Determination of power supply type
■ Retrieving the remaining battery level of the Mac
Before you get battery information
Distinction between desktop and notebook machines (1) to (3)
What battery specifications can you get?
Get the battery level of your Mac
■ Other materials
Logout process
restart
CPU type determination
CPU Operating Clock Acquisition
Get the values of various Apple Silicon temperature sensors (1) to (3)