English | 中文
A macOS menu bar utility that catches you slouching. It fuses the MacBook's hidden lid-angle sensor with Vision face-pitch detection to compute your true head-down angle, and nudges you when you've been hunching over for too long.
camera optical axis
↗ (rises with the lid: lid − 90°)
▢ screen
╱ lid angle (hidden HID sensor)
▁▁▁▁╱▁▁▁▁ base
true head pitch (vs. horizontal, positive = up)
= pitchSign × Vision face pitch (camera-relative) + (lid angle − 90°)
- Lid angle — Apple Silicon MacBooks ship a hidden hinge-angle sensor
(HID Sensor page
0x20, usage0x8A). Feature report ID 1 returns a little-endianUInt16in degrees (0 ≈ closed, 90 = upright, 180 = flat). No special permissions required. - Face pitch — AVFoundation captures the built-in camera at VGA
resolution and runs Vision's
VNDetectFaceRectanglesRequest(VNFaceObservation.pitch, macOS 12+). Frames are analyzed in memory only — nothing is stored or uploaded. - Fusion — face pitch is camera-relative; tilting the screen back raises
the camera by
lid − 90°. Compensating for it yields a gravity-referenced head pitch, so re-tilting your screen never causes false alarms and never requires recalibration. - Duty-cycle checks (battery-friendly) — the camera is not always on. Every 3 minutes (configurable) it wakes for an 8-second burst, takes the median, and shuts off. Idle cost is one timer (~0% CPU, measured); the green camera light stays off between checks. On AC power the interval automatically shrinks to ⅓ (min 30 s, shown with ⚡ in the menu); on battery it returns to the configured value. Calibration (first launch or manual recalibration) prompts you to sit straight, waits 3 seconds, then takes a fast 3-second burst (~18 densely-sampled frames, median taken); it retries in 15 s if no face was seen and warns if the captured baseline looks implausibly low.
- Escalating judgment — when a check finds your head more than 15° (configurable) below the baseline, the app escalates instead of just alerting: it switches to continuous tracking (camera stays on) until you recover. During tracking, slouching sustained for 10 s (configurable) triggers a notification + sound (optional voice), at most once per minute. Once posture stays good for 30 s, tracking ends and a vigilant period begins — checks every minute for 10 minutes — before returning to the normal cadence. Tracking also ends if you walk away (30 s without a face) or after a 10-minute cap. Bending down to pick something up won't nag you; judgment is suspended while your head is turned away (|yaw| > 35°). A permanent realtime mode (~0.5–1 W) remains available, mainly for debugging.
- Automatic yielding — locking the screen suspends monitoring (
🪑🔒; an immediate check runs 2 s after unlock instead of waiting out the interval), and checks are skipped while another app (a video call) holds the camera, rescheduled at the normal cadence with a "camera in use" hint in the menu.
Download the latest PostureGuard.app.zip from
Releases, unzip, and run.
The app is ad-hoc signed, so on first launch you may need to clear quarantine:
xattr -cr PostureGuard.app
open PostureGuard.appOr build from source:
./make-app.sh # builds build/PostureGuard.app
open build/PostureGuard.app # first launch asks for camera permissionLaunch at login: System Settings → General → Login Items → add
PostureGuard.app.
Note: with ad-hoc signing the signature hash changes on every rebuild, so macOS treats each rebuild as a new app — the camera permission prompt reappears once per rebuild. Day-to-day use is unaffected.
Menu bar states: 🙆 good posture · 🙇 slouching · 🚨 alert fired ·
🪑📐 calibrating · 🪑 no face · 🪑⏸ paused · 🪑🔒 screen locked ·
🪑🪫 low power · 🪑📷✕ no camera permission. Emoji-only by default; enable "show angle in menu bar" to append
the live deviation (e.g. 🙇 -17°).
From the menu you can: recalibrate to your current posture, pause/resume,
set the alert threshold (10/15/20/25°), set the check interval
(realtime / 1 / 3 / 5 min), toggle the menu bar angle display, toggle voice
alerts, and opt into monitoring during Low Power Mode (off by default —
entering Low Power Mode suspends detection, shown as 🪑🪫, and it resumes
automatically when the mode ends). The UI language (中文/English) follows
the system language; force it with --lang zh|en.
Voice alerts use AVSpeechSynthesizer and automatically pick the
highest-quality installed voice for the language — download a Premium voice
in System Settings → Accessibility → Spoken Content → System Voice for the
best result (Siri voices are not exposed to third-party apps).
open build/PostureGuard.app --args --debug
tail -f /tmp/posture-guard.debug.logEach line logs lid (lid angle), vision (raw Vision pitch), head
(compensated head pitch), dev (deviation from baseline), and the state.
Verify direction: dev should go negative when you bow your head; if it
moves the opposite way, launch with --invert-pitch (the stale baseline is
discarded and recalibrated automatically).
CLI options: --threshold N --check-interval N (0 = realtime)
--duration N (realtime mode only) --interval N --voice
--invert-pitch --no-lid --debug --reset (clear calibration and
settings).
- The lid-angle sensor exists only on recent Apple Silicon MacBooks. Without it the app falls back to raw face pitch (recalibrate after re-tilting the screen).
- Assumes the base sits flat on a desk. On a lap or tilted stand the baseline shifts — just recalibrate.
- Clamshell mode with an external display won't work — the built-in camera is covered.
- Apple never documented the sign convention of
VNFaceObservation.pitch. Measured empirically (macOS 26.5, correlation −0.95 between pitch and the face's vertical position in frame): positive pitch = head down, and the defaultpitchSign = -1is set accordingly. If a future OS flips it, launch with--invert-pitch.
