Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-10-18 13:45:10

sebastian-65
Member
Registered: 2022-01-12
Posts: 14

[SOLVED] Clear all xfce4-notifyd notifications

I haven't found any obvious way how to clear all opened notifications. I would like to bind this operation to a hotkey afterwards.

- xfce4-notifyd
- no xfce4-notifyd.service found to simply restart
- Arch, systemd

Thank you for any tips and hints!

Last edited by sebastian-65 (2022-10-20 15:28:43)

Offline

#2 2022-10-18 16:38:56

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: [SOLVED] Clear all xfce4-notifyd notifications

If you mean closing the active pop-ups, then org.freedesktop.Notifications provides a CloseNotification() method.

$ dbus-send --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.DBus.Introspectable.Introspect
...
    <method name="CloseNotification">
      <arg type="u" name="id" direction="in"/>
    </method>
...

If you have a list of known notifications with their IDs, you can traverse it and close them one by one:

for i in $ids
do dbus-send \
  --print-reply \
  --dest=org.freedesktop.Notifications /org/freedesktop/Notifications \
    org.freedesktop.Notifications.CloseNotification uint32:$i
done

If you mean clearing the notification log, then I don't think there is a command for it.


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#3 2022-10-18 17:00:25

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: [SOLVED] Clear all xfce4-notifyd notifications

Unfortunately, this interface doesn't provide a method for getting the list of active notifications.

You can theoretically do `for i in $(seq 4294967295)` if you want to torture your system.


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#4 2022-10-20 15:29:58

sebastian-65
Member
Registered: 2022-01-12
Posts: 14

Re: [SOLVED] Clear all xfce4-notifyd notifications

Thank you for your response, KBar, this works like a charm!

Closing the thread as solved.

Offline

#5 2024-02-10 17:09:21

bradwiggo
Member
Registered: 2021-06-29
Posts: 15

Re: [SOLVED] Clear all xfce4-notifyd notifications

sebastian-65 wrote:

Thank you for your response, KBar, this works like a charm!

Closing the thread as solved.

How did you get the notification IDs?

Offline

#6 2024-02-11 00:34:11

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

Re: [SOLVED] Clear all xfce4-notifyd notifications

bradwiggo wrote:
sebastian-65 wrote:

Thank you for your response, KBar, this works like a charm!

Closing the thread as solved.

How did you get the notification IDs?

You would need to save them when you run the command initially. Consider the following:

Create notification and save ID:

gdbus call \
        --session \
        --dest org.freedesktop.Notifications \
        --object-path /org/freedesktop/Notifications \
        --method org.freedesktop.Notifications.Notify \
        -- \
        "identifier" \
        "0" \
        "xfce4_icon1" \
        "Xfce" \
        "Rocks" \
        "[]" \
        "{}" \
        "20000" \
    | sed 's/[^ ]* //; s/,.//' > /tmp/.notifID

...the notification ID is saved in /tmp/.notifID.

However if you just want to clear the list of notifications and clear the log, you can also:

gdbus call --session --dest=org.xfce.Notifyd --object-path=/org/xfce/Notifyd --method=org.xfce.Notifyd.Log.Clear

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

#7 2024-02-11 11:57:41

bradwiggo
Member
Registered: 2021-06-29
Posts: 15

Re: [SOLVED] Clear all xfce4-notifyd notifications

ToZ wrote:
bradwiggo wrote:
sebastian-65 wrote:

Thank you for your response, KBar, this works like a charm!

Closing the thread as solved.

How did you get the notification IDs?

You would need to save them when you run the command initially. Consider the following:

Create notification and save ID:

gdbus call \
        --session \
        --dest org.freedesktop.Notifications \
        --object-path /org/freedesktop/Notifications \
        --method org.freedesktop.Notifications.Notify \
        -- \
        "identifier" \
        "0" \
        "xfce4_icon1" \
        "Xfce" \
        "Rocks" \
        "[]" \
        "{}" \
        "20000" \
    | sed 's/[^ ]* //; s/,.//' > /tmp/.notifID

...the notification ID is saved in /tmp/.notifID.

However if you just want to clear the list of notifications and clear the log, you can also:

gdbus call --session --dest=org.xfce.Notifyd --object-path=/org/xfce/Notifyd --method=org.xfce.Notifyd.Log.Clear

Thanks, that's a useful command, --print-id option in notify-send also seems to work to get the id.

The command to clear all doesn't work for me, the notification stays visible until it times out.

Offline

#8 2024-02-11 15:42:36

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

Re: [SOLVED] Clear all xfce4-notifyd notifications

bradwiggo wrote:

Thanks, that's a useful command, --print-id option in notify-send also seems to work to get the id.

I always take the more complicated road. Thanks for pointing this out.

The command to clear all doesn't work for me, the notification stays visible until it times out.

That command clears the log and the indicator on the icon indicating there are unread notifications. I think you may be referring to removing on-screen visible notification bubbles. To remove them, if you have the ID, you can use kbar's command above.


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

#9 2024-02-12 18:43:03

bradwiggo
Member
Registered: 2021-06-29
Posts: 15

Re: [SOLVED] Clear all xfce4-notifyd notifications

ToZ wrote:
bradwiggo wrote:

Thanks, that's a useful command, --print-id option in notify-send also seems to work to get the id.

I always take the more complicated road. Thanks for pointing this out.

The command to clear all doesn't work for me, the notification stays visible until it times out.

That command clears the log and the indicator on the icon indicating there are unread notifications. I think you may be referring to removing on-screen visible notification bubbles. To remove them, if you have the ID, you can use kbar's command above.

That makes sense. Most of the notifications I want to clear come from my own scripts, so adding in a way to record the IDs shouldn't be too hard.

Alternatively I found "pkill xfce4-notifyd" works to clear all notification, is this safe to do? Notifications still seem to work after doing this, I presume xfce4-notifyd will just start up again when a notification is sent.

Offline

#10 2024-02-13 00:14:27

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

Re: [SOLVED] Clear all xfce4-notifyd notifications

bradwiggo wrote:

Alternatively I found "pkill xfce4-notifyd" works to clear all notification, is this safe to do? Notifications still seem to work after doing this, I presume xfce4-notifyd will just start up again when a notification is sent.

Yes, but its like bringing a sledgehammer to a pinky wrestling match. The first option is probably cleaner.


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

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

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 584.34 KiB (Peak: 601.63 KiB) ]