Skip to content
macOS app to deactivate the lid close sensor
Branch: master
Clone or download
Latest commit a1c6b72 Jan 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Art
Fermata.xcodeproj Rename RestlessApplication to Entry Dec 24, 2018
Resources
Source
LICENSE Remove 2nd clause from license. Dec 12, 2017
README.md

README.md

Fermata

Fermata is a small macOS utility which prevents Lid Close Sleep under certain conditions:

  1. The user manually checks the "Prevent Lid Close Sleep" menu item.
  2. A specified application is launched.
  3. A specified application prevents Idle Sleep (which is common for music-playing applications).

Why?

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.

Installation and Usage

  1. Download the latest release of Fermata.
  2. Copy the downloaded application to your /Applications folder and launch it.
  3. Click on the fermata icon in the top-right corner of your menu bar.
  4. Click "Preferences…".
  5. Add your favorite music app. By default, Fermata is configured to work with Embrace (my DJ app).

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".

How?

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.

Fermata 1.1

In a macOS 10.13 update, Apple protected the private kIOPMAssertionAppliesOnLidClose with the com.apple.private.iokit.assertonlidclose restricted entitlement. Fortunately, lozzd suggested the pmset -b disablesleep 1 command, which Fermata now uses.

Fermata 1.0

By examining Apple's IOKitUser and PowerManagement projects, I learned of a private key (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.

Disclaimer

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.

Thus:

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.
You can’t perform that action at this time.