Enable tray and notifs without supergfx

This commit is contained in:
Luke D. Jones
2024-05-24 12:58:37 +12:00
parent e443ab00c9
commit 792fae3ed7
6 changed files with 166 additions and 128 deletions

View File

@@ -12,6 +12,7 @@
- Don't panic if -ENODEV on fan_curve enable - Don't panic if -ENODEV on fan_curve enable
- Adjust the G513Q support to match what is on the asus website. - 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 - Adjust init sequence of anime to prevent accidental use of Slash as Anime
- Enable notifs and tray icon without supergfx
## [v6.0.9] ## [v6.0.9]

View File

@@ -51,6 +51,10 @@ fn start_dpu_status_mon(config: Arc<Mutex<Config>>) {
let mut found_dgpu = false; // just for logging let mut found_dgpu = false; // just for logging
for dev in dev { for dev in dev {
if dev.is_dgpu() { if dev.is_dgpu() {
info!(
"Found dGPU: {}, starting status notifications",
dev.pci_id()
);
let enabled_notifications_copy = config.clone(); let enabled_notifications_copy = config.clone();
// Plain old thread is perfectly fine since most of this is potentially blocking // Plain old thread is perfectly fine since most of this is potentially blocking
std::thread::spawn(move || { 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 // GPU MUX Mode notif
let enabled_notifications_copy = config.clone(); let enabled_notifications_copy = config.clone();
tokio::spawn(async move { tokio::spawn(async move {
@@ -176,13 +187,21 @@ pub fn start_notifications(
let enabled_notifications_copy = config.clone(); let enabled_notifications_copy = config.clone();
// GPU Mode change/action notif // GPU Mode change/action notif
tokio::spawn(async move { tokio::spawn(async move {
if let Err(e) = { let conn = zbus::Connection::system().await.map_err(|e| {
let conn = zbus::Connection::system().await?; no_supergfx(&e);
let proxy = SuperProxy::builder(&conn).build().await?; e
let _ = proxy.mode().await?; })?;
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(); let proxy_copy = proxy.clone();
if let Ok(mut p) = proxy.receive_notify_action().await { let mut p = proxy.receive_notify_action().await?;
tokio::spawn(async move { tokio::spawn(async move {
info!("Started zbus signal thread: receive_notify_action"); info!("Started zbus signal thread: receive_notify_action");
while let Some(e) = p.next().await { while let Some(e) = p.next().await {
@@ -191,10 +210,7 @@ pub fn start_notifications(
let mode = convert_gfx_mode(proxy.mode().await.unwrap_or_default()); let mode = convert_gfx_mode(proxy.mode().await.unwrap_or_default());
match action { match action {
supergfxctl::actions::UserActionRequired::Reboot => { supergfxctl::actions::UserActionRequired::Reboot => {
do_mux_notification( do_mux_notification("Graphics mode change requires reboot", &mode)
"Graphics mode change requires reboot",
&mode,
)
} }
_ => do_gfx_action_notif(<&str>::from(action), *action, mode), _ => do_gfx_action_notif(<&str>::from(action), *action, mode),
} }
@@ -206,9 +222,8 @@ pub fn start_notifications(
} }
} }
}); });
};
if let Ok(mut p) = proxy_copy.receive_notify_gfx_status().await { let mut p = proxy_copy.receive_notify_gfx_status().await?;
tokio::spawn(async move { tokio::spawn(async move {
info!("Started zbus signal thread: receive_notify_gfx_status"); info!("Started zbus signal thread: receive_notify_gfx_status");
let mut last_status = GfxPower::Unknown; let mut last_status = GfxPower::Unknown;
@@ -231,13 +246,6 @@ pub fn start_notifications(
} }
} }
}); });
};
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());
}
Ok::<(), zbus::Error>(()) Ok::<(), zbus::Error>(())
}); });

View File

@@ -12,7 +12,7 @@ use std::time::Duration;
use betrayer::{Icon, Menu, MenuItem, TrayEvent, TrayIcon, TrayIconBuilder}; use betrayer::{Icon, Menu, MenuItem, TrayEvent, TrayIcon, TrayIconBuilder};
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::platform::Properties; 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 supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxy;
use versions::Versioning; use versions::Versioning;
@@ -71,7 +71,7 @@ fn build_menu() -> Menu<TrayAction> {
Menu::new([ Menu::new([
MenuItem::separator(), MenuItem::separator(),
MenuItem::button("Open", TrayAction::Open), 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<Device> {
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<Mutex<SystemState>>` /// The tray is controlled somewhat by `Arc<Mutex<SystemState>>`
pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Config>>) { pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Config>>) {
std::thread::spawn(move || { std::thread::spawn(move || {
@@ -155,12 +169,12 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
gpu_integrated, gpu_integrated,
}); });
let mut has_supergfx = true; let mut has_supergfx = false;
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
if let Ok(gfx_proxy) = GfxProxy::new(&conn) { if let Ok(gfx_proxy) = GfxProxy::new(&conn) {
let mut supergfx_active = false; match gfx_proxy.mode() {
if gfx_proxy.mode().is_ok() { Ok(_) => {
supergfx_active = true; has_supergfx = true;
if let Ok(version) = gfx_proxy.version() { if let Ok(version) = gfx_proxy.version() {
if let Some(version) = Versioning::new(&version) { if let Some(version) = Versioning::new(&version) {
let curr_gfx = Versioning::new("5.2.0").unwrap(); let curr_gfx = Versioning::new("5.2.0").unwrap();
@@ -172,10 +186,13 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
} }
} }
} }
}; }
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}"),
}
info!("Started ROGTray"); info!("Started ROGTray");
let mut last_power = GfxPower::Unknown; let mut last_power = GfxPower::Unknown;
let dev = find_dgpu();
loop { loop {
sleep(Duration::from_millis(1000)); sleep(Duration::from_millis(1000));
if let Ok(lock) = config.try_lock() { if let Ok(lock) = config.try_lock() {
@@ -187,11 +204,23 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
if let Ok(mode) = gfx_proxy.mode() { if let Ok(mode) = gfx_proxy.mode() {
if let Ok(power) = gfx_proxy.power() { if let Ok(power) = gfx_proxy.power() {
if last_power != power { if last_power != power {
set_tray_icon_and_tip(mode, power, &mut tray, supergfx_active); set_tray_icon_and_tip(mode, power, &mut tray, has_supergfx);
last_power = power; last_power = power;
} }
} }
} }
} else if let Some(dev) = dev.as_ref() {
if let Ok(power) = dev.get_runtime_status() {
if last_power != power {
set_tray_icon_and_tip(
GfxMode::Hybrid,
power,
&mut tray,
has_supergfx,
);
last_power = power;
}
}
} }
} }
} }

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-05-20 22:11+0000\n" "POT-Creation-Date: 2024-05-24 00:58+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -334,37 +334,37 @@ msgstr ""
#: rog-control-center/ui/pages/system.slint:188 #: rog-control-center/ui/pages/system.slint:188
msgctxt "ppt_pl1_spl" msgctxt "ppt_pl1_spl"
msgid "ppt_pl1_spl" msgid "PL1, Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:198 #: rog-control-center/ui/pages/system.slint:198
msgctxt "ppt_pl2_sppt" msgctxt "ppt_pl2_sppt"
msgid "ppt_pl2_sppt" msgid "PL2, turbo power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:208 #: rog-control-center/ui/pages/system.slint:208
msgctxt "ppt_fppt" msgctxt "ppt_fppt"
msgid "ppt_fppt" msgid "fPPT, fast power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:218 #: rog-control-center/ui/pages/system.slint:218
msgctxt "ppt_apu_sppt" msgctxt "ppt_apu_sppt"
msgid "ppt_apu_sppt" msgid "sPPT, APU slow power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:228 #: rog-control-center/ui/pages/system.slint:228
msgctxt "ppt_platform_sppt" msgctxt "ppt_platform_sppt"
msgid "ppt_platform_sppt" msgid "Slow Package Power Tracking Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:238 #: rog-control-center/ui/pages/system.slint:238
msgctxt "nv_dynamic_boost" msgctxt "nv_dynamic_boost"
msgid "nv_dynamic_boost" msgid "dGPU boost overclock"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:248 #: rog-control-center/ui/pages/system.slint:248
msgctxt "nv_temp_target" msgctxt "nv_temp_target"
msgid "nv_temp_target" msgid "dGPU temperature max"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:294 #: rog-control-center/ui/pages/system.slint:294
@@ -412,46 +412,6 @@ msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" 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 #: rog-control-center/ui/types/aura_types.slint:49
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Logo" msgid "Logo"
@@ -642,6 +602,46 @@ msgctxt "Aura speed"
msgid "High" msgid "High"
msgstr "" 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 #: rog-control-center/ui/main_window.slint:51
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "ROG" msgid "ROG"
@@ -679,6 +679,6 @@ msgstr ""
#: rog-control-center/ui/main_window.slint:70 #: rog-control-center/ui/main_window.slint:70
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "Quit" msgid "Quit App"
msgstr "" msgstr ""

View File

@@ -67,7 +67,7 @@ export component MainWindow inherits Window {
Text { Text {
vertical-alignment: center; vertical-alignment: center;
horizontal-alignment: center; horizontal-alignment: center;
text: @tr("Quit"); text: @tr("Quit App");
} }
TouchArea { TouchArea {

View File

@@ -185,7 +185,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.ppt-pl1-spl: SystemSlider { 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; minimum: 5;
maximum: 250; maximum: 250;
value <=> SystemPageData.ppt_pl1_spl; value <=> SystemPageData.ppt_pl1_spl;
@@ -195,7 +195,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.ppt-pl2-sppt: SystemSlider { 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; minimum: 5;
maximum: 250; maximum: 250;
value <=> SystemPageData.ppt_pl2_sppt; value <=> SystemPageData.ppt_pl2_sppt;
@@ -205,7 +205,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.ppt-fppt: SystemSlider { if SystemPageData.available.ppt-fppt: SystemSlider {
text: @tr("ppt_fppt" => "ppt_fppt"); text: @tr("ppt_fppt" => "fPPT, fast power limit");
minimum: 5; minimum: 5;
maximum: 250; maximum: 250;
value <=> SystemPageData.ppt_fppt; value <=> SystemPageData.ppt_fppt;
@@ -215,7 +215,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.ppt-apu-sppt: SystemSlider { 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; minimum: 5;
maximum: 130; maximum: 130;
value <=> SystemPageData.ppt_apu_sppt; value <=> SystemPageData.ppt_apu_sppt;
@@ -225,7 +225,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.ppt-platform-sppt: SystemSlider { 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; maximum: 130;
minimum: 5; minimum: 5;
value <=> SystemPageData.ppt_platform_sppt; value <=> SystemPageData.ppt_platform_sppt;
@@ -235,7 +235,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.nv-dynamic-boost: SystemSlider { 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; minimum: 5;
maximum: 25; maximum: 25;
value <=> SystemPageData.nv_dynamic_boost; value <=> SystemPageData.nv_dynamic_boost;
@@ -245,7 +245,7 @@ export component PageSystem inherits Rectangle {
} }
if SystemPageData.available.nv-temp-target: SystemSlider { 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; minimum: 75;
maximum: 87; maximum: 87;
value <=> SystemPageData.nv_temp_target; value <=> SystemPageData.nv_temp_target;