If it breaks
termux-battery-status itself must work first. If that command fails, the pair is incomplete. Termux:API room.
JSON looks loud. Tap the lunch box.
You are here: Practice · Battery
After the first three feel less scary
Use Termux:API so the script asks how full the battery is. You do not need to memorize the helper lines. You need the idea: run a phone command, read packed text, print one number.
Example idea. Type it only after hello, guess, and a file feel less scary.
import subprocess, json
raw = subprocess.check_output(["termux-battery-status"])
data = json.loads(raw)
print("Battery:", data["percentage"], "%")
Run the phone’s battery command, read the answer (JSON), print the percentage.
python ~/learn/battery.pytermux-battery-status itself must work first. If that command fails, the pair is incomplete. Termux:API room.
JSON looks loud. Tap the lunch box.
A script can use the phone, not only print words you typed. Clipboard can be a second experiment on another day.
App ideas wait until hello.py feels ordinary. Extras are here if you want another tiny file.