Add Pi theme based on system theme
Based entirely on the work of @robzolkos in #5711. That attempt was adapted to better fit the standard templating system while also adding color mixing for use in other themes.
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* 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 "@earendil-works/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;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
|
||||
"name": "omarchy-system",
|
||||
"vars": {
|
||||
"background": "{{ background }}",
|
||||
"foreground": "{{ foreground }}",
|
||||
"accent": "{{ accent }}",
|
||||
"selectionBackground": "{{ selection_background }}",
|
||||
"selectionForeground": "{{ selection_foreground }}",
|
||||
"selectedBackground": "{{ mix background accent 22% }}",
|
||||
"color0": "{{ color0 }}",
|
||||
"color1": "{{ color1 }}",
|
||||
"color2": "{{ color2 }}",
|
||||
"color3": "{{ color3 }}",
|
||||
"color4": "{{ color4 }}",
|
||||
"color5": "{{ color5 }}",
|
||||
"color6": "{{ color6 }}",
|
||||
"color7": "{{ color7 }}",
|
||||
"color8": "{{ color8 }}",
|
||||
"color9": "{{ color9 }}",
|
||||
"color10": "{{ color10 }}",
|
||||
"color11": "{{ color11 }}",
|
||||
"color12": "{{ color12 }}",
|
||||
"color13": "{{ color13 }}",
|
||||
"color14": "{{ color14 }}",
|
||||
"color15": "{{ color15 }}",
|
||||
"panel": "{{ mix background foreground 6% }}",
|
||||
"panelAlt": "{{ mix background foreground 10% }}",
|
||||
"panelPending": "{{ mix background accent 12% }}",
|
||||
"panelSuccess": "{{ mix background color2 12% }}",
|
||||
"panelError": "{{ mix background color1 12% }}",
|
||||
"border": "{{ mix background foreground 30% }}",
|
||||
"borderMuted": "{{ mix background foreground 20% }}",
|
||||
"mutedText": "{{ mix foreground background 34% }}",
|
||||
"dimText": "{{ mix foreground background 52% }}"
|
||||
},
|
||||
"colors": {
|
||||
"accent": "accent",
|
||||
"border": "border",
|
||||
"borderAccent": "accent",
|
||||
"borderMuted": "borderMuted",
|
||||
"success": "color2",
|
||||
"error": "color1",
|
||||
"warning": "color3",
|
||||
"muted": "mutedText",
|
||||
"dim": "dimText",
|
||||
"text": "foreground",
|
||||
"thinkingText": "dimText",
|
||||
"selectedBg": "selectedBackground",
|
||||
"userMessageBg": "panel",
|
||||
"userMessageText": "foreground",
|
||||
"customMessageBg": "panel",
|
||||
"customMessageText": "foreground",
|
||||
"customMessageLabel": "accent",
|
||||
"toolPendingBg": "panelPending",
|
||||
"toolSuccessBg": "panelSuccess",
|
||||
"toolErrorBg": "panelError",
|
||||
"toolTitle": "accent",
|
||||
"toolOutput": "foreground",
|
||||
"mdHeading": "color5",
|
||||
"mdLink": "accent",
|
||||
"mdLinkUrl": "color6",
|
||||
"mdCode": "color6",
|
||||
"mdCodeBlock": "foreground",
|
||||
"mdCodeBlockBorder": "borderMuted",
|
||||
"mdQuote": "mutedText",
|
||||
"mdQuoteBorder": "borderMuted",
|
||||
"mdHr": "borderMuted",
|
||||
"mdListBullet": "color5",
|
||||
"toolDiffAdded": "color2",
|
||||
"toolDiffRemoved": "color1",
|
||||
"toolDiffContext": "mutedText",
|
||||
"syntaxComment": "dimText",
|
||||
"syntaxKeyword": "color5",
|
||||
"syntaxFunction": "color4",
|
||||
"syntaxVariable": "accent",
|
||||
"syntaxString": "color2",
|
||||
"syntaxNumber": "color3",
|
||||
"syntaxType": "color4",
|
||||
"syntaxOperator": "color5",
|
||||
"syntaxPunctuation": "mutedText",
|
||||
"thinkingOff": "borderMuted",
|
||||
"thinkingMinimal": "accent",
|
||||
"thinkingLow": "color4",
|
||||
"thinkingMedium": "color5",
|
||||
"thinkingHigh": "color3",
|
||||
"thinkingXhigh": "color1",
|
||||
"bashMode": "color3"
|
||||
},
|
||||
"export": {
|
||||
"pageBg": "{{ background }}",
|
||||
"cardBg": "{{ mix background foreground 6% }}",
|
||||
"infoBg": "{{ mix background foreground 10% }}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user