Quasi-sleep script for the CM4 (qsleep.sh)
With no real suspend on the CM4, grandrew's script fakes it: busy processes throttled to 1–2 % CPU, backlight off, powersave governor — about 13 h on a charge.
What it takes
- Software only
- Config change
Difficulty 1 of 3 — easy.
Details
qsleep.sh finds processes using more than 2 % CPU with pidstat, clamps them with cpulimit, switches the backlight off through /sys/class/backlight and hooks into the power button by replacing lxde-pi-shutdown-helper; pressing the button again undoes it. The second revision adds the powersave governor, turns the DSI output off with wlr-randr after 60 s, re-scans for busy processes every minute and restores the previous brightness. Dependencies are just sysstat and cpulimit; it was written against Raspberry Pi OS Bookworm with labwc.
grandrew reports around 13 h from a smartphone-like usage pattern, and Rex measured roughly 4 % battery drain per hour while asleep. Known limits: the GPU cannot be fully powered down and the keyboard cannot be locked without firmware changes. paragonnov's uConsole-Sleep packages the same idea as a service.



