From 7840b834b455a33d0f53c7f0439b6cdd21e86566 Mon Sep 17 00:00:00 2001 From: MondoBoricua Date: Mon, 18 May 2026 23:30:57 -0400 Subject: [PATCH] daemon: read CLAWDEX_SCALE env var to override window scale; document in README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follows the existing CLAWDEX_SOCK env var pattern in main.swift. PetWindow already accepts a scale parameter (default 0.75) — this just plumbs an env-var override through. Value parsed as Double, NaN/infinity rejected, clamped to 0.25–4.0 so a typo can't produce a window larger than the screen. No behavior change for existing users: when the var is unset, the daemon still calls PetWindow(scale: 0.75) effectively. No CLI flags, no socket protocol changes. README gets a small "Customization" section showing the values from the existing PetWindow.swift comment (0.5 pixel-perfect / 0.75 default / 1.0 2x-doubled) and the launchd plist snippet to persist it across reboots. --- README.md | 20 ++++++++++++++++++++ Sources/ClawdexApp/main.swift | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 730ff1c..961714f 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,26 @@ Already have your own atlas? Drag-drop the `pet.json` + `spritesheet.webp` pair The bundled `skill/hatch-pet/` is the format reference + atlas validator (`validate_atlas.py`). It does not generate sprite images itself — bring your own image-gen tool (MidJourney, DALL-E, hand-drawn pixel art) and use the per-row prompts in [`SKILL.md`](skill/hatch-pet/SKILL.md). +## Customization + +The default scale is `0.75`, which suits most screens. Override it with the `CLAWDEX_SCALE` env var (read once at daemon startup, clamped to `0.25`–`4.0`): + +- `0.5` → pixel-perfect on Retina (1 source px = 1 native px) +- `0.75` → default +- `1.0` → 2× pixel-doubled, still crisp via nearest-neighbor + +To make it stick across reboots, set it in the launchd plist `~/Library/LaunchAgents/dev.clawdex.daemon.plist`: + +```xml +EnvironmentVariables + + CLAWDEX_SCALE + 0.5 + +``` + +Then reload: `launchctl kickstart -k gui/$(id -u)/dev.clawdex.daemon`. + ## How it works ``` diff --git a/Sources/ClawdexApp/main.swift b/Sources/ClawdexApp/main.swift index 54a1b29..accf4a7 100644 --- a/Sources/ClawdexApp/main.swift +++ b/Sources/ClawdexApp/main.swift @@ -17,7 +17,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate { // a single binary without an Info.plist app bundle. NSApp.setActivationPolicy(.accessory) - window = PetWindow() + // Optional CLAWDEX_SCALE env var lets users override the on-screen size + // without rebuilding. Clamped to a sensible range so a typo can't + // produce a window larger than the screen or smaller than a pixel. + let scale: CGFloat = { + guard let raw = ProcessInfo.processInfo.environment["CLAWDEX_SCALE"], + let value = Double(raw), value.isFinite else { return 0.75 } + return CGFloat(min(max(value, 0.25), 4.0)) + }() + window = PetWindow(scale: scale) // Pick first available pet. If user prefers a specific one, ClawdexCLI // can send a "select" event over the socket later.