I’ve asked ChatGPT for a solution to this and it came up with a script you can run in the Apple Automation app:
Certainly! Here are the instructions for the updated script to be posted on the Apple website:
**Instructions:**
1. Open the "Automator" app on your Mac.
2. Create a new task: Select "New Document" and choose "Application."
3. Search for actions: In the left sidebar of Automator, search for "Run AppleScript" and drag it into the workflow area on the right.
4. Write the AppleScript code: In the "Run AppleScript" window, replace the default code with the following code:
```applescript
on idle
set battery_percentage to do shell script "pmset -g batt | grep -o '\\d\\+%'"
set battery_percentage to text 1 thru -2 of battery_percentage as integer
if battery_percentage is less than 30 then
display dialog "Your battery percentage is lower than 30%. Please connect your MacBook to the charger!" buttons {"OK"} default button "OK"
end if
-- Run the script every 15 minutes (900 seconds)
return 900
end idle
```
5. Save and test: Go to "File" and choose "Save." Save the application with a name you prefer, for example, "BatteryCheck." Close Automator.
6. Automatically run at startup: You can add the "BatteryCheck" application to your startup items. To do this, go to Apple Menu > System Preferences > Users & Groups > Login Items, and click the "+" button to add your "BatteryCheck" application.
With these instructions, users can create an application that will automatically check their MacBook's battery percentage and display a warning if it drops below 30% every 15 minutes. This script is designed to be efficient and should work with the latest macOS version.