mikaelbr / node-notifier

A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
MIT License
5.72k stars 323 forks source link

Buttons + Replies for Linux #428

Open alichtman opened 1 year ago

alichtman commented 1 year ago

It seems like it's not currently possible to get replies to notifications on Ubuntu at the moment. It would be awesome if I could! Same for buttons on Linux notifs.

#!/usr/bin/env node

import {execa} from 'execa';
import {Notification} from 'node-notifier';
const jrnl = (...args) => execa("jrnl", args);

(async () => {
    const desiredFrequency = "1 minute"
    const recentEntries = (await jrnl(`-from "${desiredFrequency} ago"`)).stdout;
    if (recentEntries != "") {
        console.log(`jrnl has entries within the last ${desiredFrequency}`);
        return;
    }

    Notification().notify({
        title: "jrnl reminder",
        message: "You haven't added a jrnl entry in a while. Write one now?",
        closeLabel: "Not now",
        reply: true,
        wait: true,
        timeout: 60
    },
        function (err, response, metadata) {
            jrnl(response);
        }
    );
})();

image

Missing reply box, and custom button text.

Example notification with a button:

image