Skip to content

About

A lightweight, zero-dependency Scheduled Theme panel embedded inside Antigravity 2.0 Desktop (Windows) Settings > Appearance — auto-switches Light/Dark themes on schedule without touching Windows system mode. | 轻量、零依赖的 Antigravity 2.0 桌面端(Windows)定时切换深浅色主题工具,原生嵌入 Settings > Appearance,绝不修改 Windows 系统主题。

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

antigravity-theme-timer

English | 简体中文

A lightweight, zero-dependency, fully reversible Scheduled Theme panel embedded directly inside Antigravity 2.0 Desktop (Windows) under Settings > Appearance.

Automatically switch Antigravity between your preferred Light and Dark themes on a daily schedule — without ever touching Windows system dark/light mode.


Features

  • Native UI inside Settings > Appearance: Reuses Antigravity's own CSS variables (--background, --foreground, --border, --primary, etc.) so the Scheduled Theme card blends seamlessly in both Light and Dark modes (and custom presets).
  • Never modifies Windows OS theme: Only controls Antigravity's own theme state via its internal theme providers. All other Windows apps remain untouched.
  • Custom Day / Night schedule: Configure daytime start (default 08:00) and nighttime start (default 23:00), including cross-midnight intervals (23:00–08:00) and inverted schedules.
  • Per-slot theme presets: Choose either Current Light/Dark Preset (mode-only switch, preserving your custom colors) or specific Antigravity presets (Default Light, Default Dark, Everforest, Nord, Catppuccin, Dracula, Tokyo Night, One Dark Pro, Solarized, Monokai, Gruvbox Material, Vesper, plus dynamically detected plugin presets).
  • Precision boundary scheduling & instant cold-start catch-up: Uses a single exact boundary setTimeout (DST fall-back aware, with a 15-minute drift check and zero background timers when disabled) instead of constant 30-second polling, plus parallel config/provider startup binding and focus/visibility/sleep-wake catch-up — opening Antigravity at 02:00 AM immediately applies your Night theme.
  • Ultra-low runtime overhead: Decouples Settings page detection from mounted panel updates, uses narrow anchor-cached DOM probing and diff-based UI updates (zero full-page scans or redundant <option> rebuilds during chat streaming), and encodes presets & scoped CSS compactly.
  • Manual Override Protection: Optional guard using expected-receipt matching (plus startup hydration grace protection) that detects when you manually switch themes via Antigravity's native controls and pauses auto-switching until the next scheduled boundary (displaying Paused until HH:MM (manual override) with a one-click Resume schedule link).
  • Switch Now button: One-click manual flip between your configured Day and Night themes, coordinated with override protection.
  • Zero external dependencies: Pure vanilla JavaScript runtime + pure Windows PowerShell scripts (no Node.js, Python, React toolchain, or asar CLI required).
  • 100% reversible & atomic: Creates a byte-exact resources\app.asar.bak backup before patching, validates the temporary patched archive and .bak cleanliness before committing via same-volume atomic File.Replace, and refuses to stack-patch or operate on truncated archives. Safe to re-run after Antigravity auto-updates.

Screenshots

Light Mode

Scheduled Theme panel in Settings > Appearance (Light Mode)

Dark Mode (with Manual Override Protection active)

Scheduled Theme panel in Settings > Appearance (Dark Mode)


Requirements

  • OS: Windows 10 / 11 (built-in Windows PowerShell 5.1 or PowerShell 7+)
  • Target: Antigravity 2.0 Desktop installed under %LOCALAPPDATA%\Programs\antigravity (or pass -InstallDir <path>)

Usage

1. Install

  1. Close Antigravity Desktop completely (or pass -ForceClose).
  2. Open PowerShell in the repository root and run:
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1

If Antigravity is installed in a custom directory:

powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -InstallDir "D:\Path\To\Antigravity"
  1. Launch Antigravity and open Settings > Appearance. You will see the Scheduled Theme section embedded directly in the page.

2. Check Status

Inspect whether the patch is active, not installed, or overwritten by a recent Antigravity update (read-only):

