How to set battery level notification on MacBook, when it is under 20 %? (macOS Ventura)

Hi everybody!


I'd like to ask You a question - is it possible to set battery level notification on MacBook, when it is under 20 % (same way as it is on iPhone)?


I've just found, that it is possible via third party software, but I'd rather use somehow native option in settings, but i could not find it, or an Apple app, if it's possible. Any ideas? I've tried shortcuts, but without automatization it is not working properly, Automator + AppleScript weren't working either.


It will be cool, if this feature in Settings in options for battery appears in an update or a new version.


Thank You for Your help.


Majkinho

Posted on Jul 20, 2023 8:49 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 12, 2023 9:56 AM

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.

29 replies
Question marked as Top-ranking reply

Dec 12, 2023 9:56 AM in response to Majkinho

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.

Jul 1, 2024 10:13 PM in response to Majkinho

I was also looking for a quick way to set notifications for when my battery was at a certain level, and it looks like you can trigger shortcuts from command line so I did set it up to run every minute using crontab:


Created a shortcut (can change the if statement to what you want):



Added a CronTab to run this shortcut every minute:


  • Open the Terminal app
  • Type this command in Terminal to open the crontab editor:
env EDITOR=nano crontab -e
  • Paste this line in the crontab editor:
* * * * * shortcuts run "80\% Battery Remaining"
  • Exit the crontab editor--if you're not familiar with nano you can exit like this:
    • ctrl + o
    • enter
    • ctrl + x


Now the shortcut should run every minute, and you'll get a notification when the battery level equals 80%.


If you want to check your crontab, you can run `crontab -l` in Terminal. If you get any errors, it'll usually show up in mail which you can view by running `mail` in Terminal.


If you want to trigger the shortcut to run every 5 minutes or some other time interval, you can use this tool to replace the "* * * * *" part:

https://crontab.guru/


Also, there's probably a better way to do this, since the shortcut I'm using wouldn't account for cases where the battery level drops below 80% really quickly (i.e. battery level drops from 81% to 79% within a minute), and it would notify you every minute while the battery is at 80%.


Jul 9, 2024 11:19 AM in response to Majkinho


This shortcut will run in the background once activated. It will detect if your Mac is charging within 15 minutes based on an increase in battery percentage. You can program it to perform any action. For instance, I have programmed it to notify me to charge my laptop when the battery percentage drops below 25% (Battery Level) and to remove the charging adapter when the battery percentage exceeds 75% (Charging Level).


You can adjust the wait time to anything between 5 and 20 minutes for optimal resource consumption.



To add a new shortcut on a Mac, follow these steps:

  1. Open the Shortcuts App:
    • Click on the Launchpad icon in the Dock.
    • Type "Shortcuts" in the search bar and press Enter.
  1. Create a New Shortcut:
    • In the Shortcuts app, click the "+" button or the "Create Shortcut" button.
  1. Add Actions to the Shortcut:
    • Click "Add Action".
    • Browse or search for the action you want to add to your shortcut (e.g., open an app, send a message, etc.).
    • Click on the desired action to add it to your shortcut.
  1. Configure Actions:
    • Customize the actions according to your needs (e.g., specify the app to open, the message to send, etc.).
  1. Save the Shortcut:
    • Click "Done" to save your new shortcut.
    • Give your shortcut a name by clicking on the shortcut name at the top of the editor and typing a new name.
  1. Use the Shortcut:
    • You can run your new shortcut by opening the Shortcuts app and clicking on the shortcut, or you can add it to the Dock, Menu Bar, or use a keyboard shortcut to run it quickly.




Jul 20, 2023 8:57 AM in response to Majkinho

Majkinho wrote:

Hi everybody!

I'd like to ask You a question - is it possible to set battery level notification on MacBook, when it is under 20 % (same way as it is on iPhone)?

I've just found, that it is possible via third party software, but I'd rather use somehow native option in



I would use the third party software



You can submit your Apple Feedback here: Product Feedback - Apple


Nov 20, 2023 4:13 AM in response to samuelbumbar

The OP wants a passive low battery notification when the charge remaining drops below 20%. This is expected while in full screen mode. Your shortcut is an active notification that must be user initiated, and not possible while in a full screen state.


Dialabrain and I have suggested a means where the OP can simply move their mouse up to the top of the screen while in full screen mode and reveal current charge state. That too is active, but more practical than coding a passive tool script controlled by operating system interaction with a periodically run daemon process that checks the battery charge.

Nov 20, 2023 4:20 AM in response to Majkinho

I don't know exactly how it was on that version, but with the version Sonoma 14.1.1 (23B81) I am able to do that. You need to do the following steps:


  1. Get the Battery Level first;
  2. Do a Repeat with each using the Battery State, in order to check for each battery level change;
  3. Do an If statement (like the one in the picture below) and compare it with 20, or another value that you need;
  4. Create a Notification, Speak, or create the consequence you want.


Apr 18, 2024 10:29 AM in response to Majkinho

Actually they have not answered your question ! :)


I have the same problem: I would like to get a notification that the battery is low.

and saying that I can periodically look at the battery symbol in menu bar is like saying that you can look at GAS arrow at your car dashboard :)))

that is why EVERY car has a warning light....


We need the same in laptop - why Apple makes it sooo difficult?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to set battery level notification on MacBook, when it is under 20 %? (macOS Ventura)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.