Skip to content

Instantly share code, notes, and snippets.

@Deses
Created September 29, 2024 22:48
Show Gist options
  • Save Deses/6f16b71791c8f40c7708a33b93cd20a7 to your computer and use it in GitHub Desktop.
Save Deses/6f16b71791c8f40c7708a33b93cd20a7 to your computer and use it in GitHub Desktop.
ADB deplete battery and print some battery data
while true; do
clear
echo "Battery and Temperature Information:"
echo "-----------------------------------"
echo "Capacity: $(cat /sys/class/power_supply/battery/capacity)%"
echo "Die Health: $(cat /sys/class/power_supply/battery/die_health)"
echo "Status: $(cat /sys/class/power_supply/battery/status)"
# Get voltage
microvolts=$(cat /sys/class/power_supply/battery/voltage_now)
voltage=$(echo "$microvolts / 1000000" | awk '{printf "%.2f", $1}')
echo "Voltage: $voltage V"
# Get temperature
temp="N/A"
for zone in /sys/class/thermal/thermal_zone*; do
thermal_temp=$(cat $zone/temp 2>/dev/null)
if [ ! -z "$thermal_temp" ]; then
temp=$(echo "$thermal_temp / 1000" | awk '{printf "%.1f", $1}')
break
fi
done
echo "Temperature: $temp°C"
# Drain battery maybe
for i in $(seq 1 1000000); do
:
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment