From 9e84997cbf9a310fa2cc06f9d37012dff94a5cb9 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 18 Jan 2025 20:54:25 +1300 Subject: [PATCH] Fix: ROGCC: don't crash out if no tray area available --- rog-control-center/src/tray.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/rog-control-center/src/tray.rs b/rog-control-center/src/tray.rs index 82f84643..ef26a5e7 100644 --- a/rog-control-center/src/tray.rs +++ b/rog-control-center/src/tray.rs @@ -24,7 +24,7 @@ struct Icons { rog_red: Icon, rog_green: Icon, rog_white: Icon, - gpu_integrated: Icon + gpu_integrated: Icon, } static ICONS: OnceLock = OnceLock::new(); @@ -48,14 +48,14 @@ fn read_icon(file: &Path) -> Icon { Icon { width: width as i32, height: height as i32, - data: img.into_raw() + data: img.into_raw(), } } struct AsusTray { current_title: String, current_icon: Icon, - proxy: ROGCCZbusProxyBlocking<'static> + proxy: ROGCCZbusProxyBlocking<'static>, } impl ksni::Tray for AsusTray { @@ -103,7 +103,7 @@ async fn set_tray_icon_and_tip( mode: GfxMode, power: GfxPower, tray: &mut Handle, - supergfx_active: bool + supergfx_active: bool, ) { if let Some(icons) = ICONS.get() { let icon = match power { @@ -159,21 +159,23 @@ pub fn init_tray(_supported_properties: Vec, config: Arc tray = t, + Err(e) => { log::error!( "Tray unable to be initialised: {e:?}. Do you have a system tray enabled?" - ) - }) - .unwrap(); + ); + return; + } + } info!("Tray started"); let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png")); @@ -185,7 +187,7 @@ pub fn init_tray(_supported_properties: Vec, config: Arc, config: Arc warn!("Couldn't get mode form supergfxd: {e:?}") + Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"), } info!("Started ROGTray");