From 73808dfacccfcd1926a05a92924dfa6f2864aba7 Mon Sep 17 00:00:00 2001 From: Grzegorz Szymaszek Date: Tue, 18 Nov 2025 11:50:04 +0100 Subject: [PATCH] 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 --- src/modules/memory/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/memory/common.cpp b/src/modules/memory/common.cpp index 18600cd2..a83f6526 100644 --- a/src/modules/memory/common.cpp +++ b/src/modules/memory/common.cpp @@ -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);