2

About:

stack-exchange-notify-send.js is a extremely minimalist 2026 desktop notifier for Stack Exchange inbox/reputation. It's browserless, dependencyless, and permissionless. It's for people who need to have a code editor not Stack Exchange open, but still want to respond promptly to comments.

The motivation was that 4 other desktop notifiers broke. It's difficult to install them because their GUI libraries require 2010s versions of GTK/Qt/etc, so mine requires no GUI library at all. Their parsing might've broke and now they might do nothing, so I chose to not do anything beyond the bare minimum parsing required, and just display the raw JSON. This philosophy should help stack-exchange-notify-send.js survive better. The WebSocket API's undocumented, but it's faster than RSS or polling.

Screenshot:

stack-exchange-notify-send.js notifying upon receiving an inbox message

Install:

Just copypaste the code below into a stack-exchange-notify-send.js file. Add your https://stackexchange.com userid. Ensure Node.js is installed. Linux/macOS users, mark it as executable. Windows/macOS users, run npm init then npm install node-notifier. If desired, use KDE Linux system settings for autostart.

Linux users can double-click to run, and Windows/all users can execute it with node stack-exchange-notify-send.js

#!/usr/bin/env node
// Go to https://stackexchange.com/ , click on your profile picture,
// then copy the number in the URL here
const stackexchange_com_userid = "";

let notifier;
const title = "Stack Exchange notify-send";
console.log(title + ": https://stackapps.com/q/11981/121649");
if (process.platform === "linux") { // Dependencyless on Linux
    const { spawn } = require("child_process");
    // https://reddit.com/r/kde/comments/if5oeb/notifications_from_script_not_saving_to_history/g2lvzvj/
    const persist = ["-h", "string:desktop-entry:org.kde.konsole"];
    // libnotify-bin is default-installed on Ubuntu. Please install it if missing in other distros
    notifier = message => void spawn("notify-send", [...persist, title, message], { stdio: "inherit" });
} else {
    const { notify } = require("node-notifier");
    notifier = message => void notify({ title, message });
}

// Surprising no authentication's required.
const s = new WebSocket("wss://qa.sockets.stackexchange.com"); // https://meta.stackexchange.com/q/218343/1373352
s.onmessage = e => {
    data = JSON.parse(e.data)
    console.log(e.data);
    if (data.action === "hb") {
        s.send("pong");
        return;
    }
    notifier(e.data); // Crude but fault-tolerant
    // Omitted filtering out 1 -> 0 upon clicking in browser.
};
s.onopen = () => {
    console.log("Hello https://stackexchange.com/users/" + stackexchange_com_userid)
    // Listen to all of the current user's inbox/reputation notifications across all sites
    // Chat's not targeted by this app except perhaps if a ping enters the inbox
    s.send(stackexchange_com_userid + "-topbar");
    console.log("Connected. Now waiting for inbox messages or reputation changes...");
};

Platform:

Linux, macOS, and Windows

Contact:

I created this app. You can contact me on Stack Exchange Chat.

License:

SPDX-License-Identifier: CC-BY-SA-4.0 OR MIT OR Apache-2.0

Code:

The Node.js programming language was used to write this. No frameworks or tools are required. You can contribute by submitting an answer or suggested edit. The source code is in the "Install:" section above.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.