Beep Alert when Battery is below 10% — MacOS.

How about a irritating Beep sound which start when battery is below 10%

Beep

Save the following script somewhere — You can download it from https://raw.githubusercontent.com/nsisodiya/ubuntu-battery-alarm/master/mac/mac-battery-alarm-service.sh too

#!/bin/bash
while true;
do
echo ""
charging_level=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
charging_status=$(pmset -g batt | grep charging | cut -f4 -d" " | cut -f1 -d ";")
echo "Cuttent charing level is $charging_level and Battery is $charging_status"
if [ "$charging_status" == "discharging" ];then
if (( charging_level < 10 )); then
echo "Battery is LOW and Less than 10% & Discharging"
#amixer set 'Master' 100%
afplay /System/Library/Sounds/Blow.aiff
fi
fi

if (( charging_level < 5 )); then
sleep 2;
else
sleep 5;
fi
done

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Narendra Sisodiya

Narendra Sisodiya

12+yrs exp. JavaScript Expert. Full Stack Expert. React, Nodejs Mongo AWS, Terraform Pulumi. IITian, Open Source. Currently Software Architect @ Prophecy.io