diff --git a/src/battery_tray.rs b/src/battery_tray.rs index 92c6dc1..59dd802 100644 --- a/src/battery_tray.rs +++ b/src/battery_tray.rs @@ -1,4 +1,4 @@ -use ksni::{Tray, MenuItem, menu::{StandardItem}}; +use ksni::{Tray, MenuItem, menu::{StandardItem}, ToolTip}; #[derive(Debug)] pub struct BatteryTray { @@ -14,7 +14,7 @@ impl BatteryTray { } } - pub fn refresh(&mut self, battery_level: u8, charging: bool) { + pub fn update(&mut self, battery_level: u8, charging: bool) { self.battery_level = battery_level; self.charging = charging; } @@ -24,13 +24,6 @@ impl Tray for BatteryTray { fn icon_name(&self) -> String { "headset".into() } - fn title(&self) -> String { - if self.charging { - format!("Battery level: {}%\nCharging", self.battery_level).to_string() - } else { - format!("Battery level: {}%\nNot charging", self.battery_level).to_string() - } - } fn menu(&self) -> Vec> { vec![ StandardItem { @@ -42,4 +35,17 @@ impl Tray for BatteryTray { .into(), ] } + fn tool_tip(&self) -> ToolTip { + let description = if self.charging { + format!("Battery level: {}%\nCharging", self.battery_level) + } else { + format!("Battery level: {}%\nNot charging", self.battery_level) + }; + ToolTip { + title: "HyperX Cloud II".to_string(), + description: description, + icon_name: "".into(), + icon_pixmap: Vec::new(), + } + } } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f773492..3d7eea9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ fn main() { } }; handle.update(|tray: &mut BatteryTray| { - tray.refresh(battery_level, charging); + tray.update(battery_level, charging); }); } }