alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
tools.pi: add auto-theme extension
author
lassulus
date
7 months ago
(Mar 22, 2026, 12:59 PM CET)
commit
83bdae9d
83bdae9d67ede45b0e5415aa8a5216bf3d96efc2
parent
ea74e846
ea74e84683d19b7c9014f9c5f26f027acd8189ec
+42
2 changed files
Expand all
Collapse all
Unified
Split
tools
pi
auto-theme.ts
flake-module.nix
+41
tools/pi/auto-theme.ts
View file
Reviewed
···
1
1
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
2
+
import { readFileSync, watch, type FSWatcher } from "node:fs";
3
3
+
4
4
+
const THEME_FILE = "/var/theme/current_theme";
5
5
+
6
6
+
function readTheme(): "dark" | "light" | null {
7
7
+
try {
8
8
+
const value = readFileSync(THEME_FILE, "utf-8").trim();
9
9
+
if (value === "dark" || value === "light") return value;
10
10
+
return null;
11
11
+
} catch {
12
12
+
return null;
13
13
+
}
14
14
+
}
15
15
+
16
16
+
export default function (pi: ExtensionAPI) {
17
17
+
let watcher: FSWatcher | null = null;
18
18
+
19
19
+
pi.on("session_start", async (_event, ctx) => {
20
20
+
// Set initial theme
21
21
+
const scheme = readTheme();
22
22
+
if (scheme) ctx.ui.setTheme(scheme);
23
23
+
24
24
+
// Watch for changes
25
25
+
try {
26
26
+
watcher = watch(THEME_FILE, () => {
27
27
+
const newScheme = readTheme();
28
28
+
if (newScheme) ctx.ui.setTheme(newScheme);
29
29
+
});
30
30
+
} catch {
31
31
+
// file doesn't exist yet, ignore
32
32
+
}
33
33
+
});
34
34
+
35
35
+
pi.on("resources_discover", async () => {
36
36
+
if (watcher) {
37
37
+
watcher.close();
38
38
+
watcher = null;
39
39
+
}
40
40
+
});
41
41
+
}
+1
tools/pi/flake-module.nix
View file
Reviewed
···
47
47
];
48
48
extensions = [
49
49
./questionnaire.ts
50
50
+
./auto-theme.ts
50
51
];
51
52
defaultProvider = "anthropic";
52
53
defaultModel = "claude-opus-4-6";