phuhl/linux_notification_center

Scripting, styling etc (multiple questions)

Closed this issue ยท 3 comments

xoores commented

Hi,

I recently discovered this project and I kinda love it - it is quite customizable and allows me to create similar notification center that I had on MacOS and that I miss ๐Ÿ™‚ I recently switched from Dunst to this (I'm using i3) and everything is quite nice.

I have a few things that I was not able to figure out even when diggin through the code and I'm trying my luck here. If you want, I can open separate issue for each question/problem but I figured that I can start like this and after that I could share my config & scripts for others to see and use.

I would try to hack some of these things in but I'm completely unfamiliar with Haskell (I'm more C/Java/Python kind of guy) and looking through the source did not really help with my understanding of this language ๐Ÿ˜

Q1: Modifying urgency in script?

I have a use case that I want to filter messages from IM based on the content/sender. Some of the messages are not important, some really are and thus I'd love to change urgency in the script. Right now it is not possible (atleast it did not work when I tried).

What do you think about that?

Q2: "default action" click

When "default action" is fired, the target window does not get activated for some reason. No worries, I could do that using wmctrl or something similar - if I had some way to hook myself into that "default action" and either completely override that or (better) allow me to extend what happens. Is this possible? Or can I somehow force deadd to activate window when clicking on notification?

Q3: How do I get blurred background? ๐Ÿ˜…

In screenshots in README.md there is a lovely blurred background. But shipped CSS does not do that and I was not able to figure out on how to achieve this by myself ๐Ÿ˜ I can only get transparent background.

How do I acheve this, please?

Q4: monitor: primary?

I often dock my computer, moving my primary monitor from internal LCD to the big main monitor. That means that I would love to have notifications on that primary monitor (can be somewhat achieved by follow-mouse) and to have my notification center on the primary monitor.

I can get it to the primary monitor if I kill deadd, but this wipes notification history which is not ideal ๐Ÿ™

Is there any possibility to achieve this? I can easily send any kind of signal when monitors change - either directly UNIX signal or some DBUS message.

Q5: Aging notifications in notify-center or deleting based on filter

Some notifications are by their nature time-relevant. Meaning that after some time they might as well disapper from the notification center history.

Can I delete some notifications based on either some ID, name or their age? Or perhaps add some kind of timeout in history so that these notifications don't build up over time?

I know I can "delete all" or the individual notifications but that is not really the goal. It is handy to have some notifications in the history for some time (in case I need to re-check something) and disappear after that.

Q6: Offline building

I'd like to create an ebuild for this application so Gentoo users can use this package easily. But for this It kinda needs to be an "offline" instalation as the whole build process runs inside a sandbox with no access to the internet.

Is it possible to build this "offline"? In a way that I could download all the necessary packages beforehand?

I don't mind maintaining an ebuild for this as long as I would be using it ๐Ÿ™‚

Q7: deadd.css has to be in /etc

For some reason the (default) build of this app requires the deadd.css to be in /etc/xdg/deadd/ - and it ignores deadd.css in its configuration directory (~/.config/deadd) even though it clearly reads the deadd.yml in that directory.

For now I created a symlink from home to the /etc but it is not a "clean" solution. Did I do something wrong or is it a bug? Can I specify the CSS location in the config file so it does not have to be in the /etc?

Q8: Buttons in notification-center

I love the idea of these buttons - right now I have quite a log going on in my Polybar so I would love to move some things here.

However: is there any way to change state of a button? Either by some kind of callback or perhaps by returning a JSON when the script is called? Or (for example) to keep the button "pressed in" for as long as the script it launched is running etc?

This is such a good idea that I'd say it deserves more attention ๐Ÿ™‚

phuhl commented

Hi, glad you like it :)

Q1: Modifying urgency in script?

This should be supported as this is in master:

Make sure you are using the latest version by self compiling.

Q2: "default action" click

When "default action" is fired, the target window does not get activated for some reason. No worries, I could do that using wmctrl or something similar - if I had some way to hook myself into that "default action" and either completely override that or (better) allow me to extend what happens. Is this possible? Or can I somehow force deadd to activate window when clicking on notification?

Deadd only sends a message that the default action has been triggered to the sender. It's the senders job to focus the corresponding window. For me on Wayland this seems to work just fine with e.g. Slack notifications. But take a look at the configuration for the default action, maybe a different mouse button is configured to do the default action than you expect? That is something you can setup. Hooking into the default action is not really feasible though, I am afraid. That works over DBUS and is not scriptable through deadd. The only "option" is something I outlined here.

Q3: How do I get blurred background? sweat_smile

That is something that your compositor will have to do. If you are on X11 you could take a look at dual_kawase blur using https://github.com/yshui/picom.

Q4: monitor: primary?

Is there any possibility to achieve this? I can easily send any kind of signal when monitors change - either directly UNIX signal or some DBUS message.

Not with the current code. This could be archived if you could get deadd to reload and apply it's config file through an external signal as we do with CSS. PR is welcome ;)

Q5: Aging notifications in notify-center or deleting based on filter

I don't think there is a way with build-in tools this could be done. Only thing as of now is to not store them in the center at all using the transient flag. If you want to build something like this yourself, you could open a PR and we could discuss how such a feature could be implemented over there.

Q6: Offline building

The main challenge here would be to pre-fetch all stack dependencies. How is this done for other applications that have dependencies or that use stack? That could be a starting point to figuring this out.

Q7: deadd.css has to be in /etc

Just merged #221

Q8: Buttons in notification-center

Yes, that is build in. Take a look at the readme, specifcially this sectin:

Set the state of a user defined button (in this example the first button, which has id 0):

# turn highlighting on
notify-send.py a --hint boolean:deadd-notification-center:true \
               int:id:0 boolean:state:true type:string:buttons

