Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-05-18 12:38:01

SoundMachine
Member
Registered: 2020-05-18
Posts: 2

[Solved] Update Desktop-notification instead of creating a new one

Hello,

I hope this is the right place to ask...
I use my pc to remote-control the volume of my media-pc.
When changing the volume I visualize it using notify-send.
However, when changing the volume several times (e.g. when it decreasing it a lot),
I get several notifications each with a volume bar.

Is there a possibility to update one notification instead of showing several (as is is done when I use the system volume up/down hotkeys)?

My system is:
Linux Mint 19.3 with XFCE (4.14)

I use this BASH command to create the notification:
notify-send -h int:value:$VOLUME -h string:x-canonical-private-synchronous:volume -t 1500 -i $ICON 'Volume : '$VOLUME

Kind regards and thank you for your help :-)

Last edited by SoundMachine (2020-05-19 10:46:14)

Offline

#2 2020-05-18 17:27:12

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,488

Re: [Solved] Update Desktop-notification instead of creating a new one

Hello and welcome.

notify-send does not support re-using notifications and xfce4-notifyd does not support the x-canonical-private-synchronous hint (I believe this is a notify-osd thing).

You could use a gdbus call to start and update an existing notification. For example, the initial call:

gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify APPLICATION 1 audio-volume-low "Message" "Body" [] {} 20000

...where:
- APPLICATION is the name of your app
- 1 is the reuse ID - not relevant in the first call, will be used in update call
- audio-volume-low is the name of the icon
- Message is the title of the notification
- Body is the body of the notification
- 20000 is the notification timeout (how long it stays on the screen)

When you run this command, it will output something like:

(uint32 412,)

...412 is the ID of the notification that needs to be reused, so to reuse and update the existing notification:

gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify APPLICATION 412 audio-volume-high "Message" "Body" [] {} 20000

Programatically, you can save the parsed output to a temporary file and re-use the ID if needed.

Or you could use notify-desktop, which also supports reusable notifications but does all the heavy lifting for you.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-05-19 10:45:15

SoundMachine
Member
Registered: 2020-05-18
Posts: 2

Re: [Solved] Update Desktop-notification instead of creating a new one

Thank you for your detailed answer.

Using gdbus and grabbing the ID works fine.
I created an ASCII-slider as message body so the graphical slider isn't missing at all.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 524.97 KiB (Peak: 531.45 KiB) ]