forked from Blendman974/faceclaw
Watch display shows if glasses are charging or silent mode
This commit is contained in:
1 parent
ed8302bc6b
commit
6cd7d5fff9
10 files changed
+122
-20
No files matched your search
@@ -0,0 +1,34 @@
|
||||
export type GlassesDisplayState = {
|
||||
phase: string;
|
||||
silentMode: boolean;
|
||||
screenOn: boolean;
|
||||
battery: number | null;
|
||||
foregroundTitle: string | null;
|
||||
};
|
||||
|
||||
/** Compact status shown where the foreground-window title normally lives. */
|
||||
export function glassesDisplayLabel(state: GlassesDisplayState): string {
|
||||
// Charging wins over every session-local state: the glasses are in their
|
||||
// case, so neither the lock screen nor the foreground window is visible.
|
||||
if (state.phase === "charging") {
|
||||
return chargingDisplayLabel(state.battery);
|
||||
}
|
||||
if (state.phase !== "connected") {
|
||||
return "Glasses disconnected";
|
||||
}
|
||||
if (state.silentMode) {
|
||||
return "Silent mode";
|
||||
}
|
||||
if (!state.screenOn) {
|
||||
return "Display off";
|
||||
}
|
||||
return state.foregroundTitle || "Launcher";
|
||||
}
|
||||
|
||||
export function chargingDisplayLabel(battery: number | null): string {
|
||||
return validBatteryLevel(battery) ? `Charging · G2 ${battery}%` : "Charging";
|
||||
}
|
||||
|
||||
function validBatteryLevel(battery: number | null): battery is number {
|
||||
return battery !== null && Number.isInteger(battery) && battery >= 0 && battery <= 100;
|
||||
}
|
||||
Reference in new issue
Block a user