You are not logged in.
Pages: 1
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
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!
Offline
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!
Offline
Thank you for your response, KBar, this works like a charm!
Closing the thread as solved.
Offline
Thank you for your response, KBar, this works like a charm!
Closing the thread as solved.
How did you get the notification IDs?
Offline
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
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
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
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
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
Pages: 1
[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 584.34 KiB (Peak: 601.63 KiB) ]