@timmy6942025/cli-timer 1.1.5 → 1.1.6

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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/package.json +1 -1
  3. package/src/index.js +35 -21
package/README.md CHANGED
@@ -116,3 +116,7 @@ Controls in settings UI:
116
116
  - `Esc`/`q`: back/cancel
117
117
 
118
118
  Note for macOS: If system notifications are inconsistent with built-in AppleScript notifications, install `terminal-notifier` (`brew install terminal-notifier`) for improved reliability.
119
+
120
+ Notification notes by platform:
121
+ - Windows: notifications depend on OS notification permissions and whether your desktop session allows toasts/balloons.
122
+ - Linux: notifications require a running desktop notification daemon (`notify-send` talks to that daemon over D-Bus).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmy6942025/cli-timer",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Simple customizable terminal timer and stopwatch",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -611,26 +611,6 @@ function sendSystemNotification({ title, message }) {
611
611
  const titlePs = escapePowerShellSingleQuotedString(safeTitle);
612
612
  const messagePs = escapePowerShellSingleQuotedString(safeMessage);
613
613
 
614
- const ps = [
615
- "$ErrorActionPreference = 'Stop'",
616
- "try {",
617
- " [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null",
618
- " $template = [Windows.UI.Notifications.ToastTemplateType]::ToastText02",
619
- " $xml = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($template)",
620
- " $txt = $xml.GetElementsByTagName('text')",
621
- ` $txt.Item(0).AppendChild($xml.CreateTextNode('${titlePs}')) > $null`,
622
- ` $txt.Item(1).AppendChild($xml.CreateTextNode('${messagePs}')) > $null`,
623
- " $toast = [Windows.UI.Notifications.ToastNotification]::new($xml)",
624
- " $notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('cli-timer')",
625
- " $notifier.Show($toast)",
626
- "} catch { exit 1 }"
627
- ].join("; ");
628
-
629
- const powershellArgs = ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Sta", "-Command", ps];
630
- if (spawnOk("powershell", powershellArgs, { windowsHide: true })) {
631
- return true;
632
- }
633
-
634
614
  const balloon = [
635
615
  "$ErrorActionPreference = 'Stop'",
636
616
  "try {",
@@ -656,13 +636,47 @@ function sendSystemNotification({ title, message }) {
656
636
  "-Command",
657
637
  balloon
658
638
  ];
659
- return spawnOk("powershell", balloonArgs, { windowsHide: true });
639
+ if (spawnOk("powershell", balloonArgs, { windowsHide: true })) {
640
+ return true;
641
+ }
642
+
643
+ const ps = [
644
+ "$ErrorActionPreference = 'Stop'",
645
+ "try {",
646
+ " [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null",
647
+ " $template = [Windows.UI.Notifications.ToastTemplateType]::ToastText02",
648
+ " $xml = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($template)",
649
+ " $txt = $xml.GetElementsByTagName('text')",
650
+ ` $txt.Item(0).AppendChild($xml.CreateTextNode('${titlePs}')) > $null`,
651
+ ` $txt.Item(1).AppendChild($xml.CreateTextNode('${messagePs}')) > $null`,
652
+ " $toast = [Windows.UI.Notifications.ToastNotification]::new($xml)",
653
+ " $notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('cli-timer')",
654
+ " $notifier.Show($toast)",
655
+ "} catch { exit 1 }"
656
+ ].join("; ");
657
+
658
+ const powershellArgs = ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Sta", "-Command", ps];
659
+ if (spawnOk("powershell", powershellArgs, { windowsHide: true })) {
660
+ return true;
661
+ }
662
+ return false;
660
663
  }
661
664
 
662
665
  if (process.platform === "linux") {
663
666
  if (spawnOk("termux-notification", ["--title", safeTitle, "--content", safeMessage])) {
664
667
  return true;
665
668
  }
669
+ if (
670
+ spawnOk("notify-send", [
671
+ "--app-name=cli-timer",
672
+ "--urgency=critical",
673
+ "--icon=dialog-information",
674
+ safeTitle,
675
+ safeMessage
676
+ ])
677
+ ) {
678
+ return true;
679
+ }
666
680
  if (spawnOk("notify-send", [safeTitle, safeMessage])) {
667
681
  return true;
668
682
  }