Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added swap memory support for bar-used#1325

Merged
patrick96 merged 3 commits into
polybar:masterfrom
roel0:master
Sep 14, 2018
Merged

Added swap memory support for bar-used#1325
patrick96 merged 3 commits into
polybar:masterfrom
roel0:master

Conversation

@roel0

@roel0 roel0 commented Jul 20, 2018

Copy link
Copy Markdown
Contributor

bar-used currently only supports internal memory, added support to have a bar for swap

Comment thread src/modules/memory.cpp Outdated
bool memory_module::build(builder* builder, const string& tag) const {
if (tag == TAG_BAR_USED) {
builder->node(m_bar_memused->output(m_perc_memused));
string m_type = m_conf.get<decltype(m_type)>(name(), "bar-used-type", "RAM");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This retrieves the variable from the config every single time the module is built, which isn't very efficient. It would be better if m_type was set from the initialization and only checked in build(), or create a new tag like TAG_BAR_USED_SWAP altogether.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@maxdevjs

Copy link
Copy Markdown

Will this be merged?

@NBonaparte

NBonaparte commented Aug 27, 2018

Copy link
Copy Markdown
Member

The only issue with this method is that RAM and swap memory can't both be displayed in the same module. I'm not sure how many people would have this use case though. @patrick96 do you think having both types available would be better?

@maxdevjs

Copy link
Copy Markdown

screenshot-2018-08-28_15 08 17_-03-03 00_1535479697

sigh...

@roel0

roel0 commented Aug 29, 2018

Copy link
Copy Markdown
Contributor Author

Image of swap-bar

Example config:

[module/memory]
type = internal/memory
interval = 0.2
format = <label> <bar-used>

label = RAM
label-font = 3
label-foreground = #99

bar-used-width = 15
bar-used-gradient = true
bar-used-foreground-0 = #449f3d
bar-used-foreground-1 = #2f8419
bar-used-foreground-2 = #f5a70a
bar-used-foreground-3 = #ed5456
bar-used-indicator = █
bar-used-indicator-font = 5
bar-used-indicator-foreground = #fff
bar-used-fill = █
bar-used-fill-font = 5
bar-used-empty = █
bar-used-empty-font = 5
bar-used-empty-foreground = #44

[module/swap]
type = internal/memory
interval = 0.2
format = <label> <bar-used>

label = SWAP
label-font = 3
label-foreground = #99

bar-used-type = SWAP
bar-used-width = 15
bar-used-gradient = true
bar-used-foreground-0 = #449f3d
bar-used-foreground-1 = #2f8419
bar-used-foreground-2 = #f5a70a
bar-used-foreground-3 = #ed5456
bar-used-indicator = █
bar-used-indicator-font = 5
bar-used-indicator-foreground = #fff
bar-used-fill = █
bar-used-fill-font = 5
bar-used-empty = █
bar-used-empty-font = 5
bar-used-empty-foreground = #44

@maxdevjs

Copy link
Copy Markdown

Thank you @roel0 , currently works only with your fork, right?

@roel0

roel0 commented Aug 30, 2018

Copy link
Copy Markdown
Contributor Author

@maxdevjs correct

@patrick96

Copy link
Copy Markdown
Member

Why not use <bar-swap-used> and <bar-swap-free> etc.? This would be in the same vein as the swap tokens (%percentage_swap_used% etc.) we added. I think this would be cleaner codewise anyways, even if it uses some more code than the current approach. And people could use both in the same module.

@roel0

roel0 commented Sep 4, 2018

Copy link
Copy Markdown
Contributor Author

@NBonaparte @patrick96 done

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #1325 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1325      +/-   ##
=========================================
- Coverage    5.84%   5.83%   -0.02%     
=========================================
  Files         161     161              
  Lines        8918    8935      +17     
=========================================
  Hits          521     521              
- Misses       8397    8414      +17
Flag Coverage Δ
#unittests 5.83% <0%> (-0.02%) ⬇️
Impacted Files Coverage Δ
include/modules/memory.hpp 0% <ø> (ø) ⬆️
src/modules/memory.cpp 1.11% <0%> (-0.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2268136...ef38534. Read the comment docs.

@patrick96

Copy link
Copy Markdown
Member

Much better! Code looks good, will run it with some configurations in a few days just to make sure.

@patrick96 patrick96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found no problems

@patrick96 patrick96 merged commit 11d66ee into polybar:master Sep 14, 2018
@patrick96

Copy link
Copy Markdown
Member

Thanks for contributing!

patrick96 pushed a commit to patrick96/polybar that referenced this pull request Nov 17, 2018
Now all the tokens in the memory module also have ramp and bar counterparts.

These can be used exactly the same as `bar-used` and `ramp-used`, they are named `<bar-swap-used>`, `<bar-swap-free>`, `<ramp-swap-used>`, and `<ramp-swap-free>`
patrick96 added a commit that referenced this pull request Dec 23, 2018
### Breaking Changes:
None

### Changelog

**New Config Options**
The following config options were added

In the `[settings]` section:
* `pseudo-transparency`

In `internal/cpu`:
* `ramp-coreload-spacing`, spacing between elements in `<ramp-coreload>` elements
* `%percentage-sum%` in `label`. Shows sum of all percentages

In `custom/script`:
* `double-click-left`
* `double-click-middle`
* `double-click-right`

In `internal/pulseaudio`:
* `interval`, volume increase and decrease steps in percentage points

In `internal/memory`:
* `bar-swap-used`
* `bar-swap-free`
* `ramp-swap-used`
* `ramp-swap-free`

**Deprecations**
* `tray-transparent` in the bar section is no longer used. The tray now always uses pseudo-transparency

**Features**
* volume: adjustable volume steps (#1364), see #1361
* memory: Add progress bars and ramps for swap (#1325)
* render: pseudo-transparency (always used in the tray)  (#595)
* cpu: 
    * Configurable spacing in between coreloads (#1472), see #1389
    * Non-normalized cpu load (#1517), see #1516
* script: Double click actions (#1442)
* net: Support for bridge interfaces (#1528), see #1522
* token: zero pad tokens when min-width value starts with a `0` (#1341), see #1332

**Fixes**
* config: Use font patterns detected on system in sample config (#1350)
* net: Disconnected module when SSID is only an emoji (#1371), see #1367
* tray: Tray overlapping with bar (#1392), see #591
* build: Several build errors (#1395, #1454, #1470, polybar/xpp#12, #1493), see #1447, #1469, #750, #1492
* mpd: format-online-prefix not working (#1402), see #1399
* font: Crash for some font-patterns (#1451), see #1435
* script: 
    * Only `%counter%` or `%pid%` token usable, never both (#1456)
    * click actions with colons in them (#1457), see #984
* renderer: Bar locks up when xorg composite extension is disabled (#1430), see #1425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants