Skip to content

erel3/lidguard-helper

Repository files navigation

LidGuard icon

LidGuard Helper

Privileged helper daemon for LidGuard

Release Platform Swift License

Silent background daemon managed by launchd with on-demand socket activation.
Handles features that require elevated privileges or private APIs.


Features

🛡️ Clamshell Sleep Preventionsudo pmset disablesleep via sudoers
🔒 Lock Screen Overlay — fullscreen "STOLEN DEVICE" window via SkyLight private API
Power Button Detection — NSEvent system-defined events (requires Accessibility)

How It Works

LidGuard app ──TCP──▶ launchd ──socket activation──▶ lidguard-helper
                       port 51423                      ├─ pmset
                       JSON + shared secret auth       ├─ SkyLight overlay
                                                       └─ power button monitor

Idle 30s → daemon exits → launchd restarts on next connection

The daemon is not always running. launchd listens on port 51423 and starts the daemon only when the main app connects. Zero resource usage when LidGuard isn't active.

Install

Build from Source

git clone https://github.com/Erel3/lidguard-helper.git
cd lidguard-helper
make build          # Swift release build
make install        # install binary + LaunchAgent, load via launchctl
make uninstall      # unload and remove
make lint           # run swiftlint

Install Location

What Where
Binary ~/Library/Application Support/LidGuard/lidguard-helper
LaunchAgent ~/Library/LaunchAgents/com.lidguard.helper.plist
Shared secret ~/Library/Application Support/LidGuard/.ipc-secret
Sudoers /etc/sudoers.d/lidguard (set up by main app or PKG installer)

IPC Protocol

Newline-delimited JSON over localhost TCP port 51423.

Commands (App → Daemon)

Command Description
auth Authenticate with shared secret (must be first)
enable_pmset / disable_pmset Toggle clamshell sleep prevention
show_lock_screen / hide_lock_screen Toggle lock screen overlay
enable_power_button / disable_power_button Toggle power button monitoring
get_status Query current state of all features

Events (Daemon → App)

Event Description
auth_result Authentication success/failure
status Current state of pmset, lock screen, power button
power_button_pressed Power button was pressed
error Error message

Permissions

Permission Why
Accessibility Power button detection via NSEvent
Sudoers pmset disablesleep requires root

License

MIT

About

Privileged helper for LidGuard — enables lock screen, sleep prevention, and power button detection

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors