Toqozz / wired-notify

Lightweight notification daemon with highly customizable layout blocks, written in Rust.
MIT License
608 stars 28 forks source link

Conditionally set progress bar color? #87

Closed GoldsteinE closed 2 years ago

GoldsteinE commented 2 years ago

Hi! My usecase is following: I want to display progress bar for volume and color it differently when volume is muted. Currently I could probably achieve this by creating two identical blocks with different AppName, but this is an unpleasant duplication.

GoldsteinE commented 2 years ago

Actually, two blocks with different AppName would not be deduplicated with tags, so I ended up matching on Body instead, which is even more of a hack (and for some reason not guaranteed?)

Toqozz commented 2 years ago

Why is it not guaranteed?

GoldsteinE commented 2 years ago

I’m not sure, but that’s what the documentation says:

When the notification has some body text (not guaranteed).

Toqozz commented 2 years ago

Right, that's because it is not required for a notification to have body text, only summary text, e.g.: notify-send "summary". I'll edit that section to make it a bit clearer

I assume you're creating the notifications yourself, so the right way of handling this is probably to support supplying some extra data which you can then use with a RenderCriteria. Maybe something like: notify-send "Summary" "Body" --hint="string:wired-note:mute"?

but this is an unpleasant duplication.

Unfortunately I don't think we can do much better than this. If we have options for specific use cases just under the Progress bar, then it balloons out exponentially. It would be nice if we could have some kind of conditional inclusions or something, but we're just not set up for that right now. Here's an issue that talks about some potential options: https://github.com/Toqozz/wired-notify/issues/81

GoldsteinE commented 2 years ago

I thought about %-syntax in Color strings.

I assume you're creating the notifications yourself, so the right way of handling this is probably to support supplying some extra data which you can then use with a RenderCriteria. Maybe something like: notify-send "Summary" "Body" --hint="string:wired-note:mute"?

Yes, that would be a lot cleaner.

Toqozz commented 2 years ago

I've added RenderCriteria::Note in master. You can use it like this:

In wired.ron:

render_criteria: [Note("mute")],

When sending the notification:

$ notify-send "Summary" "Body" --hint="string:wired-note:mute"
GoldsteinE commented 2 years ago

Thanks!