Skip to content

Instantly share code, notes, and snippets.

@jeffadams
Created November 1, 2017 21:53
Show Gist options
  • Save jeffadams/f62ab7709e58746669b036da6ba92980 to your computer and use it in GitHub Desktop.
Save jeffadams/f62ab7709e58746669b036da6ba92980 to your computer and use it in GitHub Desktop.
#!/bin/bash
while true
do
OUT=`/usr/bin/pmset -g batt`
PERCENTLEFT=`echo $OUT | awk '{print $8}' | sed 's/%;//'`
if [ ${PERCENTLEFT} \< 40 ];
then
echo "${PERCENTLEFT} percent battery left" > /tmp/batterywarning
fi
if [ -f /tmp/batterywarning ];
then
say -v 'Tessa' -f /tmp/batterywarning
rm -f /tmp/batterywarning
fi
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment