Clarify gpu mux notif

This commit is contained in:
Luke D. Jones
2022-11-06 22:17:46 +13:00
parent 7385844a9b
commit cd5a85a843

View File

@@ -1,8 +1,10 @@
use crate::error::Result;
use notify_rust::{Hint, Notification, NotificationHandle}; use notify_rust::{Hint, Notification, NotificationHandle};
use rog_dbus::{ use rog_dbus::{
zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy, zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy,
zbus_power::PowerProxy, zbus_profile::ProfileProxy, zbus_power::PowerProxy, zbus_profile::ProfileProxy,
}; };
use rog_platform::platform::GpuMode;
use rog_profiles::Profile; use rog_profiles::Profile;
use smol::{future, Executor}; use smol::{future, Executor};
use std::{ use std::{
@@ -15,7 +17,6 @@ use std::{
}; };
use supergfxctl::pci_device::GfxPower; use supergfxctl::pci_device::GfxPower;
use zbus::export::futures_util::StreamExt; use zbus::export::futures_util::StreamExt;
use crate::error::Result;
const NOTIF_HEADER: &str = "ROG Control"; const NOTIF_HEADER: &str = "ROG Control";
@@ -139,7 +140,7 @@ pub fn start_notifications(
notifs_enabled, notifs_enabled,
[mode], [mode],
"BIOS GPU MUX mode (reboot required)", "BIOS GPU MUX mode (reboot required)",
do_notification mux_notification
); );
// Charge notif // Charge notif
@@ -280,28 +281,28 @@ where
notif notif
} }
fn do_notification<T>( fn do_notification<T>(message: &str, data: &T) -> Result<NotificationHandle>
message: &str,
data: &T,
) -> Result<NotificationHandle>
where where
T: Display, T: Display,
{ {
Ok(base_notification(message, data).show()?) Ok(base_notification(message, data).show()?)
} }
fn ac_power_notification( fn ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle> {
message: &str, let data = if *on {
on: &bool, "plugged".to_string()
) -> Result<NotificationHandle> { } else {
let data = if *on { "plugged".to_string() } else { "unplugged".to_string() }; "unplugged".to_string()
};
Ok(base_notification(message, &data).show()?) Ok(base_notification(message, &data).show()?)
} }
fn do_thermal_notif( /// Actual GpuMode unused as data is never correct until switched by reboot
message: &str, fn mux_notification(message: &str, _: &GpuMode) -> Result<NotificationHandle> {
profile: &Profile, Ok(base_notification(message, &"").show()?)
) -> Result<NotificationHandle> { }
fn do_thermal_notif(message: &str, profile: &Profile) -> Result<NotificationHandle> {
let icon = match profile { let icon = match profile {
Profile::Balanced => "asus_notif_yellow", Profile::Balanced => "asus_notif_yellow",
Profile::Performance => "asus_notif_red", Profile::Performance => "asus_notif_red",