This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.pi: add auto-theme extension

+42
+41
tools/pi/auto-theme.ts
··· 1 + import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; 2 + import { readFileSync, watch, type FSWatcher } from "node:fs"; 3 + 4 + const THEME_FILE = "/var/theme/current_theme"; 5 + 6 + function readTheme(): "dark" | "light" | null { 7 + try { 8 + const value = readFileSync(THEME_FILE, "utf-8").trim(); 9 + if (value === "dark" || value === "light") return value; 10 + return null; 11 + } catch { 12 + return null; 13 + } 14 + } 15 + 16 + export default function (pi: ExtensionAPI) { 17 + let watcher: FSWatcher | null = null; 18 + 19 + pi.on("session_start", async (_event, ctx) => { 20 + // Set initial theme 21 + const scheme = readTheme(); 22 + if (scheme) ctx.ui.setTheme(scheme); 23 + 24 + // Watch for changes 25 + try { 26 + watcher = watch(THEME_FILE, () => { 27 + const newScheme = readTheme(); 28 + if (newScheme) ctx.ui.setTheme(newScheme); 29 + }); 30 + } catch { 31 + // file doesn't exist yet, ignore 32 + } 33 + }); 34 + 35 + pi.on("resources_discover", async () => { 36 + if (watcher) { 37 + watcher.close(); 38 + watcher = null; 39 + } 40 + }); 41 + }
+1
tools/pi/flake-module.nix
··· 47 47 ]; 48 48 extensions = [ 49 49 ./questionnaire.ts 50 + ./auto-theme.ts 50 51 ]; 51 52 defaultProvider = "anthropic"; 52 53 defaultModel = "claude-opus-4-6";