SleepOnLowBattery (“SOLB”)
by BugsB, based on a script by Toggi3 * + more code snippets from the www

For those of us whose HackBook/ MacBook does not go to into power saving mode automatically on very low battery but just powers down coldly: “SOLB”, a small and low load footprint AppleScript based utility that checks the battery level every 2 minutes. You can choose between two versions, either with or without sound. Both display a notification in the top right of your screen.

Between ≤10 and >8% battery charge:

Between ≤8 and >5% battery charge:

On ≤ 5% battery charge you will see a 10 seconds countdown dialog box in 1 second intervals:

which you can cancel, or have your your *ac*Book be sent to sleep when down to 0.

The version with sound uses the pleasant macOS US female voice Allison. If the lady is not installed, you can download "her" via System Preferences, Accessibility, Speech (pane tab should get opened by the install script), click onto the two arrows to the right of System Voice, Customize, English (Unites States) -- Female, activate Allison, OK (macOS downloads voices to /System/Library/Speech/Voices - Allison consumes 120 MB).

If you want to see/ see and listen first, disconnect your Mac from its power supply and double click the “run Demo” file in either folder, with or without sound.

The launcher is installed per user, so one user can use the script with and another user the script without sound.

Run your desired install.command, with or without sound. The script should be active right away without restart.

Regarding the sound version, you can also:
- download any other English voice of your liking and edit the name inside the script at the very top
- download any language voice and translate the text inside the script
Edit with Apple Script Editor, save, install, reboot.

Tested working in macOS High Sierra 10.13.6. Please feedback if this utility also works in Mojave.

If you have ideas, experience bugs, etc., please contribute as precise, succinct, productive and friendly as possible. In case of a bug, always include your version of macOS for me or others to try and help. Thank you.

ENJOY

VERSION HISTORY:
2018-11-10:
1.0 (initial version)

IDEAS TO IMPLEMENT IN FUTURE RELEASES:
Have the sound version install script check if Allison is installed, and if not, offer to download and install it.
Purely cosmetic: find a way to have the display notification in the top right of the screen not display the Script Editor icon but the one of the utility without turning the utility into an app but by maintaining a script to keep the load footprint low. This is currently neither possible with an Apple Script nor with an Apple Script Bundle file, only with the script compiled into an app. One possibility might be a Perl approach, if someone volunteers.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Thanks to Toggi3 for the base script:https://hints.macworld.com/article.php?story=20110219013713667
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE CODE (of the version with sound):
install.command: