Privileged helper daemon for LidGuard
Silent background daemon managed by launchd with on-demand socket activation.
Handles features that require elevated privileges or private APIs.
🛡️ Clamshell Sleep Prevention — sudo pmset disablesleep via sudoers
🔒 Lock Screen Overlay — fullscreen "STOLEN DEVICE" window via SkyLight private API
⚡ Power Button Detection — NSEvent system-defined events (requires Accessibility)
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.
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| 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) |
Newline-delimited JSON over localhost TCP port 51423.
| 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 |
| 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 |
| Permission | Why |
|---|---|
| Accessibility | Power button detection via NSEvent |
| Sudoers | pmset disablesleep requires root |