ROGCC: Make zbus notifications fully manage pagestates

This commit is contained in:
Luke D. Jones
2022-11-15 22:26:17 +13:00
parent 762bfea102
commit 73b1a7050a
10 changed files with 115 additions and 174 deletions

View File

@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
## [v4.5.1- RC2]
- Share pagestates with tray process in ROGCC
## [v4.5.1- RC1] ## [v4.5.1- RC1]
### Added ### Added
- Support for FA506IE LED modes (Author: Herohtar) - Support for FA506IE LED modes (Author: Herohtar)
@@ -12,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add a basic system tray with dGPU status and gpu mode switch actions - Add a basic system tray with dGPU status and gpu mode switch actions
- Fixup some notifications in ROGCC - Fixup some notifications in ROGCC
- Add config options for notifications for ROGCC - Add config options for notifications for ROGCC
- Share pagestates with tray process in ROGCC
## [v4.5.0] ## [v4.5.0]
### Added ### Added

18
Cargo.lock generated
View File

@@ -83,7 +83,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]] [[package]]
name = "asusctl" name = "asusctl"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"daemon", "daemon",
"gif", "gif",
@@ -662,7 +662,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]] [[package]]
name = "daemon" name = "daemon"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"concat-idents", "concat-idents",
@@ -686,7 +686,7 @@ dependencies = [
[[package]] [[package]]
name = "daemon-user" name = "daemon-user"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"dirs", "dirs",
"rog_anime", "rog_anime",
@@ -2398,7 +2398,7 @@ dependencies = [
[[package]] [[package]]
name = "rog-control-center" name = "rog-control-center"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"daemon", "daemon",
"dirs", "dirs",
@@ -2428,7 +2428,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_anime" name = "rog_anime"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"gif", "gif",
"glam", "glam",
@@ -2444,7 +2444,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_aura" name = "rog_aura"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
@@ -2455,7 +2455,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_dbus" name = "rog_dbus"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"rog_anime", "rog_anime",
"rog_aura", "rog_aura",
@@ -2468,7 +2468,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_platform" name = "rog_platform"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"concat-idents", "concat-idents",
"inotify", "inotify",
@@ -2485,7 +2485,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_profiles" name = "rog_profiles"
version = "4.5.1-RC1" version = "4.5.1-RC2"
dependencies = [ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",

View File

@@ -2,7 +2,7 @@
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"] members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
[workspace.package] [workspace.package]
version = "4.5.1-RC1" version = "4.5.1-RC2"
[workspace.dependencies] [workspace.dependencies]
async-trait = "^0.1" async-trait = "^0.1"

View File

@@ -5,7 +5,7 @@ pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e
pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08]; pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use std::str::FromStr; use std::{fmt::Display, str::FromStr};
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zvariant::Type; use zvariant::Type;
@@ -171,6 +171,12 @@ pub enum AuraModeNum {
Flash = 12, Flash = 12,
} }
impl Display for AuraModeNum {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", <&str>::from(self))
}
}
impl From<AuraModeNum> for String { impl From<AuraModeNum> for String {
fn from(mode: AuraModeNum) -> Self { fn from(mode: AuraModeNum) -> Self {
match mode { match mode {

View File

@@ -55,8 +55,6 @@ impl RogApp {
let oscillator_toggle = Arc::new(AtomicBool::new(false)); let oscillator_toggle = Arc::new(AtomicBool::new(false));
let oscillator_toggle1 = oscillator_toggle.clone(); let oscillator_toggle1 = oscillator_toggle.clone();
let states1 = states.clone();
let supported1 = supported.clone();
std::thread::spawn(move || { std::thread::spawn(move || {
let started = Instant::now(); let started = Instant::now();
let mut toggled = false; let mut toggled = false;
@@ -86,13 +84,6 @@ impl RogApp {
oscillator1_2.store(tmp2, Ordering::SeqCst); oscillator1_2.store(tmp2, Ordering::SeqCst);
oscillator1_3.store(tmp3, Ordering::SeqCst); oscillator1_3.store(tmp3, Ordering::SeqCst);
if let Ok(mut states) = states1.try_lock() {
states
.refresh_if_notfied(&supported1)
.map_err(|e| states.error = Some(e.to_string()))
.ok();
}
std::thread::sleep(Duration::from_millis(33)); std::thread::sleep(Duration::from_millis(33));
} }
}); });

View File

@@ -118,9 +118,7 @@ fn main() -> Result<()> {
Err(_) => on_tmp_dir_exists().unwrap(), Err(_) => on_tmp_dir_exists().unwrap(),
}; };
let states = Arc::new(Mutex::new( let states = setup_page_state_and_notifs(layout, enabled_notifications, &supported).unwrap();
setup_page_state_and_notifs(layout, enabled_notifications, &supported).unwrap(),
));
init_tray(supported, states.clone()); init_tray(supported, states.clone());
@@ -156,11 +154,14 @@ fn setup_page_state_and_notifs(
keyboard_layout: KeyLayout, keyboard_layout: KeyLayout,
enabled_notifications: Arc<Mutex<EnabledNotifications>>, enabled_notifications: Arc<Mutex<EnabledNotifications>>,
supported: &SupportedFunctions, supported: &SupportedFunctions,
) -> Result<PageDataStates> { ) -> Result<Arc<Mutex<PageDataStates>>> {
let page_states = let page_states = Arc::new(Mutex::new(PageDataStates::new(
PageDataStates::new(keyboard_layout, enabled_notifications.clone(), supported)?; keyboard_layout,
enabled_notifications.clone(),
supported,
)?));
start_notifications(page_states.was_notified.clone(), enabled_notifications)?; start_notifications(page_states.clone(), enabled_notifications)?;
Ok(page_states) Ok(page_states)
} }

View File

@@ -1,4 +1,4 @@
use crate::{config::Config, error::Result}; use crate::{config::Config, error::Result, page_states::PageDataStates};
use notify_rust::{Hint, Notification, NotificationHandle, Urgency}; use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
use rog_dbus::{ use rog_dbus::{
zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy, zbus_anime::AnimeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy,
@@ -10,10 +10,7 @@ use serde::{Deserialize, Serialize};
use std::{ use std::{
fmt::Display, fmt::Display,
process::Command, process::Command,
sync::{ sync::{Arc, Mutex},
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
}; };
use supergfxctl::{pci_device::GfxPower, zbus_proxy::DaemonProxy as SuperProxy}; use supergfxctl::{pci_device::GfxPower, zbus_proxy::DaemonProxy as SuperProxy};
use zbus::export::futures_util::{future, StreamExt}; use zbus::export::futures_util::{future, StreamExt};
@@ -65,18 +62,6 @@ impl EnabledNotifications {
} }
} }
/// Intended as a help to determine if daemon controllers notified state
#[derive(Debug, Default, Clone)]
pub struct WasNotified {
pub charge: Arc<AtomicBool>,
pub bios: Arc<AtomicBool>,
pub aura: Arc<AtomicBool>,
pub anime: Arc<AtomicBool>,
pub profiles: Arc<AtomicBool>,
pub fans: Arc<AtomicBool>,
pub gfx: Arc<AtomicBool>,
}
macro_rules! notify { macro_rules! notify {
($notifier:expr, $last_notif:ident) => { ($notifier:expr, $last_notif:ident) => {
if let Some(notif) = $last_notif.take() { if let Some(notif) = $last_notif.take() {
@@ -92,16 +77,18 @@ macro_rules! notify {
macro_rules! recv_notif { macro_rules! recv_notif {
($proxy:ident, ($proxy:ident,
$signal:ident, $signal:ident,
$was_notified:ident,
$last_notif:ident, $last_notif:ident,
$notif_enabled:ident, $notif_enabled:ident,
[$($out_arg:ident)+], $page_states:ident,
($($args: tt)*),
($($out_arg:tt)+),
$msg:literal, $msg:literal,
$notifier:ident) => { $notifier:ident) => {
let last_notif = $last_notif.clone(); let last_notif = $last_notif.clone();
let notifs_enabled1 = $notif_enabled.clone(); let notifs_enabled1 = $notif_enabled.clone();
let notified = $was_notified.clone(); let page_states1 = $page_states.clone();
// TODO: make a macro or generic function or something...
tokio::spawn(async move { tokio::spawn(async move {
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let proxy = $proxy::new(&conn).await.unwrap(); let proxy = $proxy::new(&conn).await.unwrap();
@@ -110,12 +97,15 @@ macro_rules! recv_notif {
if let Ok(out) = e.args() { if let Ok(out) = e.args() {
if let Ok(config) = notifs_enabled1.lock() { if let Ok(config) = notifs_enabled1.lock() {
if config.all_enabled && config.$signal { if config.all_enabled && config.$signal {
if let Ok(ref mut lock) = last_notif.try_lock() { if let Ok(ref mut lock) = last_notif.lock() {
notify!($notifier($msg, &out$(.$out_arg)+()), lock); notify!($notifier($msg, &out.$($out_arg)+()), lock);
} }
} }
} }
notified.store(true, Ordering::SeqCst); if let Ok(mut lock) = page_states1.lock() {
lock.$($args)+ = *out.$($out_arg)+();
lock.set_notified();
}
} }
} }
}; };
@@ -126,29 +116,20 @@ macro_rules! recv_notif {
type SharedHandle = Arc<Mutex<Option<NotificationHandle>>>; type SharedHandle = Arc<Mutex<Option<NotificationHandle>>>;
pub fn start_notifications( pub fn start_notifications(
was_notified: WasNotified, page_states: Arc<Mutex<PageDataStates>>,
enabled_notifications: Arc<Mutex<EnabledNotifications>>, enabled_notifications: Arc<Mutex<EnabledNotifications>>,
) -> Result<()> { ) -> Result<()> {
let last_notification: SharedHandle = Arc::new(Mutex::new(None)); let last_notification: SharedHandle = Arc::new(Mutex::new(None));
let WasNotified {
bios: bios_notified,
charge: charge_notified,
profiles: profiles_notified,
aura: aura_notified,
anime: anime_notified,
gfx: gfx_notified,
..
} = was_notified;
// BIOS notif // BIOS notif
recv_notif!( recv_notif!(
RogBiosProxy, RogBiosProxy,
receive_notify_post_boot_sound, receive_notify_post_boot_sound,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[on], page_states,
(bios.post_sound),
(on),
"BIOS Post sound", "BIOS Post sound",
do_notification do_notification
); );
@@ -156,10 +137,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
RogBiosProxy, RogBiosProxy,
receive_notify_panel_od, receive_notify_panel_od,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[overdrive], page_states,
(bios.panel_overdrive),
(overdrive),
"Panel Overdrive enabled:", "Panel Overdrive enabled:",
do_notification do_notification
); );
@@ -167,10 +149,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
RogBiosProxy, RogBiosProxy,
receive_notify_dgpu_disable, receive_notify_dgpu_disable,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[disable], page_states,
(bios.dgpu_disable),
(disable),
"BIOS dGPU disabled", "BIOS dGPU disabled",
do_notification do_notification
); );
@@ -178,10 +161,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
RogBiosProxy, RogBiosProxy,
receive_notify_egpu_enable, receive_notify_egpu_enable,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[enable], page_states,
(bios.egpu_enable),
(enable),
"BIOS eGPU enabled", "BIOS eGPU enabled",
do_notification do_notification
); );
@@ -189,10 +173,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
RogBiosProxy, RogBiosProxy,
receive_notify_gpu_mux_mode, receive_notify_gpu_mux_mode,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[mode], page_states,
(bios.dedicated_gfx),
(mode),
"Reboot required. BIOS GPU MUX mode set to", "Reboot required. BIOS GPU MUX mode set to",
do_mux_notification do_mux_notification
); );
@@ -201,10 +186,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
PowerProxy, PowerProxy,
receive_notify_charge_control_end_threshold, receive_notify_charge_control_end_threshold,
charge_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[limit], page_states,
(power_state.charge_limit),
(limit),
"Battery charge limit changed to", "Battery charge limit changed to",
do_notification do_notification
); );
@@ -212,10 +198,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
PowerProxy, PowerProxy,
receive_notify_mains_online, receive_notify_mains_online,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[on], page_states,
(power_state.ac_power),
(on),
"AC Power power is", "AC Power power is",
ac_power_notification ac_power_notification
); );
@@ -224,10 +211,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
ProfileProxy, ProfileProxy,
receive_notify_profile, receive_notify_profile,
profiles_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[profile], page_states,
(profiles.current),
(profile),
"Profile changed to", "Profile changed to",
do_thermal_notif do_thermal_notif
); );
@@ -237,32 +225,24 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
LedProxy, LedProxy,
receive_notify_led, receive_notify_led,
aura_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[data mode_name], page_states,
(aura.current_mode),
(data.mode),
"Keyboard LED mode changed to", "Keyboard LED mode changed to",
do_notification do_notification
); );
tokio::spawn(async move { let page_states1 = page_states.clone();
let conn = zbus::Connection::system().await.unwrap();
let proxy = LedProxy::new(&conn).await.unwrap();
if let Ok(p) = proxy.receive_all_signals().await {
p.for_each(|_| {
aura_notified.store(true, Ordering::SeqCst);
future::ready(())
})
.await;
};
});
tokio::spawn(async move { tokio::spawn(async move {
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let proxy = AnimeProxy::new(&conn).await.unwrap(); let proxy = AnimeProxy::new(&conn).await.unwrap();
if let Ok(p) = proxy.receive_power_states().await { if let Ok(p) = proxy.receive_power_states().await {
p.for_each(|_| { p.for_each(|_| {
anime_notified.store(true, Ordering::SeqCst); if let Ok(_lock) = page_states1.lock() {
// TODO: lock.anime.
}
future::ready(()) future::ready(())
}) })
.await; .await;
@@ -272,10 +252,11 @@ pub fn start_notifications(
recv_notif!( recv_notif!(
SuperProxy, SuperProxy,
receive_notify_gfx, receive_notify_gfx,
bios_notified,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
[mode], page_states,
(gfx_state.mode),
(mode),
"Gfx mode changed to", "Gfx mode changed to",
do_notification do_notification
); );
@@ -300,7 +281,6 @@ pub fn start_notifications(
let action = out.action(); let action = out.action();
do_gfx_action_notif("Gfx mode change requires", &format!("{action:?}",)) do_gfx_action_notif("Gfx mode change requires", &format!("{action:?}",))
.unwrap(); .unwrap();
bios_notified.store(true, Ordering::SeqCst);
} }
} }
}; };
@@ -314,20 +294,23 @@ pub fn start_notifications(
if let Ok(mut p) = proxy.receive_notify_gfx_status().await { if let Ok(mut p) = proxy.receive_notify_gfx_status().await {
while let Some(e) = p.next().await { while let Some(e) = p.next().await {
if let Ok(out) = e.args() { if let Ok(out) = e.args() {
let status = out.status(); let status = out.status;
if *status != GfxPower::Unknown { if status != GfxPower::Unknown {
if let Ok(config) = notifs_enabled1.lock() { if let Ok(config) = notifs_enabled1.lock() {
if config.all_enabled && config.receive_notify_gfx_status { if config.all_enabled && config.receive_notify_gfx_status {
// Required check because status cycles through active/unknown/suspended // Required check because status cycles through active/unknown/suspended
if let Ok(ref mut lock) = last_notif.try_lock() { if let Ok(ref mut lock) = last_notif.lock() {
notify!( notify!(
do_gpu_status_notif("dGPU status changed:", status), do_gpu_status_notif("dGPU status changed:", &status),
lock lock
); );
} }
} }
} }
gfx_notified.store(true, Ordering::SeqCst); if let Ok(mut lock) = page_states.lock() {
lock.gfx_state.power_status = status;
lock.set_notified();
}
} }
} }
} }

View File

@@ -1,6 +1,6 @@
use std::{ use std::{
collections::{BTreeMap, HashSet}, collections::{BTreeMap, HashSet},
sync::{atomic::Ordering, Arc, Mutex}, sync::{Arc, Mutex},
}; };
use egui::Vec2; use egui::Vec2;
@@ -12,11 +12,7 @@ use supergfxctl::{
zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking, zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking,
}; };
use crate::{ use crate::{error::Result, notify::EnabledNotifications, RogDbusClientBlocking};
error::Result,
notify::{EnabledNotifications, WasNotified},
RogDbusClientBlocking,
};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct BiosState { pub struct BiosState {
@@ -236,10 +232,24 @@ impl GfxState {
} }
} }
#[derive(Clone, Debug)]
pub struct PowerState {
pub charge_limit: u8,
pub ac_power: bool,
}
impl PowerState {
pub fn new(_supported: &SupportedFunctions, dbus: &RogDbusClientBlocking) -> Result<Self> {
Ok(Self {
charge_limit: dbus.proxies().charge().charge_control_end_threshold()?,
ac_power: dbus.proxies().charge().mains_online()?,
})
}
}
pub struct PageDataStates { pub struct PageDataStates {
pub keyboard_layout: KeyLayout, pub keyboard_layout: KeyLayout,
pub enabled_notifications: Arc<Mutex<EnabledNotifications>>, pub enabled_notifications: Arc<Mutex<EnabledNotifications>>,
pub was_notified: WasNotified,
/// Because much of the app state here is the same as `RogBiosSupportedFunctions` /// Because much of the app state here is the same as `RogBiosSupportedFunctions`
/// we can re-use that structure. /// we can re-use that structure.
pub bios: BiosState, pub bios: BiosState,
@@ -248,7 +258,7 @@ pub struct PageDataStates {
pub profiles: ProfilesState, pub profiles: ProfilesState,
pub fan_curves: FanCurvesState, pub fan_curves: FanCurvesState,
pub gfx_state: GfxState, pub gfx_state: GfxState,
pub charge_limit: u8, pub power_state: PowerState,
pub error: Option<String>, pub error: Option<String>,
/// Specific field for the tray only so that we can know when it does need update. /// Specific field for the tray only so that we can know when it does need update.
/// The tray should set this to false when done. /// The tray should set this to false when done.
@@ -270,11 +280,7 @@ impl PageDataStates {
Ok(Self { Ok(Self {
keyboard_layout, keyboard_layout,
enabled_notifications, enabled_notifications,
was_notified: WasNotified::default(), power_state: PowerState::new(supported, &asus_dbus)?,
charge_limit: asus_dbus
.proxies()
.charge()
.charge_control_end_threshold()?,
bios: BiosState::new(supported, &asus_dbus)?, bios: BiosState::new(supported, &asus_dbus)?,
aura: AuraState::new(supported, &asus_dbus)?, aura: AuraState::new(supported, &asus_dbus)?,
anime: AnimeState::new(supported, &asus_dbus)?, anime: AnimeState::new(supported, &asus_dbus)?,
@@ -289,61 +295,9 @@ impl PageDataStates {
}) })
} }
pub fn refresh_if_notfied(&mut self, supported: &SupportedFunctions) -> Result<bool> { pub fn set_notified(&mut self) {
let mut notified = false; self.tray_should_update = true;
if self.was_notified.charge.load(Ordering::SeqCst) { self.app_should_update = true;
self.charge_limit = self
.asus_dbus
.proxies()
.charge()
.charge_control_end_threshold()?;
self.was_notified.charge.store(false, Ordering::SeqCst);
notified = true;
self.tray_should_update = true;
self.app_should_update = true;
}
if self.was_notified.aura.load(Ordering::SeqCst) {
self.aura = AuraState::new(supported, &self.asus_dbus)?;
self.was_notified.aura.store(false, Ordering::SeqCst);
notified = true;
self.tray_should_update = true;
self.app_should_update = true;
}
if self.was_notified.bios.load(Ordering::SeqCst) {
self.bios = BiosState::new(supported, &self.asus_dbus)?;
self.was_notified.bios.store(false, Ordering::SeqCst);
notified = true;
self.tray_should_update = true;
self.app_should_update = true;
}
if self.was_notified.profiles.load(Ordering::SeqCst) {
self.profiles = ProfilesState::new(supported, &self.asus_dbus)?;
self.was_notified.profiles.store(false, Ordering::SeqCst);
notified = true;
self.tray_should_update = true;
self.app_should_update = true;
}
if self.was_notified.fans.load(Ordering::SeqCst) {
self.fan_curves = FanCurvesState::new(supported, &self.asus_dbus)?;
self.was_notified.fans.store(false, Ordering::SeqCst);
notified = true;
self.tray_should_update = true;
self.app_should_update = true;
}
if self.was_notified.gfx.load(Ordering::SeqCst) {
self.gfx_state = GfxState::new(supported, &self.gfx_dbus)?;
self.was_notified.gfx.store(false, Ordering::SeqCst);
notified = true;
self.tray_should_update = true;
self.app_should_update = true;
}
Ok(notified)
} }
} }
@@ -355,7 +309,6 @@ impl Default for PageDataStates {
Self { Self {
keyboard_layout: KeyLayout::ga401_layout(), keyboard_layout: KeyLayout::ga401_layout(),
enabled_notifications: Default::default(), enabled_notifications: Default::default(),
was_notified: WasNotified::default(),
bios: BiosState { bios: BiosState {
post_sound: Default::default(), post_sound: Default::default(),
dedicated_gfx: GpuMode::NotSupported, dedicated_gfx: GpuMode::NotSupported,
@@ -397,7 +350,10 @@ impl Default for PageDataStates {
mode: GfxMode::None, mode: GfxMode::None,
power_status: GfxPower::Unknown, power_status: GfxPower::Unknown,
}, },
charge_limit: Default::default(), power_state: PowerState {
charge_limit: 99,
ac_power: false,
},
error: Default::default(), error: Default::default(),
tray_should_update: true, tray_should_update: true,
app_should_update: true, app_should_update: true,

View File

@@ -299,7 +299,7 @@ pub fn init_tray(
tray.rebuild_and_update( tray.rebuild_and_update(
&supported, &supported,
lock.gfx_state.mode, lock.gfx_state.mode,
lock.charge_limit, lock.power_state.charge_limit,
lock.bios.panel_overdrive, lock.bios.panel_overdrive,
); );
lock.tray_should_update = false; lock.tray_should_update = false;

View File

@@ -38,7 +38,7 @@ pub fn platform_profile(states: &mut PageDataStates, ui: &mut Ui) {
pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut PageDataStates, ui: &mut Ui) { pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut PageDataStates, ui: &mut Ui) {
ui.heading("Bios options"); ui.heading("Bios options");
let slider = egui::Slider::new(&mut states.charge_limit, 20..=100) let slider = egui::Slider::new(&mut states.power_state.charge_limit, 20..=100)
.text("Charging limit") .text("Charging limit")
.step_by(1.0); .step_by(1.0);
if ui.add(slider).drag_released() { if ui.add(slider).drag_released() {
@@ -46,7 +46,7 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut PageDataState
.asus_dbus .asus_dbus
.proxies() .proxies()
.charge() .charge()
.set_charge_control_end_threshold(states.charge_limit as u8) .set_charge_control_end_threshold(states.power_state.charge_limit as u8)
.map_err(|err| { .map_err(|err| {
states.error = Some(err.to_string()); states.error = Some(err.to_string());
}) })