-
-
Notifications
You must be signed in to change notification settings - Fork 722
Warn state for CPU, Memory, Filesystem and Battery modules #2199
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
Conversation
…n on other modules
Codecov Report
@@ Coverage Diff @@
## master #2199 +/- ##
=========================================
+ Coverage 7.25% 7.44% +0.18%
=========================================
Files 155 156 +1
Lines 10594 10678 +84
=========================================
+ Hits 769 795 +26
- Misses 9825 9883 +58
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
This would also provide the feature requested by #1871. |
patrick96
left a comment
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.
Code looks good. Thanks!
I do have some concerns about how this changes existing behavior. Because the thresholds for the new warn states would change how existing configs would display once we are in the warn state.
For example right now, if your CPU is over 80%, it would display whatever is in format and the labels and ramps used there. If we used the same config in this PR, it would now display just the total load percentage.
We generally want people to be able to update without it changing how their bar looks like (at least not in a substantial way). So we can't really have these warning states enabled by default, or we must make sure that they behave exactly the same as the non-warn states by default.
I can think of two solutions to this:
- Set the threshold to something that can never be reached. In the battery module, we would set it to anything smaller than
0. For memory, cpu, and fs, we would have to set it to something larger than 100. It has to be strictly smaller than 0 or larger than 100 because both 0% battery and 100% cpu, ram, or storage can be reached and the warn states are activated at those values. - Have an extra boolean flag in each module that is set to true only if the new warn formats were defined in the module config. Only use the warn states if the flag is true.
None of these solutions are pretty unfortunately. Can you think of another way of ensuring that the module doesn't suddenly display something completely different in the warn states?
And just to note, because it also changes module behavior: This PR adds the same changes to the behavior of the first and last ramp elements for the battery, fs, cpu, and memory module as #2197 added for the temperature module.
While this can be considered a breaking change, it just changes the ranges that ramp elements are responsible for a bit. So, the same as for the temperature module, this is probably fine, we just need to make sure to mention it in the changelogs.
|
We can create a new fallback tag. The default value for FORMAT_WARN will be this tag, and when |
Hide the effect of warn states when unused
|
Another idea on my mind is that I can write |
I think that is a good idea. 👍 |
|
I applied it on all relevant modules. |
patrick96
left a comment
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.
Looks good. Just some minor style changes.
Please also rebase and resolve the merge conflicts.
|
Ok, is it good? |
patrick96
left a comment
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.
Functionality wise, everything works now. There was a small bug in the fs module, but I added a comment for that.
The build currently breaks, I have added comments for all the places that need to be fixed.
There are also some places where you use tabs instead of spaces, I have also added comments for that.
After these changes, I think we can merge this.
|
I think I finally got the indents right. |
patrick96
left a comment
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.
Everything looks good now 🎉
Thanks a lot for all your efforts! 😃
This was a backwards-incompatible change introduced in polybar#2199, however it was caused because `module_formatter.has` throws an exception when the format doesn't exist instead of just returning false. Fixes polybar#2262 Ref polybar#2199
This is an item in the todo list from the Module State Machines project, and was requested in #570 and #956. The idea is that the modules that monitor system resources will display different labels and animations when that resource requires attention (battery low, high temperature, high cpu/memory usage).
The warn state would work like that of the temperature module. The condition to activate the warn states are as follow:
warn-percentagewarn-percentagewarn-percentagelow-atRelease Notes:
This adds
format-warnandlabel-warnto the memory, cpu and fs module andformat-lowandlabel-lowto the battery module.It also slightly changes how the ramps in those modules behave. The ramps are bounded by these warn thresholds and, the same as the temperature module, the first and last ramp elements are responsible for everything
<=the lower bound or>=the upper bound. Before, the ramp generally went from 0 to 100 and the first and last ramp elements covered the same share inside the range as all other ramp elements as well as everything outside the range.These two changes in behavior partially cancel each other out, so the change in behavior in existing configs will be barely noticeable.
It also adds the following:
animation-low,low-at = 10warn-percentage = 80warn-percentage = 90warn-percentage = 90/Release Notes
Example configuration:
Closes #570
Closes #956