Skip to content

Instantly share code, notes, and snippets.

@MrJoy
Created May 4, 2024 17:41
Show Gist options
  • Save MrJoy/5c81ef6d141d480ad704651c56bd25f8 to your computer and use it in GitHub Desktop.
Save MrJoy/5c81ef6d141d480ad704651c56bd25f8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# From: https://apple.stackexchange.com/questions/415355/is-it-possible-to-detect-the-current-power-input-on-a-macbook
ioreg -rw0 -c AppleSmartBattery |
grep BatteryData |
grep -o '"AdapterPower"=[0-9]*' |
cut -c 16- |
xargs -I % lldb --batch -o "print/f %" |
grep -o '[0-9.]*' |
tail -1
#!/bin/bash
# See also: https://apple.stackexchange.com/questions/415355/is-it-possible-to-detect-the-current-power-input-on-a-macbook
ioreg -rw0 -c AppleSmartBattery |
grep AdapterDetails |
grep -v AppleRaw |
grep -o -e '"Watts"=[0-9]*'
#!/bin/bash
# From: https://apple.stackexchange.com/questions/415355/is-it-possible-to-detect-the-current-power-input-on-a-macbook
ioreg -rw0 -c AppleSmartBattery |
grep -o -e '"ChargingCurrent"=[0-9]*'
#!/bin/bash
# From: https://apple.stackexchange.com/questions/415355/is-it-possible-to-detect-the-current-power-input-on-a-macbook
ioreg -rw0 -c AppleSmartBattery |
grep BatteryData |
grep -o '"SystemPower"=[0-9]*' |
cut -c 15- |
xargs -I % lldb --batch -o "print/f %" |
grep -o '[0-9.]*' |
tail -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment