Toqozz / wired-notify

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

Feature: rendering criterea for specific appnames. #62

Closed BeyondMagic closed 2 years ago

BeyondMagic commented 2 years ago

I think the title is pretty straightfoward, would make this 100x more customisable, being able to put some notifications in the center, others in the left top with different font sizes, etc.

(
    name: "root",
    parent: "",
    hook: Hook(parent_anchor: TM, self_anchor: MM),
    offset: Vec2(x: 0.0, y: .0),
    render_criteria: [AppName(["telegram-deskto", "firefox"])],
    params: NotificationBlock((...)),
),

(
    name: "root",
    parent: "",
    hook: Hook(parent_anchor: TR, self_anchor: RT),
    offset: Vec2(x: -25.0, y: 40.0),
    render_anti_criteria: [AppName(["telegram-deskto", "firefox"])],
    // https://github.com/Toqozz/wired-notify/wiki/NotificationBlock
    params: NotificationBlock((...)),
),

I'll try to see how it works and see if I can actually make somewhat a prototype.

Toqozz commented 2 years ago

This should be a pretty simple add yep. If you wanna give a PR a shot I'll leave it to you. Let me know if you have any questions 😃.

BeyondMagic commented 2 years ago

I'm trying, catching up with reality and learning some Rust finally

Toqozz commented 2 years ago

A good place to start looking might be https://github.com/Toqozz/wired-notify/blob/8298b7281ea4f5e3a22853ce299e4d621caabaec/src/rendering/layout.rs#L77-L111

I forgot but there actually is an AppName criteria already but it only checks if a name exists, which isn't very useful. We probably want to replace that with a string compare or something.

lukelex commented 2 years ago

I'd dig this.

BeyondMagic commented 2 years ago

All right, I think I did it, but the notifications that are not rendered simply keep alive indefinitely (from the senders' side). I'll try to fix it before opening up a PR.

E: It's due to the Action handlering.

lukelex commented 2 years ago

My 5 cents. Inverting the dependency tree, so that apps can choose which layout to use, would be a more scalable solution IMHO. Specially since apps can change name between versions and it'd be out of our control.

Having to make changes to a layout configuration every time a new app comes along sounds like the wrong way to go about it.

BeyondMagic commented 2 years ago

True, but what do you mean by inverting the dependency tree?

E: And this version app-name-changing seems more like a problem with these apps themselves rather than the notification server, as far as I can see, it's like fixing a bug it's not meant for you to mess with.

Toqozz commented 2 years ago

So I've added some support for logical operators in render_criteria and render_anti_criteria now. Would you mind trying this out @BeyondMagic and letting me know if there are any issues/things missing?

I ended up going with what you said and just did it the simple way:

...
    name: "root",
    parent: "",
    hook: Hook(parent_anchor: TL, self_anchor: TL),
    offset: Vec2(x: 7.0, y: 7.0),
    render_criteria: [And([AppName("Wired"), Body]), Or([AppName("Firefox"), AppName("Chromium")])],
    //render_anti_criteria: [Or([AppName("Wired"), AppName("Hello"), AppName("jo")])],
...

The above will match and show a notification that has either:

BeyondMagic commented 2 years ago

I'll give a look next sunday, thanks for the hard work implementating it.

BeyondMagic commented 2 years ago

Working perfectly, thank you.

Toqozz commented 2 years ago

Available in 0.10.2.