git.lucas.co / cce-status-interface
status bar
git clone https://git.lucas.co/cce-status-interface.git

commit32b481cc41af1e5e99710cecfff6eb9e6fb4a601
parent293c76dee0
authorLucas Galante <[email protected]>
date2026-08-24 14:52
feat: whole-number cpu and memory readouts

Cpu {:.0}% and Mem {:.0}/{:.0}G; the width-stability templates follow
("Cpu 100%" — the widest the rounded value gets — and the same
pinned-total derivation for Mem).

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/modules.rs | 14 +++++++-------
 src/stats.rs   |  8 ++++----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/modules.rs b/src/modules.rs
index 55bc235..2bb9e3f 100644
--- a/src/modules.rs
+++ b/src/modules.rs
@@ -57,7 +57,7 @@ pub trait StatusModule {
 }
 
 /// A stat module's width from the WIDER of its live text and a
-/// widest-plausible template ("Cpu 99.9%"), plus padding. Sizing to the live
+/// widest-plausible template ("Cpu 100%"), plus padding. Sizing to the live
 /// text alone made the surface resize whenever the value crossed a digit
 /// boundary ("Cpu 9.9%" ↔ "Cpu 10.2%"), which re-arranged the whole status
 /// strip and — through the compositor's configure echo — ping-ponged the
@@ -437,11 +437,11 @@ impl StatusModule for MemoryModule {
         padding: f32,
     ) -> f32 {
         let text = if let Some(ref s) = stats {
-            if !s.memory.is_empty() { &s.memory } else { "Mem 0.0/0.0G" }
+            if !s.memory.is_empty() { &s.memory } else { "Mem 0/0G" }
         } else {
-            "Mem 0.0/0.0G"
+            "Mem 0/0G"
         };
-        // "Mem 8.2/62.4G" → "Mem 62.4/62.4G": used pinned to the total, the
+        // "Mem 17/62G" → "Mem 62/62G": used pinned to the total, the
         // widest this machine's readout gets.
         let template = text
             .rsplit('/')
@@ -497,11 +497,11 @@ impl StatusModule for CpuModule {
         padding: f32,
     ) -> f32 {
         let text = if let Some(ref s) = stats {
-            if !s.cpu.is_empty() { &s.cpu } else { "Cpu 0.0%" }
+            if !s.cpu.is_empty() { &s.cpu } else { "Cpu 0%" }
         } else {
-            "Cpu 0.0%"
+            "Cpu 0%"
         };
-        stable_text_width(font_system, text, "Cpu 99.9%", font_size, font_family, padding)
+        stable_text_width(font_system, text, "Cpu 100%", font_size, font_family, padding)
     }
 
     fn render(
diff --git a/src/stats.rs b/src/stats.rs
index 725a801..1c96f56 100644
--- a/src/stats.rs
+++ b/src/stats.rs
@@ -40,7 +40,7 @@ pub(crate) fn read_memory_usage() -> Option<String> {
     }
     if total > 0.0 {
         let used = total - free - buffers - cached;
-        Some(format!("Mem {:.1}/{:.1}G", used, total))
+        Some(format!("Mem {:.0}/{:.0}G", used, total))
     } else {
         None
     }
@@ -151,7 +151,7 @@ pub(crate) fn get_initial_stats() -> SystemStats {
     SystemStats {
         clock,
         memory,
-        cpu: "Cpu 0.0%".to_string(),
+        cpu: "Cpu 0%".to_string(),
         battery: battery_str,
         battery_capacity,
         battery_charging,
@@ -175,9 +175,9 @@ pub(crate) async fn spawn_system_stats(sender: calloop::channel::Sender<CustomEv
             last_cpu = current_cpu;
             if total_diff > 0 {
                 let usage = 100.0 - (idle_diff as f32 * 100.0 / total_diff as f32);
-                format!("Cpu {:.1}%", usage)
+                format!("Cpu {:.0}%", usage)
             } else {
-                "Cpu 0.0%".to_string()
+                "Cpu 0%".to_string()
             }
         } else {
             "Cpu N/A".to_string()