Skip to content

daemon: read CLAWDEX_SCALE env var to override window scale#1

Open
MondoBoricua wants to merge 1 commit into
danielkempe:mainfrom
MondoBoricua:feat/configurable-scale
Open

daemon: read CLAWDEX_SCALE env var to override window scale#1
MondoBoricua wants to merge 1 commit into
danielkempe:mainfrom
MondoBoricua:feat/configurable-scale

Conversation

@MondoBoricua
Copy link
Copy Markdown

What

Adds a CLAWDEX_SCALE env var that lets users override the on-screen pet size without rebuilding from source. Default behavior is unchanged.

Why

The default 0.75 scale (hardcoded in PetWindow.init) looks great on most setups but feels oversized on some screens — I ended up patching the source locally to get a smaller sprite. Figured an env var would save the next person that same dance, since the pattern already exists in the daemon (CLAWDEX_SOCK).

How

main.swift reads CLAWDEX_SCALE once at startup, parses as Double, rejects NaN/infinity, clamps to 0.254.0, and passes the result into the existing PetWindow(scale:) initializer. No CLI flag, no socket protocol changes, no new types — same pattern as the existing CLAWDEX_SOCK handling a few lines below.

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)

The README gets a small Customization section reusing the scale guide that's already in the PetWindow.swift comment (0.5 pixel-perfect / 0.75 default / 1.0 2× pixel-doubled) plus a launchd plist snippet to persist it across reboots.

Behavior

CLAWDEX_SCALE Effect
unset PetWindow(scale: 0.75) — identical to today
0.5 smaller, pixel-perfect on Retina
1.0 larger, 2× pixel-doubled
foo / NaN / empty falls back to 0.75
0.01 / 999 clamped to 0.25 / 4.0

Tested

  • swift build -c release clean
  • Ran daemon with CLAWDEX_SCALE=0.5 and CLAWDEX_SCALE=1.0 — sprite resized correctly, state machine + dragging still work
  • Ran with unset / garbage values — falls back to 0.75 as expected
  • macOS 26 (Tahoe), Swift 6.3.2, Apple Silicon

Out of scope (happy to follow up if you want)

  • Live reload: change requires daemon restart (launchctl kickstart -k gui/\$(id -u)/dev.clawdex.daemon)
  • CLI flag like clawdex wake --scale 0.5 — would need socket protocol additions, felt too heavy for this
  • Per-pet scale in pet.json — different design question (whose preference wins?)

Thanks for clawdex by the way — it's great.

… in README

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.
Copilot AI review requested due to automatic review settings May 19, 2026 03:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional CLAWDEX_SCALE environment variable so users can adjust the pet window scale at daemon startup without recompiling, mirroring the existing CLAWDEX_SOCK pattern. The value is parsed as a Double, validated against NaN/infinity, and clamped to 0.254.0. README gets a new Customization section documenting the variable plus a launchd plist snippet.

Changes:

  • Read and validate CLAWDEX_SCALE in AppDelegate.applicationDidFinishLaunching, passing the result to PetWindow(scale:).
  • Document the new env var, scale guidance, and launchd persistence in README.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/ClawdexApp/main.swift Parse CLAWDEX_SCALE, fall back to 0.75 on invalid input, clamp to [0.25, 4.0], pass into PetWindow.
README.md Add Customization section explaining CLAWDEX_SCALE and launchd plist usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants