Skip to content

hs.power.lockScreen fails because bundled CGSession path no longer exists #224

Description

@alkene5

Summary

hs.power.lockScreen() fails because it tries to launch a hard-coded CGSession binary that is absent on the current macOS installation.

Error

2026-09-14 17:40:31 - Error: hs.power.lockScreen: failed to launch CGSession: Error Domain=NSCocoaErrorDomain Code=4 "The file “CGSession” doesn’t exist." UserInfo={NSFilePath=/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession}

Investigation

The implementation currently uses:

let cgSession = "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession"
process.executableURL = URL(fileURLWithPath: cgSession)
process.arguments = ["-suspend"]

That path does not exist on this system, so the function always fails before a lock request is made. This appears to be an application implementation issue rather than a user configuration problem.

Expected behavior

hs.power.lockScreen() should lock the screen on supported current macOS versions, or use a supported fallback when CGSession is unavailable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions