Skip to content

Tools — overview

Headless Lab has 7 commands covering four areas: app management, memory, hardware (screen and touch), and observability. All follow the same safety patterns.

Quick map

Command Area Language One-liner
appctl Apps Python TUI to disable/enable apps, profiles, backups and SystemUI/launcher/keyboard repair
createswap Memory Python Manage ZRAM + swapfile with panel, dry-run, rollback and boot hook
battery Hardware Python Battery monitor: level, temp, health, cycles, current, live mode
touch-ctl Hardware Bash Reversibly disable/enable touchscreen via mknod + sysfs
screen-state Hardware Bash Report screen on/off (exit code for scripts)
screen-toggle Hardware Bash Turn screen on/off/toggle using KEYCODE_WAKEUP/SLEEP
user-list Observability Python UID → packages → processes → RAM map, with filters and JSON

Common patterns

Automatic root elevation

All tools try, in this order:

  1. run directly if already root (id -u == 0);
  2. su -c (Magisk);
  3. sudo.

You do not need to type sudo. If all fail, the tool prints the exact reason of each attempt (e.g. su: denied; sudo: not found) and what to do (Open Magisk > Superuser and grant access to Termux).

--dry-run / -n

Simulate before applying. Available in appctl (profiles and --disable) and createswap (any --setup-*). Output shows exactly what would change.

--json

Structured output for scripts. Available in battery, user-list, and in createswap (for the status panel). See Automation for ready-made recipes.

Exit codes

Almost all follow this convention:

Code Meaning
0 success
1 operational failure (couldn't fulfill the request)
2 couldn't read state / no root where needed
3 no root (touch-ctl)
4 hardware not found (touch-ctl)
64 invalid usage (bad argument)

Use in scripts:

if screen-state -q; then
    echo "on — turning off"
    screen-toggle --off -q
fi

Reversibility

  • appctl uses pm disable-user / pm enable — never uninstalls.
  • createswap rolls back each step if a later one fails.
  • touch-ctl self-restores if off fails after removing the device node.
  • screen-toggle re-reads state and confirms the change (idempotent).

Which to use first?

  • First time on a device: createswap --status to see RAM, then appctl --profiles to understand profiles.
  • Production server: appctl --profile servidor-seguro, then createswap --setup-zram 1G --install-boot.
  • Cracked screen with ghost touch: touch-ctl off (after ensuring SSH access).
  • 24/7 monitoring: battery --watch 5 in a tmux, or --json in an alert script.

Continue to each tool's page via the side menu.