-
Notifications
You must be signed in to change notification settings - Fork 46
Description
I'm glad to report that the latest version of NoSleep (1.5.1) works perfectly on Apple Silicon machines with no code changes required!
Basically, just compiling an additional arm64e (not arm64) binary slice to the NoSleep kext works! @integralpro
Tested on macOS 12.0.1 21A559, "Monterey".
(I do realise that this isn't really an issue per se, but I just felt really bad for all the users complaining about broken functionality here…)
(Plus, speaking from my own personal experience as a fellow developer, I do find it quite helpful when someone else already tested compatibility for me ;P)
If you're a general user coming who just wants to use NoSleep on Apple Silicon right this instant…
Ever since macOS / OS X 10.10 Yosemite, Apple has required kernel extensions (kexts) to be signed by developers who are subscribed to the Apple Developer Program, who also have to apply for a special kext signing privilege.
You're… probably not one of those people. ;P
Luckily, there is a way for you to sign your own kexts using an Xcode feature called ad-hoc signing! But it does require changing some settings first.
Switching to "Reduced Security" mode
If you've already placed your Mac in "Reduced Security" mode before, simply skip this section.
- Shut down your Apple Silicon Mac.
- Press and hold down the power button until the text under the Apple logo says "Loading startup options…", then let go.
- Select "Options".
- You are now in recoveryOS — enter your password if it asks.
- Go to Utilities → Startup Security Utility.
- Select "Reduced Security" and enable Allow user management of kernel extensions from identified developers".
- Shut down your Apple Silicon Mac.
Disabling SIP (System Integrity Protection)
IMPORTANT: Disabling SIP in any capacity, even partially, will also disable Apple Pay, as well as any iOS-on-macOS apps you may have downloaded from the App Store. This is a strange (and annoying) decision that Apple has decided to make specifically on Apple Silicon, as Apple Pay actually works fine even when SIP is disabled on x86_64 (Intel) Macs.
- Follow steps 2〜4 from above.
- Go to Utilities → Terminal.
- Type in the following to fully disable SIP:
csrutil disable
Note: It is possible to only partially disable the part of SIP that enforces kext signature verification (csrutil enable --without kext), but according to Apple, this is apparently an "unsupported configuration". Use it if you wish (as many do already), but please make sure to read and fully understand the warning thatcsrutilgives if you try. - Reboot your Apple Silicon Mac.
Compiling NoSleep for Apple Silicon (arm64e)
- Download and install Xcode.
- Install the official version of NoSleep 1.5.1. Ignore the "Oops! NoSleep Kernel Extension is not loaded." message for now.
- Run the following in a Terminal session. When it asks for your password, it is normal for no characters to show when when you type!
git clone --recursive https://github.com/integralpro/nosleep.git
cd nosleep/NoSleep/
xcodebuild VALID_ARCHS="x86_64 arm64e" CODE_SIGN_IDENTITY="-" -sdk macosx -configuration Release -target NoSleepKext
sudo cp -rv ../DerivedData/Release/NoSleep.kext /Library/Extensions/- Go to System Preferences → Security & Privacy and approve the NoSleep kernel extension.
- Reboot and enjoy NoSleep!
Regarding sudo pmset disablesleep 1 and sudo pmset disablesleep 0
Interestingly, there appears to be an undocumented pmset setting called disablesleep that seems to pretty much does what NoSleep does (prevent macOS from sleeping when the lid is closed).
Because it's undocumented, it's not really a guarantee that this setting will continue to exist in future macOS versions, but for now, if you don't want to deal with the procedure above and you're comfortable with using the Terminal to toggle your sleep functionality…
sudo pmset disablesleep 1 in a Terminal will prevent macOS from sleeping when the lid is closed.
sudo pmset disablesleep 0 will re-enable the default behaviour.
To see the current status, use pmset -g and look for "SleepDisabled".
And yes, this does mean that it is possible to write a NoSleep-like front-end complete with menu bar item to toggle the pmset functionality. If NoSleep is EOL'd by integralpro or broken by Apple to the point of requiring a complete rewrite some day, that's what I'll probably end up doing.