pi-theme-flip
A tiny Pi extension that immediately syncs light/dark theme changes across every Pi session running as the same user.
No polling. No OS detection. No subprocesses. Sessions share one state file and watch it with filesystem events.
Install
From npm:
pi install npm:pi-theme-flip
Try without installing:
pi -e npm:pi-theme-flip
From this repository:
npm install
npm run check
pi -e ./src/index.ts
Or install/use it as a Pi package from a local path:
pi install /absolute/path/to/pi-theme-flip
Use
/theme-flip
/theme-flip toggle
/theme-flip dark
/theme-flip light
/theme-flip status
/theme-flip toggles between Pi's built-in dark and light themes. Pi extension commands execute immediately while the agent is streaming, without interrupting its turn.
Every loaded session updates from ~/.pi/agent/theme-flip. New sessions read the same file on startup, and existing sessions recheck it before each prompt in case a filesystem event was missed.
After first install or update, restart existing Pi sessions or run /reload once in each idle session.
External control
Other processes can set every session by atomically replacing the shared state file:
mkdir -p ~/.pi/agent
printf 'dark\n' > ~/.pi/agent/.theme-flip.tmp
mv -f ~/.pi/agent/.theme-flip.tmp ~/.pi/agent/theme-flip
This gives a laptop-side macOS appearance watcher one simple target to update over SSH.
Behavior
- Shared
darkflips tolight; sharedlightflips todark. - Without shared state, the current session theme determines the first toggle.
darkandlightforce one side in every loaded session.statusreports the current session's active theme.- Missing or invalid shared state is ignored.
- Non-UI modes no-op.