xnotify icon indicating copy to clipboard operation
xnotify copied to clipboard

Some feature requests

Open SimonTeixidor opened this issue 4 years ago • 4 comments

Hi! Cool project! I have a couple of features that I would like to have, to make this program work better for my use case. I'd be happy to hack on these features myself, but I'd like to discuss it here first to see if you are interested in pull requests.

Close notification using keyboard binding

I'd like a mode which grabs keyboard focus, and displays a notification allows me to close using ESC (or whatever key binding). This would be useful for warning messages, as it would be basically impossible to miss.

Multi line notifications

From my understanding, we can only display two lines? I'd like to be able to display multiple lines. I guess this would require us to change the delimiter between two notifications, or at least an option to do so. The delimiter can be ASCII record separator, or null byte, or whatever.

Vertical mode

Currently, notifications are in horizontal mode, with an image to the left and the text to the right. I propose another mode where the image is on top and the text below it.

Furthermore, it seems to me like -s -1 will cause notifications to never time out, but this behaviour is not specified in the manual. If this is indeed true I can make a PR.

SimonTeixidor avatar Feb 19 '21 20:02 SimonTeixidor

Close notification using keyboard binding

You can send a SIGUSR1 signal to xnotify to make it close notifications. Here is the snipped from my sxhkd configuration file for closing notifications:

mod1 + Escape
	pkill -SIGUSR1 xnotify

Multi line notifications

You can delimit lines by a tab.

printf 'This is a line\tThis is other line\tThis is yet another line\tAnd another one\n' > $XNOTIFY_FIFO

Vertical mode

This is something that I could add, but it will not be easy, as most variables and calcuations rely on the horizontal nature of the notifications. So it may require a lot of change and recalculations.

Furthermore, it seems to me like -s -1 will cause notifications to never time out

In fact, any non-numeric string (or any string that does not begin with a number, such as -1 or foo3) will be interpreted as zero. That's because I use strtoul(3) to convert from string to number.

phillbush avatar Feb 19 '21 22:02 phillbush

You can send a SIGUSR1 signal to xnotify to make it close notifications. Here is the snipped from my sxhkd configuration file for closing notifications:

Yes, I thought about that as well, but it doesn't really have the same effect. Ideally I'd like the system to be "locked up" until I press ESC. I just tried locally, and this can be achieved pretty easily with XGrabKeyboard.

You can delimit lines by a tab.

Oh, was that fixed recently on master? I tried it on the latest release and only the first tab worked properly. A local build works fine. What is the reason behind MAXLINES, though? Can we make it configurable?

This is something that I could add, but it will not be easy, as most variables and calcuations rely on the horizontal nature of the notifications. So it may require a lot of change and recalculations.

Would be a super cool feature!

In fact, any non-numeric string (or any string that does not begin with a number, such as -1 or foo3) will be interpreted as zero. That's because I use strtoul(3) to convert from string to number.

Oh, so a 0 means "no timeout" then? Then maybe we can add that to the manual :)

SimonTeixidor avatar Feb 19 '21 23:02 SimonTeixidor

Yes, I thought about that as well, but it doesn't really have the same effect. Ideally I'd like the system to be "locked up" until I press ESC. I just tried locally, and this can be achieved pretty easily with XGrabKeyboard.

I do not want to handle keybindings with xnotify, for it is out of the scope of the utility.
But if you want to send a pull request for it, I can list it as a patch for xnotify in the README.

What is the reason behind MAXLINES, though? Can we make it configurable?

The reason behind MAXLINES is to limit the height of notifications, so we don't have long notifications that span off the screen. We can make it configurable, though, with a command line option.

Oh, so a 0 means "no timeout" then? Then maybe we can add that to the manual :)

Added to the manual.

phillbush avatar Feb 19 '21 23:02 phillbush

The reason behind MAXLINES is to limit the height of notifications, so we don't have long notifications that span off the screen. We can make it configurable, though, with a command line option.

Right, I opened a PR for that. But actually, you have max_height as well, which also stops the notifications from spanning off screen.

SimonTeixidor avatar Feb 20 '21 11:02 SimonTeixidor