Created
April 28, 2020 11:59
-
-
Save oboje/7786d442786101b78c618a37b0ef11fd to your computer and use it in GitHub Desktop.
mac os input voltage stat
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
#!/bin/bash | |
b=$(system_profiler SPPowerDataType) | |
amp=$(echo "$b" | grep 'Amperage (mA):' | cut -d ':' -f 2 | xargs) | |
volt=$(echo "$b" | grep 'Voltage (mV):' | cut -d ':' -f 2 | xargs) | |
power=$(($amp * $volt / 1000)) | |
echo "$b" | grep --color=never -A 1 'Battery Information:' | |
echo "$b" | grep --color=never -A 1 'Amperage (mA)' | |
echo " Total Power (mW): $power" | |
echo "" | |
echo "$b" | grep --color=never -A 99 'AC Charger Information:' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment