Custom Notifications with 'gdbus call' + 'wired-notify'
June 9, 2022
5 min read
I wanted to write this short guide on the functionality of
gdbus call as I couldn't find any resources online regarding it besides its own documentation. I'll also quickly cover my
wired-notify config, since it's a really neat notification daemon that I don't think is nearly popular enough :)
Here's the reason I went through this trouble, first off - a tiny configurable volume HUD that live-updates in place as you change the device volume!
gdbus call has many use-cases, the one I'll focus on here is sending custom notifications, as notify-send doesn't expose many of the properties I needed to set.
notify-send, along with other notification frameworks I looked at, didn't support updating existing notifications using identifiers.
gdbus call does allow this granular control, along with exposing some other cool properties.
Running this will return
(uint32 1,), the '1' representing the notification's unique identifier. This is useful if you want to parse that identifier and re-use it later; one way to do so would be using sed (e.g.,
sed 's/[^ ]* //; s/,.//' would strip everything but the identifier).
A few other tips:
--sessionrepresents the user's
--methodin this case are all used to point to freedesktop.notifications.notify, and the following parameters are specified in
- The '1' represents the identifier, and the replaces ID
- The following blank string is the notification icon
- The following two strings are for the Summary (notification title) and Body (multi-line description)
- The empty array is for actions, for ex, sending a callback to the application when clicked
- The empty dictionary is for hints; these are used to send extra data such as (in my use case) the current volume level, an image, extra text, etc
- The '4000' represents the expiration timeout in ms. If set to -1, it falls back to the notification server's default
The body text can, in most cases, contain limited markup:
- <b>...</b> for bold,
- <i>...</i> for italics,
- <u>...</u> for underlines,
- <a href="...">...</a> for links, and
- <img src="..." alt="...">...</img> for images
Hints are provided as a dictionary, using the following format:
So, for example, sending a hint for the integer value of my volume notification looks like:
And for providing a file path for an image preview:
Note that when providing the dictionary in the command, it should be encased by double-quotes.
That's all there is to it! I hope this comes in handy for someone at some point :)
Finally, if you're curious, here's my wired-notify config, as well as the simple script I call on volume update to send a notification to it: