Skip to content

feat(just): add caffeinate recipe to prevent system sleep#351

Open
hanthor wants to merge 1 commit into
mainfrom
feat/caffeinate-recipe
Open

feat(just): add caffeinate recipe to prevent system sleep#351
hanthor wants to merge 1 commit into
mainfrom
feat/caffeinate-recipe

Conversation

@hanthor
Copy link
Copy Markdown
Member

@hanthor hanthor commented May 29, 2026

Summary

Closes #350

Adds a caffeinate recipe to default.just that wraps systemd-inhibit to provide the macOS caffeinate experience on Linux. Without args, holds sleep indefinitely until Ctrl+C. With args, holds sleep only while the given command runs.

Usage

ujust caffeinate                    # hold indefinitely, Ctrl+C to release
ujust caffeinate -- sleep 60        # hold while command runs
ujust caffeinate -- make long-build # hold while build runs

Changes

  • system_files/shared/usr/share/ublue-os/just/default.just: add caffeinate recipe

Test plan

  • Run ujust caffeinate and confirm systemd-inhibit --list shows the inhibitor
  • Press Ctrl+C and confirm sleep is re-enabled
  • Run ujust caffeinate -- sleep 5 and confirm inhibitor is released after 5 seconds

Wraps systemd-inhibit to provide a macOS caffeinate-like experience.
Without args, holds sleep indefinitely until Ctrl+C. With args, holds
sleep only while the given command runs.

Closes #350

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@hanthor, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 36 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f5bd004-ccd7-4530-aa34-0605d70e4513

📥 Commits

Reviewing files that changed from the base of the PR and between a148197 and 76103df.

📒 Files selected for processing (1)
  • system_files/shared/usr/share/ublue-os/just/default.just
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/caffeinate-recipe

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added area/just Justfile things kind/enhancement New feature, don't implement without a spec and consensus labels May 29, 2026
Copy link
Copy Markdown
Member Author

@hanthor hanthor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean implementation. LGTM.

Correctness: systemd-inhibit invocation is correct. Using exec avoids leaving a shell process behind. The --what flags are appropriate (sleep, idle, plus lid-switch for the indefinite case).

Edge cases: No-args mode uses sleep infinity which is the standard pattern. With-args mode correctly passes through to the user's command.

Style: Matches existing recipe conventions. Comments are helpful.

One minor suggestion (non-blocking): consider adding handle-lid-switch to the with-args mode as well for consistency, since a lid-close during a long build would also be disruptive. But the current split is reasonable — explicit command mode assumes the user is actively working.

@castrojo
Copy link
Copy Markdown
Contributor

Can't we just do the command without the ujust part? Ain't no one got time for that!

@castrojo
Copy link
Copy Markdown
Contributor

🤖 Copilot Test Report

Branch: feat/caffeinate-recipe | 15 commits behind main | Tested: 2026-05-30T04:51Z

Test Results

Test Result
just check (syntax validation) ✅ PASS
Branch freshness ✅ Near head

Change

Adds ujust caffeinate recipe to default.just — a more featureful implementation with two modes:

  • ujust caffeinate — holds sleep indefinitely (sleep infinity)
  • ujust caffeinate -- <cmd> — wraps a command

Uses --what=sleep:idle:handle-lid-switch (broader inhibit scope than the alias PRs).

Context

This is the ujust recipe approach vs #360/#361 which use shell aliases. These can co-exist. If the alias from #360 or #361 also merges, users get both caffeinate (shell alias) and ujust caffeinate (recipe) — both are fine.

@castrojo castrojo closed this May 30, 2026
@castrojo castrojo reopened this May 30, 2026
@castrojo castrojo closed this May 30, 2026
@castrojo castrojo reopened this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/just Justfile things kind/enhancement New feature, don't implement without a spec and consensus size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alias caffeinate

2 participants