The Termux Marathon Switch: Keep Android Awake on the Charger Without Another App
You kick off a pkg upgrade, a proot distro install or a long build in Termux, set the phone down on the desk, and turn back to the laptop. Thirty seconds later the screen dims and locks, and now you’re unlocking it every few minutes just to watch progress scroll by. Same deal when you’re screen sharing a phone demo or reading logs at the bench.
The Play Store will happily sell you a “keep screen on” app with ads and a permission list longer than your build log. You don’t need it. Android has had this switch built in for years: Stay awake, hidden in Developer options. While the phone is plugged in, the screen never sleeps. Unplug it and normal timeouts come back.
My rule: it’s a marathon switch, not a lifestyle. Turn it on for the long job, then turn it off.
What You Need
- USB power (wall charger, laptop port or a desk strip) so the phone stays plugged in.
- Developer options enabled, or two minutes to enable them.
- A cable that stays put. If the phone slides off the charger, Stay awake quietly stops. A one‑strip desk charge station fixes that.
- No third‑party apps.
Battery & heat tradeoff: Stay awake only works while plugged in, but a lit screen plus a CPU‑heavy compile is a toasty combo. The phone can charge slower and run warm. Drop brightness to the minimum you can read, keep the phone out of direct sun and off soft surfaces, and don’t make “screen on all night” a habit. It does not keep the screen on when running on battery alone.
Flip the Marathon Switch
Step 1: Enable Developer options
Settings > About phone → tap Build number seven times (Samsung: About phone → Software information → Build number). Yes, it really is a secret knock.
Step 2: Turn on Stay awake
Settings > System > Developer options (search Stay awake if your build hides it).
Under General options, enable Stay awake. Android Developers’ wording: it “sets your screen to stay on while the device is plugged in.”
Step 3: Verify with a charger
Plug in, then wait past your normal screen timeout. The display should stay lit. Unplug and the usual timeout comes back. Unplugging is your off switch for the day.
Step 4: Turn it off when the marathon ends
Developer options → disable Stay awake. Or flip the master Use developer options switch off when you’re done with developer tools entirely.
Samsung Galaxy
Same Stay awake toggle under Developer options after Build number ×7 (ANS10003430). Samsung warns Developer options aren’t meant for typical use and may affect performance, which is one more reason to leave Stay awake off day to day.
Stay Awake vs. the Cheaper Fixes
- Use Stay awake for hours‑long, plugged‑in jobs you want to watch: Termux installs like proot‑distro, build logs, screen‑shared demos, a phone acting as a status display.
- Don’t need the screen, just the job? Termux can hold its own wakelock. Tap Acquire wakelock in the Termux notification or run
termux-wake-lock. The screen can sleep while the work keeps going. That’s cooler, cheaper on the battery and usually the smarter pick. - Short recording or a 10‑minute demo? Just raise Screen timeout in Display settings. No Developer options needed.
- The real problem is a flaky cable? If the phone keeps losing power because the cable falls off the desk edge, Stay awake won’t save you. A binder‑clip cable clip will.
Leave Yourself a Note
Official docs
Configure on-device developer options — General options → Stay awake. Samsung enable path: ANS10003430.