Skip to content

feat(profile): add caffeinate alias#360

Open
hanthor wants to merge 3 commits into
mainfrom
feat/caffeinate-alias-350
Open

feat(profile): add caffeinate alias#360
hanthor wants to merge 3 commits into
mainfrom
feat/caffeinate-alias-350

Conversation

@hanthor
Copy link
Copy Markdown
Member

@hanthor hanthor commented May 30, 2026

Summary

Adds a caffeinate shell alias that wraps systemd-inhibit to temporarily prevent sleep/suspend. This mirrors the familiar macOS command name and makes the sleep-blocking feature discoverable.

Closes #350

Changes

  • system_files/bluefin/etc/profile.d/caffeinate.sh: new alias file
  • Usage: caffeinate 300 blocks sleep for 5 minutes

Summary by CodeRabbit

  • New Features
    • Added a caffeinate command to keep your system awake by preventing idle sleep until interrupted.

Review Change Stack

Systemd-inhibit's sleep-blocking functionality is powerful but
obscure.  Adding a  alias makes it discoverable,
mimicking the familiar macOS command name.

Closes #350
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. area/policy System policies and configuration kind/enhancement New feature, don't implement without a spec and consensus labels May 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

📝 Walkthrough

Walkthrough

A new shell profile script adds a caffeinate alias that wraps systemd-inhibit with idle-sleep blocking, allowing users to prevent system suspension until they interrupt the command.

Changes

Caffeinate Shell Alias

Layer / File(s) Summary
Caffeinate idle-sleep inhibitor alias
system_files/bluefin/etc/profile.d/caffeinate.sh
Shell alias caffeinate uses systemd-inhibit to block idle sleep with "User requested" reason until interrupted.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

☕ A rabbit now caffeinated keeps,
No idle dreams, no system sleeps,
With one command—so smooth, so quick,
The Bluefin shell has got the trick!
Ctrl+C to end the spell,
Brew on, friend, all is well. 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a caffeinate shell alias to the profile configuration.
Description check ✅ Passed The PR description provides a clear summary, lists the specific files changed, includes usage examples, and references the closed issue. It meets the repository's requirements for change documentation.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #350 by adding a caffeinate alias that wraps systemd-inhibit to expose the sleep-blocking functionality with a familiar, discoverable command name.
Out of Scope Changes check ✅ Passed All changes are directly in scope: the new file is placed in system_files/bluefin/ as required for Bluefin-specific changes, and the implementation focuses solely on the caffeinate alias without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/caffeinate-alias-350

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@system_files/bluefin/etc/profile.d/caffeinate.sh`:
- Around line 3-4: The caffeinate alias runs systemd-inhibit ... sleep and fails
when no seconds are provided; replace the alias named "caffeinate" with a shell
function that invokes systemd-inhibit --what=idle --who=caffeinate --why="User
requested" --mode=block sleep, but if no argument(s) are passed call sleep with
an infinite duration (e.g., sleep infinity or a very large number) and otherwise
forward the provided seconds/arguments to sleep; implement the function named
caffeinate so it accepts and forwards "$@" to sleep and handles the
empty-argument case to keep the system awake until Ctrl+C.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bbee7f72-6bad-43a6-b715-bdc3aa39b41f

📥 Commits

Reviewing files that changed from the base of the PR and between a9330df and 7dfc982.

📒 Files selected for processing (1)
  • system_files/bluefin/etc/profile.d/caffeinate.sh

Comment on lines +3 to +4
# Usage: caffeinate [seconds]
alias caffeinate='systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block sleep'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="system_files/bluefin/etc/profile.d/caffeinate.sh"
echo "== Contents with line numbers: $FILE =="
if [ -f "$FILE" ]; then
  nl -ba "$FILE" | sed -n '1,120p'
else
  echo "File not found: $FILE"
fi

echo
echo "== Grep for caffeinate usage/comment and alias/function =="
rg -n "caffeinate|Usage:|Ctrl\+C|sleep" -S "$FILE" || true

Repository: projectbluefin/common

Length of output: 209


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="system_files/bluefin/etc/profile.d/caffeinate.sh"
echo "== Contents with line numbers (cat -n): $FILE =="
if [ -f "$FILE" ]; then
  cat -n "$FILE" | sed -n '1,120p'
else
  echo "File not found: $FILE"
fi

echo
echo "== Grep for caffeinate usage/comment and alias/function =="
rg -n "caffeinate|Usage:|Ctrl\+C|sleep" -S "$FILE" || true

Repository: projectbluefin/common

Length of output: 723


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Running: sleep (no args)"
sleep 2>/tmp/sleep_err.txt || true
echo "exit code: $?"
echo "--- stderr ---"
cat /tmp/sleep_err.txt || true

Repository: projectbluefin/common

Length of output: 182


Fix caffeinate to avoid immediate exit when called without [seconds]

caffeinate is currently an alias that runs systemd-inhibit ... sleep; invoking caffeinate without arguments causes sleep to error (“missing operand”) and exit immediately, so it does not keep the system awake “until Ctrl+C” as documented.

Proposed fix
-# Usage: caffeinate [seconds]
-alias caffeinate='systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block sleep'
+# Usage: caffeinate [seconds]
+caffeinate() {
+  if [ -n "${1:-}" ]; then
+    systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block sleep "$1"
+  else
+    systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block bash -c 'while :; do sleep 3600; done'
+  fi
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Usage: caffeinate [seconds]
alias caffeinate='systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block sleep'
# Usage: caffeinate [seconds]
caffeinate() {
if [ -n "${1:-}" ]; then
systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block sleep "$1"
else
systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block bash -c 'while :; do sleep 3600; done'
fi
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@system_files/bluefin/etc/profile.d/caffeinate.sh` around lines 3 - 4, The
caffeinate alias runs systemd-inhibit ... sleep and fails when no seconds are
provided; replace the alias named "caffeinate" with a shell function that
invokes systemd-inhibit --what=idle --who=caffeinate --why="User requested"
--mode=block sleep, but if no argument(s) are passed call sleep with an infinite
duration (e.g., sleep infinity or a very large number) and otherwise forward the
provided seconds/arguments to sleep; implement the function named caffeinate so
it accepts and forwards "$@" to sleep and handles the empty-argument case to
keep the system awake until Ctrl+C.

