fix(ci): appease clippy and fmt

This commit is contained in:
mihai2mn
2026-01-29 19:22:36 +01:00
parent 3437bc0eff
commit 03be872220
7 changed files with 102 additions and 52 deletions

View File

@@ -19,6 +19,7 @@ const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/";
struct Icons {
#[allow(dead_code)]
rog_red: Icon,
rog_blue: Icon,
}
static ICONS: OnceLock<Icons> = OnceLock::new();
@@ -76,6 +77,7 @@ pub struct TrayStats {
pub gpu_fan: String,
pub power_w: String,
pub power_profile: String,
pub is_dgpu_active: bool,
}
impl ksni::Tray for AsusTray {
@@ -151,6 +153,7 @@ pub fn init_tray(
let proxy = ROGCCZbusProxyBlocking::new(&user_con).unwrap();
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
let tray_init = AsusTray {
current_title: TRAY_LABEL.to_string(),
@@ -180,6 +183,7 @@ pub fn init_tray(
info!("Tray started");
ICONS.get_or_init(|| Icons {
rog_red: rog_red.clone(),
rog_blue: rog_blue.clone(),
});
info!("Started ROGTray");
@@ -197,6 +201,15 @@ pub fn init_tray(
t.gpu_fan = stats.gpu_fan;
t.power_w = stats.power_w;
t.power_profile = stats.power_profile;
// Update icon based on dGPU state
if let Some(icons) = ICONS.get() {
t.current_icon = if stats.is_dgpu_active {
icons.rog_red.clone()
} else {
icons.rog_blue.clone()
};
}
}).await;
});
}

View File

@@ -57,6 +57,9 @@ pub fn setup_status(
}
let ui_weak_loop = ui_weak.clone(); // Clone ui_weak for this iteration
// Check dGPU state
let is_dgpu_active = get_dgpu_state();
// Send to Tray
let _ = stats_tx.send(TrayStats {
cpu_temp: format!("{}", cpu_temp),
@@ -65,6 +68,7 @@ pub fn setup_status(
gpu_fan: format!("{}", gpu_fan),
power_w: format!("{:.1}", power_w),
power_profile: profile_str,
is_dgpu_active,
});
let _ = slint::invoke_from_event_loop(move || {
@@ -148,3 +152,23 @@ async fn read_power() -> i32 {
}
p
}
// Simple check: if /sys/class/drm/card1 exists, dGPU is likely active/available.
// Integrated is always card0.
fn get_dgpu_state() -> bool {
if let Ok(entries) = std::fs::read_dir("/sys/class/drm") {
let mut card_count = 0;
for entry in entries.flatten() {
if let Ok(name) = entry.file_name().into_string() {
if name.starts_with("card")
&& name.chars().nth(4).is_some_and(|c| c.is_ascii_digit())
&& !name.contains('-')
{
card_count += 1;
}
}
}
return card_count > 1;
}
true // Fallback to true (Red) if check fails
}