Skip to content

feat: /tmp/stay_awake and /tmp/stay_alive suspend-inhibit lock files#756

Draft
nborodikhin wants to merge 1 commit into
LoveRetro:mainfrom
nborodikhin:feat/suspend-inhibit-locks
Draft

feat: /tmp/stay_awake and /tmp/stay_alive suspend-inhibit lock files#756
nborodikhin wants to merge 1 commit into
LoveRetro:mainfrom
nborodikhin:feat/suspend-inhibit-locks

Conversation

@nborodikhin

Copy link
Copy Markdown

Summary

Adds two standard /tmp/ marker files that let external processes defer
NextUI's automatic power-save transitions:

  • /tmp/stay_awake — blocks autosleep (no screen-off, no deep sleep)
  • /tmp/stay_alive — blocks deep sleep only (screen may still blank)

This PR addresses #755

Changes

  • stay_awake plugs into PWR_preventAutosleep() so the autosleep timer
    is pinned while the file exists. Manual SLEEP-button and HW-requested
    sleep paths are unaffected.
  • Both files are checked in PWR_waitForWake()'s deferral loop next
    to the existing is_charging branch, so deep sleep is skipped
    while either lock is present (same 60s re-check cadence).
    This also catches the race where stay_awake appears
    after the device already entered light sleep.

Test plan

  • Built and ran on tg5040, tg5050

Two well-known marker files let external processes (Pak scripts, debug
sessions, long-running tools) defer the auto power-save transitions:

  /tmp/stay_awake - blocks autosleep (no screen-off, no deep sleep)
  /tmp/stay_alive - blocks deep sleep only (screen may still blank)

stay_awake plugs into PWR_preventAutosleep so the autosleep timer is
pinned while the file exists; manual SLEEP-button and HW-requested
sleep paths are unaffected. Both files are also checked in
PWR_waitForWake's deferral loop next to the existing is_charging
branch, so deep sleep is skipped while either lock is present (with
the same 60s re-check cadence). This also catches the race where
stay_awake appears after the device already entered light sleep.

/tmp is tmpfs on the device, so the locks evaporate on reboot.
Addresses LoveRetro#755.
@frysee

frysee commented Jun 12, 2026

Copy link
Copy Markdown
Member

I remember a brief discussion about something similar a while back, but its not because paks cant override sleep, the opposite really. See my comment on #755, this should not be necessary for any current pak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants