feat: timer widget with countdown, stopwatch and alarm

This commit is contained in:
2026-09-25 15:12:49 +02:00
parent d15bb4687c
commit 018e326918
6 changed files with 623 additions and 3 deletions
+38 -3
View File
@@ -38,6 +38,16 @@ PluginComponent {
"y": 0.14,
"defaultVisible": true
},
{
"id": "timer",
"title": "Timer",
"icon": "timer",
"width": 380,
"height": 320,
"x": 0.57,
"y": 0.58,
"defaultVisible": false
},
{
"id": "capture",
"title": "Capture",
@@ -331,9 +341,8 @@ PluginComponent {
// ── Overlay ──────────────────────────────────────────────────────────────
function openOverlay() {
if (overlay.shouldBeVisible)
return;
// No early return on shouldBeVisible: the flag can survive a shell
// restart with no window mapped, which used to make open() a no-op.
if (typeof PopoutService !== "undefined" && PopoutService)
PopoutService.closeControlCenter();
@@ -416,6 +425,25 @@ PluginComponent {
return "SUCCESS";
}
function timer(seconds: string, label: string) : string {
const value = parseInt(seconds, 10);
if (isNaN(value) || value <= 0)
return "USAGE: timer <seconds> [label]";
timers.resetTimer();
timers.startTimer(value * 1000, label || "");
return "STARTED " + timers.formatDuration(value * 1000);
}
function timerStop() : string {
timers.resetTimer();
return "SUCCESS";
}
function timerStatus() : string {
return "timer=" + (timers.timerRunning ? "running" : (timers.timerFinished ? "finished" : "idle")) + " remaining=" + timers.formatDuration(timers.remainingMs) + " label=" + (timers.timerLabel || "(none)") + " stopwatch=" + (timers.stopwatchRunning ? "running" : "idle") + " elapsed=" + timers.formatStopwatch(timers.stopwatchElapsedMs);
}
function layoutStatus() : string {
const lines = Quickshell.screens.map(screen => {
const key = root.screenKey(screen);
@@ -459,6 +487,13 @@ PluginComponent {
readonly property alias homeService: haService
readonly property alias captureService: capture
readonly property alias timerService: timers
TimerService {
id: timers
daemon: root
}
CaptureService {
id: capture