Add dark/light mode theme syncing to pi agent

This commit is contained in:
David Heinemeier Hansson
2026-05-07 15:02:18 +02:00
parent 4eb3a9198d
commit cd2c41f618
4 changed files with 48 additions and 0 deletions
@@ -0,0 +1,41 @@
/**
* Syncs pi's light/dark theme with the active Omarchy theme.
*
* Omarchy light themes include:
* ~/.config/omarchy/current/theme/light.mode
*/
import { existsSync } from "node:fs";
import { join } from "node:path";
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
const home = process.env.HOME ?? "";
const lightModePath = join(home, ".config/omarchy/current/theme/light.mode");
function omarchyPiTheme(): "light" | "dark" {
return existsSync(lightModePath) ? "light" : "dark";
}
export default function (pi: ExtensionAPI) {
let intervalId: ReturnType<typeof setInterval> | null = null;
pi.on("session_start", (_event, ctx) => {
let currentTheme = omarchyPiTheme();
ctx.ui.setTheme(currentTheme);
intervalId = setInterval(() => {
const nextTheme = omarchyPiTheme();
if (nextTheme !== currentTheme) {
currentTheme = nextTheme;
ctx.ui.setTheme(currentTheme);
}
}, 2000);
});
pi.on("session_shutdown", () => {
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}
});
}
+1
View File
@@ -24,6 +24,7 @@ run_logged $OMARCHY_INSTALL/config/unmount-fuse.sh
run_logged $OMARCHY_INSTALL/config/sudoless-asdcontrol.sh
run_logged $OMARCHY_INSTALL/config/input-group.sh
run_logged $OMARCHY_INSTALL/config/omarchy-ai-skill.sh
run_logged $OMARCHY_INSTALL/config/pi.sh
run_logged $OMARCHY_INSTALL/config/omarchy-toggles.sh
run_logged $OMARCHY_INSTALL/config/kernel-modules-hook.sh
run_logged $OMARCHY_INSTALL/config/powerprofilesctl-rules.sh
+2
View File
@@ -0,0 +1,2 @@
mkdir -p ~/.pi/agent/extensions
cp "$OMARCHY_PATH/default/pi/agent/extensions/omarchy-system-theme.ts" ~/.pi/agent/extensions/
+4
View File
@@ -0,0 +1,4 @@
echo "Add Omarchy pi system theme extension"
mkdir -p "$HOME/.pi/agent/extensions"
cp "$OMARCHY_PATH/default/pi/agent/extensions/omarchy-system-theme.ts" "$HOME/.pi/agent/extensions/"