mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Add dark/light mode theme syncing to pi agent
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
mkdir -p ~/.pi/agent/extensions
|
||||
cp "$OMARCHY_PATH/default/pi/agent/extensions/omarchy-system-theme.ts" ~/.pi/agent/extensions/
|
||||
@@ -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/"
|
||||
Reference in New Issue
Block a user