hoodie / notify-rust

☝️send desktop notifications from your Rust app.
Apache License 2.0
1.17k stars 74 forks source link

A controllable way to add timeouts #181

Closed denispeplin closed 3 months ago

denispeplin commented 1 year ago

I found that on Ubuntu 20.04 I can't really control timeouts and to control timeouts better I have to use Urgency::Critical and then wait_for_action. I also found, that on the same system, a notification sometimes could be sent but not being displayed, so my program stuck waiting for an action on a notification that was never displayed. Both wait_for_action and on_close are blocking (means the issue is related a bit to #36), and also I can't clone NotificationHandler. My partial solution to those issues it's not a perfect one, since while I introduced an external timeout, I can't close a notification after my process times out. My attempt to ask on Stackoverflow didn't give any results apart from the solution I was able to find myself.

Any thoughts?

hoodie commented 1 year ago

The current way this is implemented is not ideal. You're thread solution is basically state-of-the-art of what is possible right now I'm afraid. We could add a mechanism that uses channels to notify-rust, but ultimately that would also require a thread. Alternatively there is an experimental async version on a branch somewhere, but that's not done yet unfortunately.

denispeplin commented 1 year ago

The only thing I really miss here is an ability to close the notification on timeout. But for now, I can live without it.

hoodie commented 1 year ago

but that should be the default behaviour of .timeout()

denispeplin commented 1 year ago

If I wanted to close a notification from my "external timeout" thread, I would need a handler, which is unavailable because it's being used by on_close.

The whole reason why I'm using the external timeout is that I wasn't able to reliable set up .timeout().

hoodie commented 1 year ago

Do you need the critical urgency btw? I think that is specified to make the notification stick around. I only just noticed that in your SO post

denispeplin commented 1 year ago

Yep, I need it. Otherwise, notifications are being closed pretty quickly with random timeouts (and using .timeout() doesn't help). Maybe it's just my OS that behaves so weird, but critical helped to resolve that.