Skip to content

Instantly share code, notes, and snippets.

@dulao5
Created August 30, 2019 05:38
Show Gist options
  • Save dulao5/099700f7ac20b10141de6c24ce60fee6 to your computer and use it in GitHub Desktop.
Save dulao5/099700f7ac20b10141de6c24ce60fee6 to your computer and use it in GitHub Desktop.
#!/bin/sh
if ( pmset -g batt | head -n 1 | grep 'AC Power' ); then
exit 0
fi
battery_percent=$(pmset -g batt|grep InternalBattery | awk '{print $3}' | sed -e 's/%.*//')
battery_low=60
if [ $battery_percent -lt $battery_low ]; then
osascript -e 'display notification "電源が足りない!"'
fi
## crontab -e
## * * * * * hoge/fuga.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment