linux_notification_center
linux_notification_center copied to clipboard
Closing updated notifications is impossible or requires many clicks
First of all, this is a really cool project, thank you for developing and maintaining it!
Note: I'm using this on sway but with GDK_BACKEND=x11. All other features work (surprisingly) well, so I don't think this bug is Xwayland-related, but at the same time I don't have an X11 box to check that it's not.
Anyways, I have this project: https://github.com/balsoft/simple-osd-daemons/ which shows on-screen display for volume via pulseaudio and the currently playing song via mpris. To achieve this, it creates notifications when it first receives an event from pulseaudio or mpris, and then updates those notifications upon subsequent events. This works pretty well with mako, which I used previously, but for some reason with linux_notification_center I can't close those notifications by either clicking on them with mouse1 or dismissing them from the notification drawer. I can easily close most other notifications (from notify-send, firefox, etc), and I can also close notifications from simple-osd-daemons if they weren't updated (e.g. when I just change the volume once and then dismiss the notification) so I assume this is either a problem with my project somehow not following the spec or with linux_notification_center. Help would be appreciated either way.
Those notifications also seem to crash the notification center sometimes, but it's pretty random so I don't have a way to reproduce it yet. Error message is:
deadd-notification-center: src/NotificationCenter/Notifications/NotificationPopup.hs:(138,5)-(156,18): Non-exhaustive guards in multi-way if
Also sometimes those notifications forcefully close the drawer or prevent it from being opened, don't know how to reliably reproduce this either.
EDIT: opened #101 for this specifically
Inspecting the source code at the given position (in the error):
https://github.com/phuhl/linux_notification_center/blob/a155a6b826b6380f9c712aa07e345a66d0b622a1/src/NotificationCenter/Notifications/NotificationPopup.hs#L129-L158
You can see that there is an edge-case (I think) where valid is True (so the mouse button pressed is in the list, the dismiss button also is, and the default action also is), but where you did not press any of the dismiss button or the default action, which according to https://github.com/phuhl/linux_notification_center/blob/a155a6b826b6380f9c712aa07e345a66d0b622a1/src/Config.hs#L138-L139 is either mouse1 (left click I believe) or mouse3 (right click) or some custom value in your configuration. Because you did not share any of your configuration, I'm assuming you have the default one from now on.
There should be a case where valid is True, but you pressed none of the configured buttons, to prevent this crash (I believe). I'll leave this to confirm to people who actually contributed and know the codebase way better than me.
Something like adding this case
| valid -> do
putStrLn $ "Mouse button " <> mouseButton <> " has been recognized as a valid input but is not configured"
notiOnClosed noti $ User
onClose
-- or do a better action there, up to you
should fix it.
I do believe this helped isolating this issue, if really it was it. Can you confirm that pressing a non-configured button happens to crash the notification center?
Yes, the issue with notification center crashing was indeed because I made a middle mouse button click on one of the notifications. This is probably separate from my main issue, so I'll report a new one.
Thanks for reporting :)
The fix proposed by @Mesabloo should work (to fix #101). If you want, open a working PR and I'll merge it. Otherwise, I will do it, but don't know when, yet
I, too, had the issue with not being able to close notifications but I couldn't produce a fix for it, yet. If it helps, for the time being, you can open and close the notification center to make notifications disappear, or you can bind notify-send.py a --hint boolean:deadd-notification-center:true string:type:clearPopups to a key to clear the notification-popups.
@phuhl fix for #101 is in #102 (although a bit of a different solution).
Thanks for the tips on working around the issue.