powershell -ExecutionPolicy Bypass -File .\scripts\status.ps1

3. After Antigravity Auto-Updates

When Antigravity updates itself, its installer replaces resources\app.asar with the new version. Simply close Antigravity and re-run install.ps1:

powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1

The script automatically detects the new clean app.asar, refreshes resources\app.asar.bak with the new version's original binary, and re-applies the patch cleanly without duplicates. Your saved schedule and theme preferences are preserved automatically.

4. Uninstall

Close Antigravity and restore the original resources\app.asar byte-for-byte:

powershell -ExecutionPolicy Bypass -File .\scripts\uninstall.ps1

To also remove your saved schedule configuration from %APPDATA%\antigravity\app_storage.json:

powershell -ExecutionPolicy Bypass -File .\scripts\uninstall.ps1 -CleanConfig

Project Structure

antigravity-theme-timer/
├── src/
│   └── theme-timer.js        # Vanilla JS runtime (DOM observer, scheduler, override guard, native UI)
├── scripts/
│   ├── install.ps1           # Auto-locate Antigravity, check process, .bak backup, idempotent ASAR patch
│   ├── uninstall.ps1         # Byte-exact rollback from .bak (+ optional -CleanConfig)
│   └── status.ps1            # Read-only status check (Installed / Not Installed / Overwritten)
├── docs/                     # UI screenshots (light & dark mode)
├── README.md                 # English documentation
├── README_CN.md              # Chinese documentation
├── LICENSE                   # MIT License
└── .gitignore

How It Works

  1. Pure-PowerShell Atomic ASAR Patching: install.ps1 parses the Electron resources\app.asar header once using fast .IndexOfAny JSON span scanning, backs up the original file byte-for-byte to resources\app.asar.bak, encodes src/theme-timer.js with minimal valid JS string escaping (eliminating PowerShell 5.1 ConvertTo-Json escape bloat), recalculates SHA-256 block integrity metadata, verifies the temporary archive before committing via same-volume File.Replace, and enforces strict truncation/clean-backup guards.
  2. Scoped Main-World Injection: Non-target frames (SSH remote windows and embedded webviews) short-circuit before loading Electron APIs. Only local Antigravity Hub windows execute src/theme-timer.js via webFrame.executeJavaScript.
  3. Official Theme State Bridge & Low-Overhead UI: theme-timer.js runs authoritative config loading in parallel with O(1)-queue React Fiber discovery to bind SettingsSyncedStateProvider (themeModeProvider and customThemeSeedsProvider). Precision boundary timers and expected-receipt override detection keep themes synced even when Settings > Appearance is closed, while narrow .max-w-2xl/h3 anchor caching and diff updates keep Settings UI rendering lightweight.
  4. Port-Safe Persistence: Because Antigravity's local language server binds to an ephemeral 127.0.0.1 port on every launch, configuration is persisted under the isolated namespace key antigravity.themeTimer.v1 in window.nativeStorage (%APPDATA%\antigravity\app_storage.json), mirrored to localStorage as a session cache.

Safety & Disclaimer

  • This is an unofficial community project and is not affiliated with or endorsed by Google.
  • install.ps1 modifies only dist/preload.js inside resources\app.asar after creating a full byte-exact backup (resources\app.asar.bak). No other application binaries or Windows system settings are modified.
  • Future Antigravity updates may change internal frontend structures or enable Electron ASAR integrity fuses (EnableEmbeddedAsarIntegrityValidation). If an update ever causes issues, run .\scripts\uninstall.ps1 to immediately restore the clean application binary.

License

MIT

About

A lightweight, zero-dependency Scheduled Theme panel embedded inside Antigravity 2.0 Desktop (Windows) Settings > Appearance — auto-switches Light/Dark themes on schedule without touching Windows system mode. | 轻量、零依赖的 Antigravity 2.0 桌面端(Windows)定时切换深浅色主题工具,原生嵌入 Settings > Appearance,绝不修改 Windows 系统主题。

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages