mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix: ROGCC: don't crash out if no tray area available
This commit is contained in:
@@ -24,7 +24,7 @@ struct Icons {
|
|||||||
rog_red: Icon,
|
rog_red: Icon,
|
||||||
rog_green: Icon,
|
rog_green: Icon,
|
||||||
rog_white: Icon,
|
rog_white: Icon,
|
||||||
gpu_integrated: Icon
|
gpu_integrated: Icon,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ICONS: OnceLock<Icons> = OnceLock::new();
|
static ICONS: OnceLock<Icons> = OnceLock::new();
|
||||||
@@ -48,14 +48,14 @@ fn read_icon(file: &Path) -> Icon {
|
|||||||
Icon {
|
Icon {
|
||||||
width: width as i32,
|
width: width as i32,
|
||||||
height: height as i32,
|
height: height as i32,
|
||||||
data: img.into_raw()
|
data: img.into_raw(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AsusTray {
|
struct AsusTray {
|
||||||
current_title: String,
|
current_title: String,
|
||||||
current_icon: Icon,
|
current_icon: Icon,
|
||||||
proxy: ROGCCZbusProxyBlocking<'static>
|
proxy: ROGCCZbusProxyBlocking<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ksni::Tray for AsusTray {
|
impl ksni::Tray for AsusTray {
|
||||||
@@ -103,7 +103,7 @@ async fn set_tray_icon_and_tip(
|
|||||||
mode: GfxMode,
|
mode: GfxMode,
|
||||||
power: GfxPower,
|
power: GfxPower,
|
||||||
tray: &mut Handle<AsusTray>,
|
tray: &mut Handle<AsusTray>,
|
||||||
supergfx_active: bool
|
supergfx_active: bool,
|
||||||
) {
|
) {
|
||||||
if let Some(icons) = ICONS.get() {
|
if let Some(icons) = ICONS.get() {
|
||||||
let icon = match power {
|
let icon = match power {
|
||||||
@@ -159,21 +159,23 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
|
|||||||
|
|
||||||
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
|
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
|
||||||
|
|
||||||
let tray = AsusTray {
|
let tray_init = AsusTray {
|
||||||
current_title: TRAY_LABEL.to_string(),
|
current_title: TRAY_LABEL.to_string(),
|
||||||
current_icon: rog_red.clone(),
|
current_icon: rog_red.clone(),
|
||||||
proxy
|
proxy,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut tray = tray
|
// TODO: return an error to the UI
|
||||||
.spawn_without_dbus_name()
|
let mut tray;
|
||||||
.await
|
match tray_init.spawn_without_dbus_name().await {
|
||||||
.map_err(|e| {
|
Ok(t) => tray = t,
|
||||||
|
Err(e) => {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Tray unable to be initialised: {e:?}. Do you have a system tray enabled?"
|
"Tray unable to be initialised: {e:?}. Do you have a system tray enabled?"
|
||||||
)
|
);
|
||||||
})
|
return;
|
||||||
.unwrap();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
info!("Tray started");
|
info!("Tray started");
|
||||||
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
|
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
|
||||||
@@ -185,7 +187,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
|
|||||||
rog_red: rog_red.clone(),
|
rog_red: rog_red.clone(),
|
||||||
rog_green,
|
rog_green,
|
||||||
rog_white,
|
rog_white,
|
||||||
gpu_integrated
|
gpu_integrated,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut has_supergfx = false;
|
let mut has_supergfx = false;
|
||||||
@@ -206,7 +208,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}")
|
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Started ROGTray");
|
info!("Started ROGTray");
|
||||||
|
|||||||
Reference in New Issue
Block a user