Add notification of dGPU state change

This commit is contained in:
Luke D. Jones
2022-11-04 21:29:47 +13:00
parent ba1d3f045d
commit 1332ac803c
4 changed files with 374 additions and 177 deletions

507
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,8 +11,8 @@ concat-idents = "1.1.3"
dirs = "^4.0"
smol = "^1.2"
zbus = "^3.2"
zbus_macros = "^3.2"
zbus = "3.4.0"
zbus_macros = "3.4.0"
zvariant = "^3.2"
zvariant_derive = "^3.2"
logind-zbus = { version = "^3.0" } #, default-features = false, features = ["non_blocking"] }

View File

@@ -18,7 +18,8 @@ rog_dbus = { path = "../rog-dbus" }
rog_aura = { path = "../rog-aura" }
rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" }
# supergfxctl = { git = "https://gitlab.com/asus-linux/supergfxctl.git" }
#supergfxctl = { git = "https://gitlab.com/asus-linux/supergfxctl.git" }
supergfxctl = { path = "../../supergfxctl" }
smol.workspace = true

View File

@@ -14,6 +14,7 @@ use std::{
},
thread::spawn,
};
use supergfxctl::pci_device::GfxPower;
use zbus::export::futures_util::StreamExt;
const NOTIF_HEADER: &str = "ROG Control";
@@ -69,6 +70,42 @@ pub fn start_notifications(
})
.detach();
let notifs_enabled1 = notifs_enabled.clone();
let last_notif = last_notification.clone();
let bios_notified1 = bios_notified.clone();
executor
.spawn(async move {
let conn = zbus::Connection::system().await.unwrap();
let proxy = supergfxctl::zbus_proxy::DaemonProxy::new(&conn)
.await
.unwrap();
if let Ok(p) = proxy.receive_notify_gfx_status().await {
p.for_each(|e| {
if let Ok(out) = e.args() {
if notifs_enabled1.load(Ordering::SeqCst) {
let status = out.status();
if *status != GfxPower::Unknown {
// Required check because status cycles through active/unknown/suspended
if let Ok(ref mut lock) = last_notif.try_lock() {
notify!(
do_notification(
"dGPU status changed:",
&format!("{status:?}",)
),
lock
);
}
}
}
}
bios_notified1.store(true, Ordering::SeqCst);
future::ready(())
})
.await;
};
})
.detach();
let bios_notified1 = bios_notified.clone();
executor
.spawn(async move {