# turn highlighting off
notify-send.py a --hint boolean:deadd-notification-center:true \
               int:id:0 boolean:state:false type:string:buttons

When you press a button it will stay in a "waiting" state until you explicitly set the state via one of the commands above.

Hope your questions could be answered. If you want to contribute, you are very welcome. Cheers

xoores commented

Hi, glad you like it :)

So far I love it ๐Ÿ™‚

Q1: Modifying urgency in script?

This should be supported as this is in master:

Make sure you are using the latest version by self compiling.

I'll try it our - I did compile it but since there are no tags or releases I just took the latest commit ID. I'll check whether there is a newer one. ๐Ÿ‘

Q2: "default action" click

When "default action" is fired, the target window does not get activated for some reason. No worries, I could do that using wmctrl or something similar - if I had some way to hook myself into that "default action" and either completely override that or (better) allow me to extend what happens. Is this possible? Or can I somehow force deadd to activate window when clicking on notification?

Deadd only sends a message that the default action has been triggered to the sender. It's the senders job to focus the corresponding window. For me on Wayland this seems to work just fine with e.g. Slack notifications. But take a look at the configuration for the default action, maybe a different mouse button is configured to do the default action than you expect? That is something you can setup. Hooking into the default action is not really feasible though, I am afraid. That works over DBUS and is not scriptable through deadd. The only "option" is something I outlined here.

I see, I thought that DEADD was the thing that did that action - I misunderstood the inner workings of the notifications. Thanks for the clarifications.

That is rather dirty trick, NGL ๐Ÿ˜… I will try & take a look if I could somehow hack in something like "fire script after dispatching action" or something like that.

Q3: How do I get blurred background? sweat_smile

That is something that your compositor will have to do. If you are on X11 you could take a look at dual_kawase blur using https://github.com/yshui/picom.

Aaah, I was bashing my head against the wall while trying to figure out the way to do that through the CSS! Of course, compositor can do that for "opacity". ๐Ÿ‘ For some reason it did not dawn on me.

Q4: monitor: primary?

Is there any possibility to achieve this? I can easily send any kind of signal when monitors change - either directly UNIX signal or some DBUS message.

Not with the current code. This could be archived if you could get deadd to reload and apply it's config file through an external signal as we do with CSS. PR is welcome ;)

Trust me, I would love to create a PR. I ended up opening "Haskell for C programmers" and ended there ๐Ÿ˜… I will try, of course, but it will take some time to understand Haskell as it is very different from anything I normally use.

Q5: Aging notifications in notify-center or deleting based on filter

I don't think there is a way with build-in tools this could be done. Only thing as of now is to not store them in the center at all using the transient flag. If you want to build something like this yourself, you could open a PR and we could discuss how such a feature could be implemented over there.

Transient flag is not really an solution - I want to keep them there, sometimes I just wanna re-check etc. But it clogs up the notification center quickly and deleting is either tedious or I have to delete all (including newer notifications that I would like to keep) ๐Ÿ˜

As I said earlier, I would love to open PR but... ๐Ÿ˜…

Q6: Offline building

The main challenge here would be to pre-fetch all stack dependencies. How is this done for other applications that have dependencies or that use stack? That could be a starting point to figuring this out.

There already is an ebuild (Gentoo package) for stack so I presume that one is sorted out. If stack is something like PIP, then it might me trickier. I honestly did not really get to the depths of the Haskell ecosystem - I just built the project and ran it from the bin directory directly.

Q7: deadd.css has to be in /etc

Just merged #221

๐Ÿ‘

Q8: Buttons in notification-center

Yes, that is build in. Take a look at the readme, specifcially this sectin:

Set the state of a user defined button (in this example the first button, which has id 0):

# turn highlighting on
notify-send.py a --hint boolean:deadd-notification-center:true \
               int:id:0 boolean:state:true type:string:buttons

# turn highlighting off
notify-send.py a --hint boolean:deadd-notification-center:true \
               int:id:0 boolean:state:false type:string:buttons

When you press a button it will stay in a "waiting" state until you explicitly set the state via one of the commands above.

Yup, that works - sorry, I could have describe it better: Is it possible to change the label like this? ๐Ÿค” Because with label I could easily do nerd fonts icons and even more ๐Ÿ™‚

Hope your questions could be answered. If you want to contribute, you are very welcome. Cheers

I will try to at least understand Haskell and then I will try to contribute with PR ๐Ÿ˜… Thanks for your time answering me!

phuhl commented

Trust me, I would love to create a PR. I ended up opening "Haskell for C programmers" and ended there sweat_smile I will try, of course, but it will take some time to understand Haskell as it is very different from anything I normally use.

Yeah, I like Haskell but if I would do it again I'd choose a different language for an open source project as it does severely limit the community size that can contribute easily... That being said, if you are interested in learning Haskell, I can recommend http://learnyouahaskell.com/chapters. If you need a finger point to where a certain change most likely would have to be done, let me now in a dedicated issue.

There already is an ebuild (Gentoo package) for stack so I presume that one is sorted out. If stack is something like PIP, then it might me trickier. I honestly did not really get to the depths of the Haskell ecosystem - I just built the project and ran it from the bin directory directly.

I think the PIP equivalent of Haskell would be Cabal (which is also used by deadd). Stack is more of a program that builds and manages a lock file in the hopes to produce reproducible builds.

If packaging the self-build project is too tedious, maybe a first step would be to package the binary package? I try to keep the bin up to date (but don't always succeed ๐Ÿ˜… )

up, that works - sorry, I could have describe it better: Is it possible to change the label like this? thinking Because with label I could easily do nerd fonts icons and even more slightly_smiling_face

I see, that would actually be a cool feature but it is not supported atm.