The lost post is redundant; uninterupted sleep has worked; here is the guide:
iMac & Mac Mini Deep Sleep Setup Guide
(Explanatory notes for each numbered step are located at the bottom of this guide. Code blocks for steps 4 and 6 are located in the Additional Text box.)
Quick Setup Steps
- Download and install Hammerspoon from hammerspoon.org, then enable permissions under System Settings > General > Login Items (Open at Login) and Privacy & Security (Accessibility and Input Monitoring).
- Open the Calendar app, go to Settings > Alerts, uncheck "Time to Leave", and set "Events" and "All Day Events" to None.
- Open Terminal and run:
sudo pmset -a tcpkeepalive 0 powernap 0 womp 0
sudo launchctl bootout system/com.apple.osanalyticsdIn Terminal, run sudo nano /Library/Preferences/FeatureFlags/Domain/powerd.plist, paste Script 1 (from the Additional Text box), press Ctrl + O (then Enter) to save, and Ctrl + X to exit.
- In Terminal, run sudo nano /etc/sudoers.d/btt_bluetooth, paste z ALL=(ALL) NOPASSWD: /usr/bin/pmset, /bin/launchctl, press Ctrl + O (then Enter) to save, and Ctrl + X to exit.
- Click the Hammerspoon menu bar icon and select Open Config. Delete any existing text in the document, paste Script 2 (from the Additional Text box), save the file (Cmd + S), and click Reload Config in the Hammerspoon menu bar.
- To put your Mac to sleep, press Option + /.
- To wake your Mac, press the physical Power Button, then wait 15 seconds before interacting.
Explanatory Notes
- 1: Hammerspoon requires accessibility and input permissions to detect global keyboard shortcuts and trigger actions without security prompts.
- 2: Calendar "Time to Leave" and event alerts schedule hardware real-time clock (RTC) alarms that bypass system sleep settings.
- 3: Stops background network polling and unloads the telemetry engine (osanalyticsd) to prevent automated background wake events.
- 1 : The powerd.plist file overrides system feature flags to permanently stop hardcoded 2-hour maintenance evaluation dark wakes (CSPNEvaluation).
- 2: Grants Hammerspoon passwordless execution rights for system power and launch control commands.
- 3a: Clearing default text in Hammerspoon prevents Lua syntax errors.
- 3b: The script unloads Bluetooth before sleeping to prevent peripheral wake-loops in deep hibernation (hibernatemode 25). Upon power-button wake, it restores Bluetooth and resets the system to light RAM sleep (hibernatemode 0) so short daytime idle breaks do not cause excessive write wear on your SSD.
- 3c: A 2-second buffer prevents physical key-up actions from canceling the sleep command.
- 4: Gives macOS 15 seconds to re-establish Bluetooth, Wi-Fi, and background services, preventing UI lockups when clicking complex elements.
Verification
To check that deep sleep has fully worked, run this command in Terminal:
Bash
pmset -g log | grep -E "Sleep|Wake|DarkWake" | tail -n 250 > ~/Desktop/pmset_sleep_log.txt
This will generate a text file named pmset_sleep_log.txt on your Desktop. Inspecting the log should show no entries between the moment sleep was initiated and the moment the machine was woken by the power button.