@timmy6942025/cli-timer 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -114,3 +114,5 @@ Controls in settings UI:
114
114
  - `/`: filter fonts in font picker
115
115
  - `/`: filter keys in key picker
116
116
  - `Esc`/`q`: back/cancel
117
+
118
+ Note for macOS: If system notifications are inconsistent with built-in AppleScript notifications, install `terminal-notifier` (`brew install terminal-notifier`) for improved reliability.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmy6942025/cli-timer",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Simple customizable terminal timer and stopwatch",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -480,6 +480,21 @@ function spawnOk(command, args, options) {
480
480
  }
481
481
  }
482
482
 
483
+ function terminalNotifierDelivered(groupId) {
484
+ try {
485
+ const listed = spawnSync("terminal-notifier", ["-list", groupId], { encoding: "utf8", stdio: "pipe" });
486
+ if (listed.error || listed.status !== 0) {
487
+ return false;
488
+ }
489
+ const output = String(listed.stdout || "");
490
+ return output.includes(groupId);
491
+ } catch (_error) {
492
+ return false;
493
+ } finally {
494
+ spawnOk("terminal-notifier", ["-remove", groupId]);
495
+ }
496
+ }
497
+
483
498
  function sendSystemNotification({ title, message }) {
484
499
  const safeTitle = String(title || "").trim() || "Timer";
485
500
  const safeMessage = String(message || "").trim();
@@ -490,13 +505,16 @@ function sendSystemNotification({ title, message }) {
490
505
 
491
506
  try {
492
507
  if (process.platform === "darwin") {
508
+ const groupId = `cli-timer-${Date.now()}-${Math.floor(Math.random() * 1e9)}`;
509
+ if (spawnOk("terminal-notifier", ["-title", safeTitle, "-message", safeMessage, "-group", groupId])) {
510
+ if (terminalNotifierDelivered(groupId)) {
511
+ return true;
512
+ }
513
+ }
493
514
  const script = `display notification "${escapeAppleScriptString(safeMessage)}" with title "${escapeAppleScriptString(safeTitle)}"`;
494
515
  if (spawnOk("osascript", ["-e", script])) {
495
516
  return true;
496
517
  }
497
- if (spawnOk("terminal-notifier", ["-title", safeTitle, "-message", safeMessage])) {
498
- return true;
499
- }
500
518
  return false;
501
519
  }
502
520