mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
44 lines
2.0 KiB
TypeScript
44 lines
2.0 KiB
TypeScript
import { inProcessTrayWidget, type AppDefinition } from "../app-definition";
|
|
import { shell } from "../../ui/shell/shell";
|
|
import { registerTimerTools } from "../../assistant/timer-tools";
|
|
import { timerEngine, timersWakeSetting } from "./timer-engine";
|
|
import { createTimerAppWindow, showTrayTimer, startTimersTrayIcon, TIMER_SURFACE_ID, TIMER_WINDOW_ID } from "./timer-app";
|
|
|
|
/**
|
|
* Timers, stopwatch and alarms. The clock engine boots with the shell so
|
|
* timers and alarms fire (and the assistant's timer.* / alarm.* tools work)
|
|
* with no window open; launching only opens the view on it.
|
|
*/
|
|
const timerApp: AppDefinition = {
|
|
appId: "timer",
|
|
title: "Timers",
|
|
icon: "timer",
|
|
boot: (ctx) => {
|
|
timerEngine.boot({
|
|
playBuzzer: (payload) => ctx.actions.playBuzzerSequence(payload),
|
|
onRing: (item) => {
|
|
// Bring the ringing item on screen: focus the Timers window, then
|
|
// wake the display if it is off (a setting, since a wearer may
|
|
// prefer the phone alone while the glasses sleep). Only once it is
|
|
// actually showing does the phone start its acknowledgement clock;
|
|
// otherwise the phone adds its own sound within seconds.
|
|
void ctx
|
|
.launchApp("timer")
|
|
.then(() => {
|
|
if (timersWakeSetting.get() && !shell.isScreenOn()) shell.wake("window");
|
|
if (shell.isScreenOn() && shell.foregroundWindow()?.windowId === TIMER_WINDOW_ID) {
|
|
timerEngine.markDeliveredToGlasses(item);
|
|
}
|
|
})
|
|
.catch((error) => console.error(`timers ring launch failed: ${error}`));
|
|
},
|
|
});
|
|
// Selected in the switcher, the tray readout shows its timer in the app's window.
|
|
startTimersTrayIcon(inProcessTrayWidget(ctx, TIMER_WINDOW_ID, TIMER_SURFACE_ID, createTimerAppWindow, showTrayTimer));
|
|
registerTimerTools((appId) => ctx.launchApp(appId));
|
|
},
|
|
launch: (ctx) => ctx.launchInProcessApp(TIMER_WINDOW_ID, TIMER_SURFACE_ID, createTimerAppWindow),
|
|
};
|
|
|
|
export default timerApp;
|