Three Raycast Script Commands for controlling macOS sleep without keeping Terminal open. The two active modes are mutually exclusive: starting one stops the other, and running the active command again turns it off.
| Raycast command | What it does |
|---|---|
| Caffeinate — Display Can Turn Off | Runs caffeinate -is. Keeps the Mac awake while allowing the normal display-sleep timer to work. |
| Caffeinate — Keep Everything On | Runs caffeinate -disu. Keeps both the Mac and display awake. |
| Caffeinate Status | Shows the managed mode in Raycast and refreshes every 10 seconds without changing anything. |
- macOS
- Raycast
- No third-party packages or administrator access
Clone the repository:
git clone https://github.com/daaniyaan/raycast-caffeinate.git
Alternatively, choose Code → Download ZIP on GitHub and extract it.
Then add the folder to Raycast:
- Open Raycast Settings → Extensions.
- Click + → Add Script Directory.
- Select the
raycast-caffeinatefolder. - Open Raycast and search for
caffeinate.
If Raycast does not detect the commands, make the scripts executable:
chmod +x *.sh- Use Display Can Turn Off for downloads, builds, or backups that should continue while the screen sleeps normally.
- Use Keep Everything On for presentations, dashboards, or anything that requires the display to stay on.
- Use Caffeinate Status to see whether either managed mode is active.
- Run the active toggle again to restore normal macOS sleep behavior. You can also switch modes directly; the previous one stops automatically.
Each toggle starts caffeinate in the background and stores its process ID under:
~/Library/Caches/com.raycast.caffeinate-modes/
Before stopping anything, the scripts verify both the saved PID and the exact command. This prevents them from terminating unrelated caffeinate processes started by you or another app.
- Display Can Turn Off does not switch off the screen immediately; it follows the timeout in System Settings → Lock Screen.
- These commands do not prevent sleep caused by closing a MacBook lid.
- The
-sassertion works only on AC power; the-dand-iassertions provide the main behavior on battery power. - Assertions end automatically if the Mac restarts or the managed process exits.
- The status command reports only the two modes managed by these scripts.
- If the commands are missing, confirm the folder is added as a Raycast Script Directory and run
chmod +x *.sh. - If the Mac still sleeps, check Caffeinate Status, keep a MacBook lid open, and inspect assertions with
pmset -g assertions. - Seeing OFF after a restart is normal; run the desired toggle again.
The scripts make no network requests, collect no analytics, require no administrator access, and do not modify permanent macOS power settings. Their PID files contain only local process numbers.
MIT — see LICENSE.
