miniblog.

← Back to all posts
110
Are there any nice cross-platform ways to trigger a notification from a terminal? I've been using https://pushover.net/ but you need to use a browser and it's noticeably slower than the native options. (Pushover is great for mobile notifications though.)

10 Comments

@wilfredh In a desktop OS running on the same machine or a different machine?
@wilfredh ah, missed the "cross-platform" part – I'm not sure notify-send will work outside Linux
@wilfredh Yes, Microsoft Azure provides Notification Hubs to handle this. “nice” is maybe the part that’s a bit dicey… If you’re already familiar with Service Bus it’s not too bad, but if not, ehhh - it’s a lot. There’s a bit of DIY wiring you have to do at first, then you can just use curl to send a message and the notification goes to all devices that have registered themselves. Maybe spend a few minutes reading the docs, but if you’re not feeling it, don’t bother going deeper.
@wilfredh I haven't used it but I know this exists, I hope it is what you need https://codeberg.org/mrus/overpush
@wilfredh One interesting way of sending "notifications" is ringing the terminal bell, i.e. `echo -e '\a'`. Many terminal emulators show some kind of notification or badge when that happens while the terminal is in the background. It works across many platforms and even through ssh!
@wilfredh @moonhouse If it's just for these two, you can use `notify-send` on Linux and something like `osascript -e "display notification \"$1\" with title \"notify-send\""` on macOS. I've created a script for the latter, so that I can type `notify-send` without thinking on which OS I am right now.
@wilfredh Oh, I forgot another good way of raising notifications: OSC 777. It is cross-platform, but needs terminal support. Instead of continuing to spam this thread, I put all of this into a blog post: https://www.karl.berlin/terminal-notifications.html