-
Notifications
You must be signed in to change notification settings - Fork 165
Description
It would be nice to have a way to "stream" notifications out so that another app can get updates when notifications land.
Right now, I can find out the list of pending notifications with mako list. I can make a custom waybar panel, for example, that will count the number of such entries with something like: makoctl list | jq '.data[] | length', and I could integrate that in waybar.
But then I need to refresh this all the time, and that's costly (say, on battery), as I have to wakeup all the time. Meh.
A better way would be to have some sort of streaming interface where a caller could hook into mako and get pushed updates. The way sway-notification-center works in that regard is interesting. Look at the output of the --subscribe-waybar flag:
> swaync-client --subscribe-waybar
{"text": "0", "alt": "none", "tooltip": "", "class": "none"}
Now, that output is kind of specific to waybar of course: this is a JSON object formatted in a way that Waybar will like. But this could be anything you like... The blobs in the .data field of makoctl list would be fine, as an intermediate filter could parse those and generate the correct waybar output.
The key here is to have mako send those updates over a pipe somehow, instead of the callers pulling those in.
Right now, my mako integration in waybar is substandard, as the message count doesn't automatically update. But it's the best I could do with the current interface, it would be great to have a push system to improve on this!
"custom/dnd": {
"interval": "once",
"return-type": "json",
"format": "{}{icon}",
"format-icons": {
"default": "",
"do-not-disturb": ""
},
"on-click": "makoctl mode -t 'do-not-disturb' > /dev/null; pkill -RTMIN+11 waybar",
"on-click-right": "makoctl dismiss --all ; pkill -RTMIN+11 waybar",
"exec": "mako-waybar-output",
"signal": 11
},the exec (mako-waybar-output) is now a standalone script that looks like this:
#!/bin/sh
count="$(makoctl list | jq '.data[] | length')"
mode="$(makoctl mode | grep 'do-not-disturb' || echo default)"
if [ "$mode" != "default" ]; then
class="$mode"
elif [ $count -gt 0 ]; then
class="active"
fi
printf '{"text": "%s", "alt":"%s","tooltip":"mako notification mode: %s", "class": "%s"}' "$count" "$mode" "$mode" "$class"I suspect something around dbus would be needed to implement this, but I'm not familiar enough with dbus (let alone mako's implementation) to figure this out..
Thanks!