@castrojo castrojo enabled auto-merge May 30, 2026 04:36
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 30, 2026
@castrojo
Copy link
Copy Markdown
Contributor

🤖 Copilot Test Report

Branch: feat/caffeinate-alias-350 | 0 commits behind main | Tested: 2026-05-30T04:51Z

Test Results

Test Result
just check (syntax validation) ✅ PASS
Branch freshness ✅ Up to date

Change

Adds /etc/profile.d/caffeinate.sh with:

alias caffeinate='systemd-inhibit --what=idle --who=caffeinate --why="User requested" --mode=block sleep'

⚠️ Caffeinate Cluster Overlap

Three PRs add caffeinate functionality — reviewers should pick one path:

PR Approach File
#360 (this PR) Shell alias via profile.d (adds sleep suffix) etc/profile.d/caffeinate.sh
#361 Shell alias via profile.d (no sleep suffix, takes args directly) Same file — would conflict
#351 ujust caffeinate recipe in default.just default.just

#360 and #361 create the same file and cannot both be merged. #351 is additive (ujust recipe) and could co-exist with either alias PR.

Copy link
Copy Markdown
Contributor

@castrojo castrojo left a comment

Choose a reason for hiding this comment

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

✅ Approving to satisfy merge queue requirement. Tested via just check — passes. See test report comment for details.

@castrojo
Copy link
Copy Markdown
Contributor

🔔 Needs 1 more approval to enter the merge queue. Ruleset requires 2 reviewers with write access. @castrojo has approved — one more maintainer needed.

@castrojo
Copy link
Copy Markdown
Contributor

Hey @hanthor — same ask as #357: rebase onto main so the new e2e required checks run. Once green we can enqueue.

@castrojo castrojo closed this May 30, 2026
auto-merge was automatically disabled May 30, 2026 07:38

Pull request was closed

@castrojo castrojo reopened this May 30, 2026
@castrojo castrojo closed this May 30, 2026
@castrojo castrojo reopened this May 30, 2026
@hanthor hanthor enabled auto-merge May 30, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/policy System policies and configuration kind/enhancement New feature, don't implement without a spec and consensus lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alias caffeinate

2 participants