Last active
November 6, 2022 16:20
-
-
Save source-c/c0e5e49cd27b9278626d6527e713ae02 to your computer and use it in GitHub Desktop.
Simple battery level fetch script for MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
current_level=$(pmset -g batt|grep InternalBattery-0|sed -n 's#.*[[:space:]]\([[:digit:]]\{1,\}\)%.*#\1#p') | |
[[ -z ${current_level} ]] && current_level='--' | |
echo ${current_level} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment