macOS app to deactivate the lid close sensor
Fermata is a small macOS utility which prevents Lid Close Sleep under certain conditions:
While DJing our weekly social dance, my laptop went to sleep and interrupted playback of the current song. Fortunately, the crowd was forgiving and the floor recovered.
After wading through logs, I discovered that the Lid Close sensor was activated. Originally, I thought that my laptop was failing; and then I realized: the sensor detects a magnetic field and headphones are magnetic (Apple's support article mentions speakers, but not headphones).
Many DJs and musicians use headphones during live performances. It's common to place those headphones near the laptop when not in use.
Unfortunately, macOS has no built-in option to disable the Lid Close sensor. Apps such as InsomniaX and NoSleep attempt to prevent it via a kernel extension. I had issues getting these apps to work due to Apple's System Integrity Protection and User-Approved Kernel Extension Loading.
/Applicationsfolder and launch it.
When Embrace starts to play audio, it prevents Idle Sleep via a call to
-[NSProcessInfo beginActivityWithOptions:reason:]. Fermata sees this prevention and "upgrades" it to also prevent Lid Close Sleep. When Embrace stops playing audio, it once again allows Idle Sleep. Fermata sees this and re-enables Lid Close Sleep.
Some applications may not properly prevent Idle Sleep. For these apps, use the "is running" option rather than "is preventing Idle Sleep".
Note: this is private SPI and is unsupported by Apple. It could break in the future; it could cause your computer to explode; it could cause the Apple Power Management Team to show up at my doorstep and angrily chastise me; etc.
In a macOS 10.13 update, Apple protected the private
com.apple.private.iokit.assertonlidcloserestricted entitlement. Fortunately, lozzd suggested the
pmset -b disablesleep 1command, which Fermata now uses.
kIOPMAssertionAppliesOnLidClose) which can be used in conjunction with
IOPMAssertionDeclareUserActivity()to prevent Lid Close sleep.
I've filed rdar://35954315 for a public API solution to this problem.
This software disables your Lid Close Sensor. While Apple laptops are designed to operate in "closed-display mode", Fermata makes it easier to accidentally toss a running laptop into your bag. This can result in overheating or damage to mechanical hard drives.
In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.