-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for "top" option to icon_position rule and hide_text rule #985
Conversation
Codecov Report
@@ Coverage Diff @@
## master #985 +/- ##
==========================================
+ Coverage 61.07% 61.09% +0.01%
==========================================
Files 44 45 +1
Lines 6836 6965 +129
==========================================
+ Hits 4175 4255 +80
- Misses 2661 2710 +49
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Since you're making a rule for that notification anyways, it may be better to add an option |
For clarity, do you imagine that I don't think this would be too hard to implement, although I personally prefer separating the feature and having the icons with text remain to the left or right. A compromise is potentially having this behavior captured in other extra option values like |
Yes, I was thinking something like that. Now that you show that, it occurs to me that the name
Maybe your use case wasn't entirely clear to me, but I thought you wanted all your volume notifications to have no text and other kinds of notifications with text need to have their icon on the left. If that is the case you can achieve this the following way:
[other]
icon_position = left
format = "%s\n%b"
[volume]
category="volume" # Match criteria
format = %b
icon_position = top
history_ignore = yes
fullscreen = show Rules are flexible enough that we don't need the added functionality of When you want to exactly mimic the behaviour of # didn't test this, but something like this might work
if [ -z $1]
then
shift 1
dunstify "empty-summary" $@
else
dunstify $@
fi
[other]
icon_position = left
format = "%s\n%b"
[empty]
summary = "empty-summary" # Match criteria
format = %b
icon_position = top
history_ignore = yes
fullscreen = show Does either solutions satisfy your use case? |
The config you shared and what you suggest with setting However I am not observing that i.e. my config is [global]
...
icon_position = left
...
[volume]
category="volume"
format = %b
alignment = center
history_ignore = yes
fullscreen = show
icon_position = right # <--- After reloading
yields: Do I have this configured incorrectly? Or am I misunderstanding anything? Or if that feature also needs to be implemented, I could potentially provide that as a commit here as well as the |
Great, let's do that then.
I didn't notice this before, but How to add/change a rule
An example of making something a rule can be found in edc6f5a |
Thanks for the guidance, I'll work towards making |
Nice! There's also this issue about more icon positions (#972), if you want to. |
Hey @m-bartlett have you had time to work on this? |
Not quite yet but it has been on my todo list, just putting some finishing touches on a different project |
@fwsmit I've got the core of these features implemented as far as my testing has proven. Still no pushes to this PR's branch yet as I want to run everything by you first before pushing Things needing your decision:
|
Yes that seems right.
The default max height could probably be a bit higher, but for these cases you can always set the max height higher with a rule.
Feel free to push unfinished code, you can always force-push later.
A new progress bar position setting best for another PR. But for now, the centering behaviour seems fine.
|
This feature cannot really be tested via automated testing, but it would be nice to easily test it in the future, so could you add a few tests to |
I was wrong on both of these, thanks for correcting. I it would be sensible to add this option, but I would call it As for the height, yes, this should definitely be made a rule, but I would prefer if you did that in another PR. The width cannot really be made a rule, since we are limited to a single notification window. Until that's fixed, I think it's best to stick to one width.
This documentation should definitely be improved. Also, I think that letting |
Okay, so for next actionables:
Is this correct? |
Yep, but I would do the |
Okay I will work on adding the |
@fwsmit I believe this is ready for your review, let me know if there's anything I should change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the changes look good. I'll take a closer look at the changes in draw.c later, but I don't expect to find any big problems. I've left a few comments here and there.
change icon_position rule defaults to enum off change tests to not read icon_position from settings
@fwsmit I believe I've made all requested changes, let me know what you think. I consolidated the icon_position tests into one batch of notifications, and then added iterating different padding configurations for the icon_position test. Here is each batch of icon_position tests rendered with the 4 different padding configurations now found in the icon_position test as rendered on my screen: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks perfect. The functional tests are also very nice.
EDIT: Features for other pull requests
A list of possible features recommended as other PRs in below conversation to keep track:
vertical_padding
setting, makepadding
act as a default for bothhorizontal_padding
andvertical_padding
if either is unsetAdd support for "top" option to icon_position rule and hide_text rule #985 (comment)
This adds a setting
center_icon_when_no_text
which centers the notification icon if the notification's text content is empty or only space characters.The motivation for this feature is to support simple graphical notifications using the progress bar for volume, brightness, or any other such notification where the icon is the notification.
I had attempted to achieve this sort of notification using symbolic fonts (I am using a nerd-font) however
dunst
seems to position font characters pixel-wise which causes font faces (despite being monospaced) to not be placed consistently. Notice in this animation of volume notifications using purely symbolic font characters that the "icon" moves slightly by a few pixels along the x-axis when comparing the "low-volume" symbol to the rest of the symbols:Admittedly the difference is slight but I believe having more freedom over the icons is a benefit, as the icon images can enforce being a consistent dimension.
Here is an animation of the same volume notification redone using my proposed code and centered icons instead of symbolic characters from fonts:
notice the base of the speaker icon does not move between each frame
So long as the body text is exclusively space characters, longer strings of spaces can be used to increase the width of the notification if the user prefers:
And as the setting name implies, if there is non-whitespace notification text content, the icon proceeds to respect the user's
icon_position
preference:For reference in my
dunstrc
I am using the following rule to achieve this notification:and this sample
notify-send
command to create an "empty" notification body with an icon:I tried searching through this repository but I didn't find any code style guidelines or contribution guidelines. If those exist and I've overlooked them, please feel free to refer me to them. Otherwise please let me know if there is anything I should change about this PR to improve consistency.