From 792fae3ed75dca8a3cb81ef6505e2b920bd5cd30 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Fri, 24 May 2024 12:58:37 +1200 Subject: [PATCH] Enable tray and notifs without supergfx --- CHANGELOG.md | 1 + rog-control-center/src/notify.rs | 118 ++++++++++-------- rog-control-center/src/tray.rs | 61 ++++++--- .../translations/en/rog-control-center.po | 98 +++++++-------- rog-control-center/ui/main_window.slint | 2 +- rog-control-center/ui/pages/system.slint | 14 +-- 6 files changed, 166 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18df1aaa..2b4515ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Don't panic if -ENODEV on fan_curve enable - Adjust the G513Q support to match what is on the asus website. - Adjust init sequence of anime to prevent accidental use of Slash as Anime +- Enable notifs and tray icon without supergfx ## [v6.0.9] diff --git a/rog-control-center/src/notify.rs b/rog-control-center/src/notify.rs index f194b459..2740317d 100644 --- a/rog-control-center/src/notify.rs +++ b/rog-control-center/src/notify.rs @@ -51,6 +51,10 @@ fn start_dpu_status_mon(config: Arc>) { let mut found_dgpu = false; // just for logging for dev in dev { if dev.is_dgpu() { + info!( + "Found dGPU: {}, starting status notifications", + dev.pci_id() + ); let enabled_notifications_copy = config.clone(); // Plain old thread is perfectly fine since most of this is potentially blocking std::thread::spawn(move || { @@ -138,6 +142,13 @@ pub fn start_notifications( } }); + let enabled_notifications_copy = config.clone(); + let no_supergfx = move |e: &zbus::Error| { + error!("zbus signal: receive_notify_gfx_status: {e}"); + warn!("Attempting to start plain dgpu status monitor"); + start_dpu_status_mon(enabled_notifications_copy.clone()); + }; + // GPU MUX Mode notif let enabled_notifications_copy = config.clone(); tokio::spawn(async move { @@ -176,68 +187,65 @@ pub fn start_notifications( let enabled_notifications_copy = config.clone(); // GPU Mode change/action notif tokio::spawn(async move { - if let Err(e) = { - let conn = zbus::Connection::system().await?; - let proxy = SuperProxy::builder(&conn).build().await?; - let _ = proxy.mode().await?; + let conn = zbus::Connection::system().await.map_err(|e| { + no_supergfx(&e); + e + })?; + let proxy = SuperProxy::builder(&conn).build().await.map_err(|e| { + no_supergfx(&e); + e + })?; + let _ = proxy.mode().await.map_err(|e| { + no_supergfx(&e); + e + })?; - let proxy_copy = proxy.clone(); - if let Ok(mut p) = proxy.receive_notify_action().await { - tokio::spawn(async move { - info!("Started zbus signal thread: receive_notify_action"); - while let Some(e) = p.next().await { - if let Ok(out) = e.args() { - let action = out.action(); - let mode = convert_gfx_mode(proxy.mode().await.unwrap_or_default()); - match action { - supergfxctl::actions::UserActionRequired::Reboot => { - do_mux_notification( - "Graphics mode change requires reboot", - &mode, - ) - } - _ => do_gfx_action_notif(<&str>::from(action), *action, mode), - } - .map_err(|e| { - error!("zbus signal: do_gfx_action_notif: {e}"); - e - }) - .ok(); + let proxy_copy = proxy.clone(); + let mut p = proxy.receive_notify_action().await?; + tokio::spawn(async move { + info!("Started zbus signal thread: receive_notify_action"); + while let Some(e) = p.next().await { + if let Ok(out) = e.args() { + let action = out.action(); + let mode = convert_gfx_mode(proxy.mode().await.unwrap_or_default()); + match action { + supergfxctl::actions::UserActionRequired::Reboot => { + do_mux_notification("Graphics mode change requires reboot", &mode) } + _ => do_gfx_action_notif(<&str>::from(action), *action, mode), } - }); - }; + .map_err(|e| { + error!("zbus signal: do_gfx_action_notif: {e}"); + e + }) + .ok(); + } + } + }); - if let Ok(mut p) = proxy_copy.receive_notify_gfx_status().await { - tokio::spawn(async move { - info!("Started zbus signal thread: receive_notify_gfx_status"); - let mut last_status = GfxPower::Unknown; - while let Some(e) = p.next().await { - if let Ok(out) = e.args() { - let status = out.status; - if status != GfxPower::Unknown && status != last_status { - if let Ok(config) = enabled_notifications_copy.lock() { - if !config.notifications.receive_notify_gfx_status - || !config.notifications.enabled - { - continue; - } - } - // Required check because status cycles through - // active/unknown/suspended - do_gpu_status_notif("dGPU status changed:", &status).ok(); + let mut p = proxy_copy.receive_notify_gfx_status().await?; + tokio::spawn(async move { + info!("Started zbus signal thread: receive_notify_gfx_status"); + let mut last_status = GfxPower::Unknown; + while let Some(e) = p.next().await { + if let Ok(out) = e.args() { + let status = out.status; + if status != GfxPower::Unknown && status != last_status { + if let Ok(config) = enabled_notifications_copy.lock() { + if !config.notifications.receive_notify_gfx_status + || !config.notifications.enabled + { + continue; } - last_status = status; } + // Required check because status cycles through + // active/unknown/suspended + do_gpu_status_notif("dGPU status changed:", &status).ok(); } - }); - }; - Ok::<(), zbus::Error>(()) - } { - error!("zbus signal: receive_notify_gfx_status: {e}"); - info!("Attempting to start plain dgpu status monitor"); - start_dpu_status_mon(config.clone()); - } + last_status = status; + } + } + }); Ok::<(), zbus::Error>(()) }); diff --git a/rog-control-center/src/tray.rs b/rog-control-center/src/tray.rs index 7db94797..84132982 100644 --- a/rog-control-center/src/tray.rs +++ b/rog-control-center/src/tray.rs @@ -12,7 +12,7 @@ use std::time::Duration; use betrayer::{Icon, Menu, MenuItem, TrayEvent, TrayIcon, TrayIconBuilder}; use log::{debug, error, info, warn}; use rog_platform::platform::Properties; -use supergfxctl::pci_device::{GfxMode, GfxPower}; +use supergfxctl::pci_device::{Device, GfxMode, GfxPower}; use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxy; use versions::Versioning; @@ -71,7 +71,7 @@ fn build_menu() -> Menu { Menu::new([ MenuItem::separator(), MenuItem::button("Open", TrayAction::Open), - MenuItem::button("Quit", TrayAction::Quit), + MenuItem::button("Quit App", TrayAction::Quit), ]) } @@ -126,6 +126,20 @@ fn set_tray_icon_and_tip( } } +fn find_dgpu() -> Option { + use supergfxctl::pci_device::Device; + let dev = Device::find().unwrap_or_default(); + for dev in dev { + if dev.is_dgpu() { + info!("Found dGPU: {}", dev.pci_id()); + // Plain old thread is perfectly fine since most of this is potentially blocking + return Some(dev); + } + } + warn!("Did not find a dGPU on this system, dGPU status won't be avilable"); + None +} + /// The tray is controlled somewhat by `Arc>` pub fn init_tray(_supported_properties: Vec, config: Arc>) { std::thread::spawn(move || { @@ -155,27 +169,30 @@ pub fn init_tray(_supported_properties: Vec, config: Arc { + has_supergfx = true; + if let Ok(version) = gfx_proxy.version() { + if let Some(version) = Versioning::new(&version) { + let curr_gfx = Versioning::new("5.2.0").unwrap(); + warn!("supergfxd version = {version}"); + if version < curr_gfx { + // Don't allow mode changing if too old a version + warn!("supergfxd found but is too old to use"); + has_supergfx = false; + } } } } - }; + Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"), + } info!("Started ROGTray"); let mut last_power = GfxPower::Unknown; + let dev = find_dgpu(); loop { sleep(Duration::from_millis(1000)); if let Ok(lock) = config.try_lock() { @@ -187,11 +204,23 @@ pub fn init_tray(_supported_properties: Vec, config: Arc\n" "Language-Team: LANGUAGE \n" @@ -334,37 +334,37 @@ msgstr "" #: rog-control-center/ui/pages/system.slint:188 msgctxt "ppt_pl1_spl" -msgid "ppt_pl1_spl" +msgid "PL1, Sustained Power Limit" msgstr "" #: rog-control-center/ui/pages/system.slint:198 msgctxt "ppt_pl2_sppt" -msgid "ppt_pl2_sppt" +msgid "PL2, turbo power limit" msgstr "" #: rog-control-center/ui/pages/system.slint:208 msgctxt "ppt_fppt" -msgid "ppt_fppt" +msgid "fPPT, fast power limit" msgstr "" #: rog-control-center/ui/pages/system.slint:218 msgctxt "ppt_apu_sppt" -msgid "ppt_apu_sppt" +msgid "sPPT, APU slow power limit" msgstr "" #: rog-control-center/ui/pages/system.slint:228 msgctxt "ppt_platform_sppt" -msgid "ppt_platform_sppt" +msgid "Slow Package Power Tracking Limit" msgstr "" #: rog-control-center/ui/pages/system.slint:238 msgctxt "nv_dynamic_boost" -msgid "nv_dynamic_boost" +msgid "dGPU boost overclock" msgstr "" #: rog-control-center/ui/pages/system.slint:248 msgctxt "nv_temp_target" -msgid "nv_temp_target" +msgid "dGPU temperature max" msgstr "" #: rog-control-center/ui/pages/system.slint:294 @@ -412,46 +412,6 @@ msgctxt "PageSystem" msgid "Throttle Policy on AC" msgstr "" -#: rog-control-center/ui/widgets/aura_power.slint:33 -msgctxt "AuraPowerGroup" -msgid "Boot" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:43 -msgctxt "AuraPowerGroup" -msgid "Awake" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:53 -msgctxt "AuraPowerGroup" -msgid "Sleep" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:63 -msgctxt "AuraPowerGroup" -msgid "Shutdown" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:102 -msgctxt "AuraPowerGroupOld" -msgid "Zone Selection" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:114 -msgctxt "AuraPowerGroupOld" -msgid "Boot" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:124 -msgctxt "AuraPowerGroupOld" -msgid "Awake" -msgstr "" - -#: rog-control-center/ui/widgets/aura_power.slint:134 -msgctxt "AuraPowerGroupOld" -msgid "Sleep" -msgstr "" - #: rog-control-center/ui/types/aura_types.slint:49 msgctxt "Aura power zone" msgid "Logo" @@ -642,6 +602,46 @@ msgctxt "Aura speed" msgid "High" msgstr "" +#: rog-control-center/ui/widgets/aura_power.slint:33 +msgctxt "AuraPowerGroup" +msgid "Boot" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:43 +msgctxt "AuraPowerGroup" +msgid "Awake" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:53 +msgctxt "AuraPowerGroup" +msgid "Sleep" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:63 +msgctxt "AuraPowerGroup" +msgid "Shutdown" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:102 +msgctxt "AuraPowerGroupOld" +msgid "Zone Selection" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:114 +msgctxt "AuraPowerGroupOld" +msgid "Boot" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:124 +msgctxt "AuraPowerGroupOld" +msgid "Awake" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:134 +msgctxt "AuraPowerGroupOld" +msgid "Sleep" +msgstr "" + #: rog-control-center/ui/main_window.slint:51 msgctxt "MainWindow" msgid "ROG" @@ -679,6 +679,6 @@ msgstr "" #: rog-control-center/ui/main_window.slint:70 msgctxt "MainWindow" -msgid "Quit" +msgid "Quit App" msgstr "" diff --git a/rog-control-center/ui/main_window.slint b/rog-control-center/ui/main_window.slint index d49d9599..d7b72496 100644 --- a/rog-control-center/ui/main_window.slint +++ b/rog-control-center/ui/main_window.slint @@ -67,7 +67,7 @@ export component MainWindow inherits Window { Text { vertical-alignment: center; horizontal-alignment: center; - text: @tr("Quit"); + text: @tr("Quit App"); } TouchArea { diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index 5e3a7980..48b2478c 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -185,7 +185,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.ppt-pl1-spl: SystemSlider { - text: @tr("ppt_pl1_spl" => "ppt_pl1_spl"); + text: @tr("ppt_pl1_spl" => "PL1, Sustained Power Limit"); minimum: 5; maximum: 250; value <=> SystemPageData.ppt_pl1_spl; @@ -195,7 +195,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.ppt-pl2-sppt: SystemSlider { - text: @tr("ppt_pl2_sppt" => "ppt_pl2_sppt"); + text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); minimum: 5; maximum: 250; value <=> SystemPageData.ppt_pl2_sppt; @@ -205,7 +205,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.ppt-fppt: SystemSlider { - text: @tr("ppt_fppt" => "ppt_fppt"); + text: @tr("ppt_fppt" => "fPPT, fast power limit"); minimum: 5; maximum: 250; value <=> SystemPageData.ppt_fppt; @@ -215,7 +215,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.ppt-apu-sppt: SystemSlider { - text: @tr("ppt_apu_sppt" => "ppt_apu_sppt"); + text: @tr("ppt_apu_sppt" => "sPPT, APU slow power limit"); minimum: 5; maximum: 130; value <=> SystemPageData.ppt_apu_sppt; @@ -225,7 +225,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.ppt-platform-sppt: SystemSlider { - text: @tr("ppt_platform_sppt" => "ppt_platform_sppt"); + text: @tr("ppt_platform_sppt" => "Slow Package Power Tracking Limit"); maximum: 130; minimum: 5; value <=> SystemPageData.ppt_platform_sppt; @@ -235,7 +235,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.nv-dynamic-boost: SystemSlider { - text: @tr("nv_dynamic_boost" => "nv_dynamic_boost"); + text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); minimum: 5; maximum: 25; value <=> SystemPageData.nv_dynamic_boost; @@ -245,7 +245,7 @@ export component PageSystem inherits Rectangle { } if SystemPageData.available.nv-temp-target: SystemSlider { - text: @tr("nv_temp_target" => "nv_temp_target"); + text: @tr("nv_temp_target" => "dGPU temperature max"); minimum: 75; maximum: 87; value <=> SystemPageData.nv_temp_target;