This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
63 lines (56 loc) · 2.3 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
import { format } from 'date-fns';
import chalk from 'chalk';
import notifier from 'node-notifier';
// List of friendly reminder messages
const reminderMessages = [
"Stay hydrated!",
"Time to stretch your legs.",
"Take a deep breath and relax.",
"Time for a short break?",
"Remember to stay focused!",
"Keep up the great work!",
"Don’t forget to smile!",
"Take a moment to appreciate your progress.",
"Stay positive and keep going!",
"It’s okay to take a break and recharge.",
"Check your posture and adjust your chair.",
"You’re doing an awesome job!",
"Celebrate your small wins!",
"Take a deep breath and refocus.",
"Remember to set your priorities straight.",
"Stay organized and plan your next steps.",
"Keep your workspace tidy and inspiring.",
"Stay motivated; you’ve got this!",
"Think of one thing you’re grateful for today.",
"Visualize your success and stay on track."
];
// Function to get a random reminder message
const getRandomMessage = () => {
const randomIndex = Math.floor(Math.random() * reminderMessages.length);
return reminderMessages[randomIndex];
};
// Function to show reminders at specified intervals
const showReminder = (interval) => {
console.log(chalk.green(`Friendly Reminder initialized. Reminders will appear every ${interval} minutes.`));
setInterval(() => {
const time = format(new Date(), 'HH:mm:ss');
const message = getRandomMessage();
console.log(chalk.green(`[${time}] ${message}`));
notifier.notify({
title: 'Friendly Reminder',
message: message,
sound: true, // Play sound with the notification
});
}, interval * 60 * 1000); // Convert minutes to milliseconds
};
// Parse interval argument from the command line (in minutes)
const intervalArg = process.argv[2];
// Check if the interval argument is provided and valid
let interval = parseInt(intervalArg);
if (isNaN(interval) || interval <= 0) {
console.log(chalk.yellow("Invalid or missing interval argument. Using default interval of 60 minutes."));
interval = 60; // Default to 60 minutes if no valid interval is provided
}
// Start showing reminders
showReminder(interval);