From ff4a417a2a899446d5c8d7b15dcb1da357f60e1e Mon Sep 17 00:00:00 2001 From: DuskyElf Date: Sun, 2 Aug 2026 18:20:16 +0530 Subject: [PATCH] fix(timers): drop seconds readout, escape <1m for RichText Show <1m for sub-minute intervals and strip seconds above a minute (systemctl can emit 129ms-style sub-second LEFT values). Escape the < in <1m as < so Qt RichText does not parse it as a malformed tag and corrupt the table layout. --- scripts/timers.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/timers.mjs b/scripts/timers.mjs index 56a268b..ce529fa 100755 --- a/scripts/timers.mjs +++ b/scripts/timers.mjs @@ -22,7 +22,13 @@ function rel(s, mark) { // drop the space between value and unit ("2 d" -> "2d") .replace(/(\d) ([a-zA-Z])/g, "$1$2") .trim(); - return mark === "left" ? `in ${out}` : `${out} ago`; + // Sub-minute (pure seconds or ms) reads as <1m. The output goes into Qt + // RichText, so a raw `<` would be parsed as a malformed tag and corrupt the + // table layout: escape it as <. + const body = /^(\d+ms|\d+s)$/.test(out) + ? "<1m" + : out.replace(/\d+ms(?:\s+|$)/g, "").replace(/\d+s(?:\s+|$)/g, "").trim(); + return mark === "left" ? `in ${body}` : `${body} ago`; } // One timer line from `systemctl [--user] list-timers --all --no-pager`. -- 2.51.2