Add optional swap bar next to the memory chart - #148
Open
glima wants to merge 1 commit into
Open
Conversation
The memory sensor only ever reported RAM: it refreshed with MemoryRefreshKind::nothing().with_ram() and sampled used/free memory, so swap usage was invisible in the panel. Add a "Show swap bar next to chart" toggle to the memory settings. When enabled, a narrow fill bar is drawn beside the memory chart showing the share of swap in use. The bar is half the size of a regular chart along the panel's flow direction and carries no text, since the memory chart next to it already shows the numbers. Its aspect ratio flips for vertical panels so it stays half-size in the direction items are stacked. The bar reuses the memory chart colors and is omitted entirely on systems without swap configured. Swap usage is also listed on the memory settings page when the toggle is on. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
Thank you for this PR. I'm thinking about how it looks. I'm wondering if it should be a full secondary chart, like temp is to CPU, the user can then choose between line/ring. @CarsonBurke thoughts? (In the future, not in the scope of this PR, it would be nice to be able to adjust chart width for line/bar charts and corner radius.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The memory sensor only reports RAM.
update()refreshed withMemoryRefreshKind::nothing().with_ram()and sampledused_memory()/free_memory(), so swap usage was not visible anywhere in the panel.Change
Adds a Show swap bar next to chart toggle to the memory settings (off by default). When enabled, a narrow fill bar is drawn beside the memory chart showing the share of swap in use:
Swap usage (
used / total GB) is also listed on the memory settings page while the toggle is on.Implementation notes
svg_graph::bar()is a new standalone renderer: rounded rect, bottom-up fill clipped to the corner radius, 1px frame.Memorynow also trackstotal_swap/swap_used, refreshed via.with_swap()alongside the existing RAM refresh, so no extra syscall pass is added.MemoryConfig::show_swapdefaults tofalse, so existing configs deserialize unchanged and the panel looks the same until the toggle is flipped.Translations
memory-show-swapandswap-explanationwere added to every locale file, since all locales in this repo currently carry the full key set. The non-English files get the English string as a placeholder for translators to replace.Testing
cargo buildandcargo clippyare clean (only pre-existing warnings). Verified on a machine with 68 GB of swap that the bar tracks usage, and checked the rendered SVG geometry standalone.