Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
Created February 22, 2020 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paxperscientiam/ed6eb7d9fd463eb2bf78c2849d88bb8d to your computer and use it in GitHub Desktop.
Save paxperscientiam/ed6eb7d9fd463eb2bf78c2849d88bb8d to your computer and use it in GitHub Desktop.
macos low battery notifications (cron)
#!/usr/bin/env bash
declare -x GEM_HOME=/usr/local/ruby-lang/Gems
declare -x GEM_PATH=/usr/local/ruby-lang/Gems
if pmset -g batt | grep -Eo "Battery Power"
then
x=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) && [[ $x -lt 50 ]] && /usr/local/ruby-lang/Gems/bin/terminal-notifier -ignoreDnD -title "battery status" -message "low battery (${x}%)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment