Skip to content

Installation

Prerequisites

Requirement Why How to get it
Rooted Android (Magisk) Tools touch pm, dumpsys, input, sysfs and /dev/input — all require root magisk.me or official channels
Termux Shell where the commands run F-Droid or GitHub releases — do not use the Play Store version (obsolete)
Python 3.9+ Runs appctl, battery, createswap, user-list pkg install python
rich TUI/color library used by Python scripts Installed automatically by install.sh
Magisk grant for Termux Without it, su -c fails and you get "no root" Magisk → Superuser → allow Termux

Step by step

# 1. base dependencies
pkg update && pkg install -y git python

# 2. rich library (install.sh tries this, but do it manually to be sure)
pip install rich || pip install --break-system-packages rich

# 3. clone and install (creates symlinks in $PREFIX/bin)
git clone https://github.com/C4-Labs/headless-lab.git ~/headless-lab
cd ~/headless-lab && ./install.sh

Expected output from step 3:

[+] appctl
[+] battery
[+] createswap
[+] screen-state
[+] screen-toggle
[+] touch-ctl
[+] user-list
[+] 7 commands installed in /data/data/com.termux/files/usr/bin
[*] test:  appctl --help   |   battery   |   createswap --status

Post-install verification

# does root work?
su -c id
# should print: uid=0(root) gid=0(root) groups=0(root)

# are the tools in PATH?
command -v appctl createswap battery touch-ctl screen-state screen-toggle user-list

# smoke test of each (changes nothing)
appctl --list
createswap --status
battery
touch-ctl status
screen-state
user-list --top 5

If su -c id asks for permission in Magisk and you accidentally deny it, open Magisk → Superuser → Termux and grant access. Without this, every tool that needs root will report "no root" with the exact reason.

Where files live

Path What
~/headless-lab/ Repo clone (source of the scripts)
$PREFIX/bin/<cmd> Symlinks to ~/headless-lab/bin/<cmd>
~/.appctl/snapshots/ appctl backups before each batch
/data/local/tmp/createswap-boot.log createswap boot hook log
/data/local/tmp/touch-ctl.state touch-ctl state for restoration
/data/local/tmp/createswap.disable Flag file that disables the boot hook

Uninstallation

cd ~/headless-lab && ./install.sh --uninstall
# removes the 7 symlinks from $PREFIX/bin

For a complete cleanup:

# warning: deletes backups and state
rm -rf ~/.appctl
rm -f /data/local/tmp/touch-ctl.state /data/local/tmp/createswap*.disable /data/local/tmp/createswap-boot.log

# undo swap/ZRAM if still active
createswap --clear all

# remove the Magisk boot hook (if installed)
createswap --uninstall-boot

# finally, delete the clone
rm -rf ~/headless-lab

Updating

cd ~/headless-lab
git pull
./install.sh   # recreates the symlinks (idempotent)

If you moved ~/headless-lab somewhere else, the symlinks break. Run ./install.sh again from the new location to recreate them.

Optional: createswap autocompletion

pip install argcomplete
createswap --completion
# follow the printed instructions (enables argcomplete in your shell)

Afterwards, TAB completes subcommands, sizes (1G, 50%) and flags.

Install troubleshooting

Symptom Likely cause Fix
python3 not found Python not installed pkg install python
rich missing pip failed (PEP 668) pip install --break-system-packages rich
bin/ folder not found Ran install.sh outside the clone cd ~/headless-lab && ./install.sh
does not look like Termux Running on PC/other shell Works, but adjust INSTALL_BIN
commands vanish after reboot Symlinks point into ~/storage Move clone to ~/ and reinstall

Why not use the Play Store version of Termux

The Termux version on the Play Store is obsolete and breaks on Android 12+ due to changes in background execution policy. Always use the F-Droid one or the APK from GitHub releases.