modules: memory: fix fully utilized swap percentage calculation

Do calculate used swap percentage even if swapfree is 0, otherwise
reported used_swap_percentage would be 0, even though it should be 100.

Signed-off-by: Grzegorz Szymaszek <gszymaszek@short.pl>
This commit is contained in:
Grzegorz Szymaszek 2025-11-18 11:50:04 +01:00
parent 161367d961
commit 73808dfacc
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@ auto waybar::modules::Memory::update() -> void {
float total_swap_gigabytes = 0.01 * round(swaptotal / 10485.76);
int used_ram_percentage = 100 * (memtotal - memfree) / memtotal;
int used_swap_percentage = 0;
if (swaptotal && swapfree) {
if (swaptotal) {
used_swap_percentage = 100 * (swaptotal - swapfree) / swaptotal;
}
float used_ram_gigabytes = 0.01 * round((memtotal - memfree) / 10485.76);