commit f5891d960c5f65b8bbc925175bfcfb70a4d084d9 parent 3f7f99afd4f8e176d4e0c1863a9bc9801904b243 Author: Alex Balgavy <a.balgavy@gmail.com> Date: Mon, 27 Jan 2020 15:01:31 +0100 mac-battery-warning: verbal warning when a mac's battery is low Former-commit-id: 9a9dfae3be6b75ca11ac828ac97cd6961c7cf8f0 Diffstat:
A | scripts/mac-battery-warning | | | 7 | +++++++ |
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/scripts/mac-battery-warning b/scripts/mac-battery-warning @@ -0,0 +1,7 @@ +#!/usr/local/bin/bash +battery_pct=$(pmset -g batt | tail -1 | awk '{ print $3 }' | cut -d% -f1) +if [ -n "$(pmset -g batt | grep "from 'Battery Power'")" ] && [ "$battery_pct" -le 15 ]; then + say "Charge your computer"; +elif [ -n "$(pmset -g batt | grep "from 'AC Power'")" ] && [ "$battery_pct" -ge 95 ]; then + say "Battery charged" +fi