Skip to content

Instantly share code, notes, and snippets.

@parkerlreed
Created May 4, 2018 10:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save parkerlreed/08a6c40dce5d83f2dc329faea80a9256 to your computer and use it in GitHub Desktop.
Save parkerlreed/08a6c40dce5d83f2dc329faea80a9256 to your computer and use it in GitHub Desktop.
#!/bin/bash
voltage() { cat /sys/class/power_supply/fusb302-typec-source/voltage_now; }
voltage_actual() { cat /sys/class/power_supply/max170xx_battery/voltage_now; }
current_actual() { cat /sys/class/power_supply/max170xx_battery/current_now; }
current() { cat /sys/class/power_supply/fusb302-typec-source/current_max; }
current_limit() { cat /sys/class/power_supply/bq24190-charger/input_current_limit; }
capacity() { cat /sys/class/power_supply/max170xx_battery/capacity; }
breaker() { echo "------------------------------------------------------"; }
echo "Voltage: $(expr `voltage` / 1000000)V DC"
echo "Voltage (battery): $(echo 'scale=2; '$(voltage_actual)'/1000000' | bc)V DC"
echo "Current (battery): $(echo 'scale=2; '$(current_actual)'/1000000' | bc)A"
echo "Current (negotiated): $(echo 'scale=2; '$(current)'/1000000' | bc)A"
echo "Current (max): $(echo 'scale=2; '$(current_limit)'/1000000' | bc)A"
echo "Capacity: $(capacity)%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment