Skip to content

davidheryanto/screen-nap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScreenNap

ScreenNap locks your Mac and turns off the display in one click — right from the menu bar.

It is built for KeepingYouAwake users. KeepingYouAwake keeps your Mac running. ScreenNap gives you a quick way to step away by locking the screen and turning off the display while background work continues.

ScreenNap works alongside KeepingYouAwake. It does not keep your Mac awake, call caffeinate, create sleep assertions, alter pmset settings, or change System Settings.

Left-click the menu bar icon to run the selected default action. Right-click or Control-click the icon to open the menu.

ScreenNap menu showing default action, screen actions, Accessibility permission, Start at Login, and Quit

Menu Actions

Action What it does Needs Accessibility
Sleep Display Now Turns off the display immediately No
Lock Screen Locks the screen Yes
Lock + Sleep Display Locks the screen, then turns off the display Yes

The menu also has Run Default Action, a Default Action picker, Accessibility Permission…, Start at Login, and Quit ScreenNap.

Lock + Sleep Display is the default left-click action.

How It Works

  • Sleep Display Now runs /usr/bin/pmset displaysleepnow via Process. It does not use sudo, shell strings, or persistent pmset changes.
  • Lock Screen sends the system Control-Command-Q shortcut using public Core Graphics APIs.
  • Lock + Sleep Display sends Control-Command-Q, waits about 0.6 seconds, then runs /usr/bin/pmset displaysleepnow.
  • Start at Login is optional, off by default, and uses the public SMAppService API.

Accessibility Permission

macOS requires Accessibility permission before an app can synthesize the Control-Command-Q keyboard shortcut used by Lock Screen and Lock + Sleep Display.

To grant it, open System Settings → Privacy & Security → Accessibility, enable ScreenNap, then try the lock action again.

Sleep Display Now does not require Accessibility permission.

Install

Download ScreenNap-0.1.0-ad-hoc.zip from the latest GitHub Release, unzip it, move ScreenNap.app to /Applications, then open it.

This build is ad-hoc signed and not notarized, so macOS may require right-clicking ScreenNap.app and choosing Open. Then grant Accessibility permission for ScreenNap if you want to use the lock actions.

Build from Source

Requirements:

  • macOS 13 or newer
  • Xcode with the macOS SDK

Build from Xcode by opening ScreenNap.xcodeproj, selecting the ScreenNap scheme, and running or archiving the app.

Or build a release app from the command line when Xcode is selected:

xcodebuild -project ScreenNap.xcodeproj -scheme ScreenNap -configuration Release -derivedDataPath .build/DerivedData -destination platform=macOS,arch=arm64 build

The built app will be at .build/DerivedData/Build/Products/Release/ScreenNap.app.

Local Testing

Copy the build to a stable path before granting Accessibility permission. Rebuilds change the signature, which can revoke trust.

osascript -e 'quit app "ScreenNap"'
ditto .build/DerivedData/Build/Products/Release/ScreenNap.app /Applications/ScreenNap.app
open /Applications/ScreenNap.app

Then grant Accessibility permission for /Applications/ScreenNap.app.

Privacy

ScreenNap has no telemetry, no network access, and no data collection. It uses only public macOS APIs and local system commands for the menu actions described above.

About

Lock your Mac and turn off the display in one click — right from the menu bar.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages