An open API service indexing awesome lists of open source software.

https://github.com/shinniuwu/nocoffeinereminder

A Node.js coffee-limit reminder. Schedules daily alerts with cron & FFplay
https://github.com/shinniuwu/nocoffeinereminder

caffeine coffee cron daily-reminder ffmpeg keyboard-listener nodejs productivity reminder time-management typescript

Last synced: 3 months ago
JSON representation

A Node.js coffee-limit reminder. Schedules daily alerts with cron & FFplay

Awesome Lists containing this project

README

          

# NoCoffeeInReminder

![No coffee sign](./assets/nocoffee.png)

NoCoffeeInReminder is a simple reminder tool designed to help you remember when to stop drinking coffee. It allows you to set a time for a daily reminder, at which point it will play a sound using `ffplay`. You can stop the sound at any time by pressing a global hotkey (`Alt + F` by default).

## Features

- **Reminder Scheduling**: Set a daily reminder time for your caffeine break.
- **Sound Notification**: Play a sound to remind you to take a break, using `ffplay`.
- **Global Keyboard Listener**: Stop the sound at any time with a custom keybind (default is `Alt + F`).
- **Customizable Time**: Use a human-readable time (e.g., "8:00 PM") to set the reminder.
- **Persistent Settings**: Save the reminder time and cron expression in a JSON file (`settings.json`) for future use.
- **Checks FFplay on Startup**: Ensures `ffplay` is available; prints a helpful error and exits if not found.

## Requirements

- **Node.js** (v16 or higher recommended)
- **ffplay** (part of `ffmpeg`, ensure it’s installed and available in your system’s PATH)
- **node-global-key-listener** (installed automatically via `npm install`)

## Installation

1. **Clone** or **download** this repository.
2. **Install dependencies**:
```bash
npm install
```
3. **Ensure `ffplay` is installed** and on your system PATH. For instance:
- **macOS**:
```bash
brew install ffmpeg
```
- **Ubuntu**:
```bash
sudo apt install ffmpeg
```
- **Windows**: Follow the [FFmpeg installation guide](https://ffmpeg.org/download.html).

4. **Build/Compile** (if using TypeScript):
```bash
npm run build
```
Or run directly with a TS executor (e.g., `ts-node` or `tsx`):
```bash
npx tsx src/index.ts
```

## Usage

When the program starts, you’ll see a menu:

1. **Settings**: Set or update the time (e.g., "8:00 PM") for your daily reminder.
2. **Exit**: Terminate the application.

Once set, the reminder will **play a sound** at the specified time every day. You can **stop the sound** at any time by pressing `Alt + F` (or your configured keybind).

### Example Workflow

1. **Start the program**:
```bash
npx tsx src/index.ts
```
2. **Set a reminder** time when prompted (e.g., `"8:00 PM"`).
3. **Wait** until the specified time.
4. **Sound plays** via `ffplay` at the set time.
5. **Press `Alt + F`** (system-wide) to stop the sound if desired.

### Changing the Reminder

- At any time, choose **Settings** from the menu to update your reminder time or keybind.
- The time is stored in `settings.json`, along with the generated cron expression.

## File Structure

- **`src/`**: Contains the TypeScript source code (entry point: `index.ts`).
- **`assets/`**: Contains the `nocoffee.png` used in this README.
- **`settings.json`**: Holds the user-defined reminder time, cron expression, and stop key combination.
- **`sound/`**: Should contain the `sound.mp3` (or other audio file) played when the reminder triggers.

## Troubleshooting

- **FFplay not found**: If the script exits immediately and warns about `ffplay`, make sure you have **FFmpeg** installed and that `ffplay` is accessible on your system PATH.
- **Keybind issues**: On some systems, “Alt” may be recognized as “Option,” or conflicts might occur with other apps. Try a different combo (e.g., `Ctrl+Q`).
- **Permissions**: Ensure you can write to the project folder so that `settings.json` can be created/updated.

## Contributing

1. **Fork** the repository.
2. **Create a feature branch** (`git checkout -b feature/foo`).
3. **Commit your changes** (`git commit -m 'Add some feature'`).
4. **Push** to your fork (`git push origin feature/foo`).
5. **Create a Pull Request**.

All contributions are welcome—bug reports, improvements, or new features.

## License

This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details.