From b172bef4972102d0aca0b410891c4f2840fecae5 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sun, 24 Dec 2023 23:26:52 +0100 Subject: [PATCH] Add percentage labels to volume and brightness indicators --- src/server/osd_window.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server/osd_window.rs b/src/server/osd_window.rs index 0c1cd6e..0ae8b8a 100644 --- a/src/server/osd_window.rs +++ b/src/server/osd_window.rs @@ -99,11 +99,14 @@ impl SwayosdWindow { let icon = self.build_icon_widget(icon_name); let progress = self.build_progress_widget(volume / max_volume); + let label = self.build_text_widget(None); + label.set_text(&format!("{}%", volume)); progress.set_sensitive(!device.mute); self.container.add(&icon); self.container.add(&progress); + self.container.add(&label); self.run_timeout(); } @@ -117,9 +120,12 @@ impl SwayosdWindow { let brightness = brightness_backend.get_current() as f64; let max = brightness_backend.get_max() as f64; let progress = self.build_progress_widget(brightness / max); + let label = self.build_text_widget(None); + label.set_text(&format!("{}%", brightness / max * 100.)); self.container.add(&icon); self.container.add(&progress); + self.container.add(&label); self.run_timeout(); }