tuidoro 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "version": "0.1.1",
3
3
  "name": "tuidoro",
4
4
  "description": "A minimal pomodoro timer that runs in your terminal.",
5
5
  "author": "b12o",
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import { createLayout } from "./layout.js";
5
5
  import { logger } from "./logger.js";
6
6
  import { Timer } from "./timer.js";
7
7
  import type { TimerState } from "./types.js";
8
- import { loadConfig, playSound } from "./utils.js";
8
+ import { loadConfig, playSound, isAudioAvailable } from "./utils.js";
9
9
 
10
10
  //@ts-ignore -- this is a bun-specific file embed import that ts is not aware of
11
11
  import toggleSound from "../assets/tuidoro_toggle.mp3" with { type: "file" };
@@ -23,6 +23,7 @@ let zenModeEnabled = config.zenMode ?? false;
23
23
 
24
24
  const {
25
25
  root,
26
+ audioAvailableContainer,
26
27
  captionContainer,
27
28
  captionText,
28
29
  timeContainer,
@@ -43,6 +44,7 @@ renderer.root.add(root);
43
44
  // initial render
44
45
  timeText.color = RGBA.fromHex(timer.activeColor);
45
46
  showHideElements();
47
+ audioAvailableContainer.visible = config.sound && !isAudioAvailable();
46
48
 
47
49
  // 250ms in order to respond fairly quickly to timer.ts updates without
48
50
  // unnecessarily re-rendering UI
package/src/layout.ts CHANGED
@@ -37,6 +37,15 @@ export function createLayout(renderer: CliRenderer, initialData: InitialData) {
37
37
  fg: RGBA.fromHex(offWhite),
38
38
  });
39
39
 
40
+ const audioAvailableText = new TextRenderable(renderer, {
41
+ id: "audioAvailable",
42
+ content:
43
+ "Can't play audio ('paplay' not installed).\
44
+ Disable 'sound' in your config or install paplay to remove this notice.",
45
+ justifyContent: "center",
46
+ fg: RGBA.fromHex(offWhite),
47
+ });
48
+
40
49
  const separator = new TextRenderable(renderer, {
41
50
  content: "_________________________________________",
42
51
  fg: RGBA.fromHex(gray),
@@ -66,6 +75,12 @@ export function createLayout(renderer: CliRenderer, initialData: InitialData) {
66
75
  fg: RGBA.fromHex(offWhite),
67
76
  });
68
77
 
78
+ const audioAvailableContainer = new BoxRenderable(renderer, {
79
+ id: "audioAvailableContainer",
80
+ border: true,
81
+ });
82
+ audioAvailableContainer.add(audioAvailableText);
83
+
69
84
  const captionContainer = new BoxRenderable(renderer, {
70
85
  id: "captionContainer",
71
86
  alignItems: "center",
@@ -119,6 +134,7 @@ export function createLayout(renderer: CliRenderer, initialData: InitialData) {
119
134
  alignItems: "center",
120
135
  justifyContent: "center",
121
136
  },
137
+ audioAvailableContainer,
122
138
  captionContainer,
123
139
  timeContainer,
124
140
  pomodoriContainer,
@@ -129,6 +145,7 @@ export function createLayout(renderer: CliRenderer, initialData: InitialData) {
129
145
 
130
146
  return {
131
147
  root,
148
+ audioAvailableContainer,
132
149
  captionContainer,
133
150
  captionText,
134
151
  timeContainer,
package/src/timer.ts CHANGED
@@ -176,6 +176,7 @@ export class Timer {
176
176
  this.caption = WORK_CAPTION;
177
177
  }
178
178
  notifyMessage = this.caption;
179
- notifyMessage.length > 0 && Bun.spawn(["notify-send", notifyMessage]);
179
+ if (notifyMessage.length)
180
+ Bun.spawn(["notify-send", notifyMessage], { stderr: "ignore" });
180
181
  }
181
182
  }
package/src/utils.ts CHANGED
@@ -58,3 +58,7 @@ export async function loadConfig(): Promise<PomodoroSettings> {
58
58
  return defaultSettings;
59
59
  }
60
60
  }
61
+
62
+ export function isAudioAvailable() {
63
+ return Bun.which("paplay") !== null;
64
+ }