Closed carlosV2 closed 2 years ago
If anyone is interested on this, I've managed to compose a jq
query that does exacly this:
$ swaync-client -swb | jq '.text=(.tooltip|match("\\d+").string//"0")'
If you are planning to plug this command into waybar, you need to add the following flags to jq
:
-c
: To make the output compact (single-line)-M
: To make the output monochrome (disable colors)--unbuffered
: To show the output as soon as it is readyHere is a working and minimal waybar configuration with all this in mind:
"custom/notifications": {
"format": "{}",
"return-type": "json",
"exec": "swaync-client -swb | jq -c -M --unbuffered '.text=(.tooltip|match(\"\\\\d+\").string//\"0\")'",
}
Great suggestion! I don't think that I'll have any time to add this but here's the swaync-client file src/client.vala specifically these lines: https://github.com/ErikReider/SwayNotificationCenter/blob/440ca813c78424e933977fec87d007f1c6fee0c9/src/client.vala#L77-L93
Hi @ErikReider,
Thanks for your help. I've just created a PR with this silly change.
Thank you!
Hi,
I just replaced
mako
withswaync
and, so far, I love it.I think there is tho a missed opportunity on the waybar subscription. You see, this is the output I'm getting:
This is really cool but I would like to have the number of notifications displayed in the waybar too and it would be as easy as including the number only in the
text
field too. Ultimately, it is up to the user to show the number or not. If the README example is followed as is, it would still not show the number as{}
is missing in theformat
field.I'll try to add the number there with a bash/python script although I'm pretty sure it should be pretty straight forward to return it from the
swaync-client
too. If you point me to the right files, I can attempt a PR (provided you like this option, of course).Thanks for a great project!