Fancier battery displays: Stacked view, segmenting

This commit is contained in:
James Babcock committed 2026-09-09 14:46:47 -07:00
1 parent 6f60cda9cc
commit ca839f45d6
6 files changed
+277 -58

No files matched your search

+13 -14
View File
@@ -34,7 +34,7 @@ import {
assistantBridgeTokenSetting,
assistantModelSetting,
assistantSkipConfirmationSetting,
batteryDisplayModeSetting,
batteryIndicatorSettingsKey,
brightnessSetting,
onAnySettingChanged,
openAiApiKeySetting,
@@ -289,6 +289,11 @@ class ShellAlertLayer implements Layer {
}
}
/** Every setting the top bar paints from, as one comparable string. */
function topBarSettingsKey(): string {
return `${batteryIndicatorSettingsKey()}|${timeFormatSetting.get()}`;
}
class Shell {
private windows: ShellWindow[] = [];
private selectedIndex = 0;
@@ -343,11 +348,10 @@ class Shell {
private readonly chrome = new ShellChromeLayer(() => this.chromeState());
private readonly stack = new LayerStack(this.chrome, this.actions);
// Top-bar settings we mirror into the chrome; a change to either repaints
// the shell surface so the top bar reflects it immediately.
// Top-bar settings we mirror into the chrome; a change to any of them
// repaints the shell surface so the top bar reflects it immediately.
private topBarSettingsSubscribed = false;
private lastBatteryDisplayMode: string | null = null;
private lastTimeFormat: string | null = null;
private lastTopBarSettingsKey: string | null = null;
configure(config: ShellConfig): void {
this.config = config;
@@ -373,16 +377,11 @@ class Shell {
private subscribeToTopBarSettings(): void {
if (this.topBarSettingsSubscribed) return;
this.topBarSettingsSubscribed = true;
this.lastBatteryDisplayMode = batteryDisplayModeSetting.get();
this.lastTimeFormat = timeFormatSetting.get();
this.lastTopBarSettingsKey = topBarSettingsKey();
onAnySettingChanged(() => {
const batteryMode = batteryDisplayModeSetting.get();
const timeFormat = timeFormatSetting.get();
if (batteryMode === this.lastBatteryDisplayMode && timeFormat === this.lastTimeFormat) {
return;
}
this.lastBatteryDisplayMode = batteryMode;
this.lastTimeFormat = timeFormat;
const key = topBarSettingsKey();
if (key === this.lastTopBarSettingsKey) return;
this.lastTopBarSettingsKey = key;
this.config.requestShellRender();
});
}