mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
ROGCC: Better control of notifs, add panel_od
This commit is contained in:
@@ -33,9 +33,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let anime_notified = Arc::new(AtomicBool::new(false));
|
||||
let profiles_notified = Arc::new(AtomicBool::new(false));
|
||||
let fans_notified = Arc::new(AtomicBool::new(false));
|
||||
let notifs_enabled = Arc::new(AtomicBool::new(config.enable_notifications));
|
||||
// TODO: change this to an error instead of the nested unwraps, then use to
|
||||
// display a bare box app with error message.
|
||||
let states = PageDataStates::new(
|
||||
notifs_enabled.clone(),
|
||||
charge_notified.clone(),
|
||||
bios_notified.clone(),
|
||||
aura_notified.clone(),
|
||||
@@ -54,6 +56,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
anime_notified,
|
||||
profiles_notified,
|
||||
fans_notified,
|
||||
notifs_enabled,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,12 +51,16 @@ pub fn start_notifications(
|
||||
anime_notified: Arc<AtomicBool>,
|
||||
profiles_notified: Arc<AtomicBool>,
|
||||
_fans_notified: Arc<AtomicBool>,
|
||||
notifs_enabled: Arc<AtomicBool>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
|
||||
|
||||
let executor = Executor::new();
|
||||
// BIOS notif
|
||||
let x = last_notification.clone();
|
||||
let last_notif = last_notification.clone();
|
||||
let notifs_enabled1 = notifs_enabled.clone();
|
||||
let bios_notified1 = bios_notified.clone();
|
||||
// TODO: make a macro or generic function or something...
|
||||
executor
|
||||
.spawn(async move {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
@@ -64,10 +68,12 @@ pub fn start_notifications(
|
||||
if let Ok(p) = proxy.receive_notify_post_boot_sound().await {
|
||||
p.for_each(|e| {
|
||||
if let Ok(out) = e.args() {
|
||||
if let Ok(ref mut lock) = x.try_lock() {
|
||||
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||
if let Ok(ref mut lock) = last_notif.try_lock() {
|
||||
notify!(do_post_sound_notif, lock, &out.sound());
|
||||
}
|
||||
bios_notified.store(true, Ordering::SeqCst);
|
||||
}
|
||||
bios_notified1.store(true, Ordering::SeqCst);
|
||||
}
|
||||
future::ready(())
|
||||
})
|
||||
@@ -76,8 +82,23 @@ pub fn start_notifications(
|
||||
})
|
||||
.detach();
|
||||
|
||||
executor
|
||||
.spawn(async move {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let proxy = RogBiosProxy::new(&conn).await.unwrap();
|
||||
if let Ok(p) = proxy.receive_notify_panel_overdrive().await {
|
||||
p.for_each(|_| {
|
||||
bios_notified.store(true, Ordering::SeqCst);
|
||||
future::ready(())
|
||||
})
|
||||
.await;
|
||||
};
|
||||
})
|
||||
.detach();
|
||||
|
||||
// Charge notif
|
||||
let x = last_notification.clone();
|
||||
let last_notif = last_notification.clone();
|
||||
let notifs_enabled1 = notifs_enabled.clone();
|
||||
executor
|
||||
.spawn(async move {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
@@ -85,9 +106,11 @@ pub fn start_notifications(
|
||||
if let Ok(p) = proxy.receive_notify_charge().await {
|
||||
p.for_each(|e| {
|
||||
if let Ok(out) = e.args() {
|
||||
if let Ok(ref mut lock) = x.try_lock() {
|
||||
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||
if let Ok(ref mut lock) = last_notif.try_lock() {
|
||||
notify!(do_charge_notif, lock, &out.limit);
|
||||
}
|
||||
}
|
||||
charge_notified.store(true, Ordering::SeqCst);
|
||||
}
|
||||
future::ready(())
|
||||
@@ -98,7 +121,8 @@ pub fn start_notifications(
|
||||
.detach();
|
||||
|
||||
// Profile notif
|
||||
let x = last_notification.clone();
|
||||
let last_notif = last_notification.clone();
|
||||
let notifs_enabled1 = notifs_enabled.clone();
|
||||
executor
|
||||
.spawn(async move {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
@@ -106,9 +130,11 @@ pub fn start_notifications(
|
||||
if let Ok(p) = proxy.receive_notify_profile().await {
|
||||
p.for_each(|e| {
|
||||
if let Ok(out) = e.args() {
|
||||
if let Ok(ref mut lock) = x.try_lock() {
|
||||
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||
if let Ok(ref mut lock) = last_notif.try_lock() {
|
||||
notify!(do_thermal_notif, lock, &out.profile);
|
||||
}
|
||||
}
|
||||
profiles_notified.store(true, Ordering::SeqCst);
|
||||
}
|
||||
future::ready(())
|
||||
@@ -119,8 +145,9 @@ pub fn start_notifications(
|
||||
.detach();
|
||||
|
||||
// LED notif
|
||||
let x = last_notification.clone();
|
||||
let a = aura_notified.clone();
|
||||
let last_notif = last_notification.clone();
|
||||
let aura_notif = aura_notified.clone();
|
||||
let notifs_enabled1 = notifs_enabled.clone();
|
||||
executor
|
||||
.spawn(async move {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
@@ -128,10 +155,12 @@ pub fn start_notifications(
|
||||
if let Ok(p) = proxy.receive_notify_led().await {
|
||||
p.for_each(|e| {
|
||||
if let Ok(out) = e.args() {
|
||||
if let Ok(ref mut lock) = x.try_lock() {
|
||||
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||
if let Ok(ref mut lock) = last_notif.try_lock() {
|
||||
notify!(do_led_notif, lock, &out.data);
|
||||
}
|
||||
a.store(true, Ordering::SeqCst);
|
||||
}
|
||||
aura_notif.store(true, Ordering::SeqCst);
|
||||
}
|
||||
future::ready(())
|
||||
})
|
||||
@@ -145,13 +174,8 @@ pub fn start_notifications(
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let proxy = LedProxy::new(&conn).await.unwrap();
|
||||
if let Ok(p) = proxy.receive_notify_power_states().await {
|
||||
p.for_each(|e| {
|
||||
if let Ok(_out) = e.args() {
|
||||
// if let Ok(ref mut lock) = last_notification.try_lock() {
|
||||
// notify!(do_led_notif, lock, &out.data);
|
||||
// }
|
||||
p.for_each(|_| {
|
||||
aura_notified.store(true, Ordering::SeqCst);
|
||||
}
|
||||
future::ready(())
|
||||
})
|
||||
.await;
|
||||
@@ -164,13 +188,8 @@ pub fn start_notifications(
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let proxy = AnimeProxy::new(&conn).await.unwrap();
|
||||
if let Ok(p) = proxy.receive_power_states().await {
|
||||
p.for_each(|e| {
|
||||
if let Ok(_out) = e.args() {
|
||||
// if let Ok(ref mut lock) = last_notification.try_lock() {
|
||||
// notify!(do_led_notif, lock, &out.data);
|
||||
// }
|
||||
p.for_each(|_| {
|
||||
anime_notified.store(true, Ordering::SeqCst);
|
||||
}
|
||||
future::ready(())
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -218,6 +218,7 @@ impl AnimeState {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PageDataStates {
|
||||
pub notifs_enabled: Arc<AtomicBool>,
|
||||
pub was_notified: Arc<AtomicBool>,
|
||||
/// Because much of the app state here is the same as `RogBiosSupportedFunctions`
|
||||
/// we can re-use that structure.
|
||||
@@ -232,6 +233,7 @@ pub struct PageDataStates {
|
||||
|
||||
impl PageDataStates {
|
||||
pub fn new(
|
||||
notifs_enabled: Arc<AtomicBool>,
|
||||
charge_notified: Arc<AtomicBool>,
|
||||
bios_notified: Arc<AtomicBool>,
|
||||
aura_notified: Arc<AtomicBool>,
|
||||
@@ -242,6 +244,7 @@ impl PageDataStates {
|
||||
dbus: &RogDbusClientBlocking,
|
||||
) -> Self {
|
||||
Self {
|
||||
notifs_enabled,
|
||||
was_notified: charge_notified,
|
||||
charge_limit: dbus.proxies().charge().limit().unwrap(),
|
||||
bios: BiosState::new(bios_notified, supported, dbus),
|
||||
|
||||
@@ -59,6 +59,24 @@ impl<'a> RogApp<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
if supported.rog_bios_ctrl.post_sound {
|
||||
if ui
|
||||
.add(egui::Checkbox::new(
|
||||
&mut states.bios.panel_overdrive,
|
||||
"Panel overdrive",
|
||||
))
|
||||
.changed()
|
||||
{
|
||||
dbus.proxies()
|
||||
.rog_bios()
|
||||
.set_panel_overdrive(states.bios.panel_overdrive)
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
if supported.rog_bios_ctrl.dedicated_gfx {
|
||||
if ui
|
||||
.add(egui::Checkbox::new(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use crate::RogApp;
|
||||
|
||||
impl<'a> RogApp<'a> {
|
||||
@@ -13,32 +15,19 @@ impl<'a> RogApp<'a> {
|
||||
}
|
||||
});
|
||||
ui.menu_button("Settings", |ui| {
|
||||
let (mut in_bg, mut hidden) =
|
||||
{ (config.run_in_background, config.startup_in_background) };
|
||||
if ui.checkbox(&mut in_bg, "Run in Background").clicked() {
|
||||
config.run_in_background = in_bg;
|
||||
config
|
||||
.save()
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
if ui.checkbox(&mut hidden, "Startup Hidden").clicked() {
|
||||
config.startup_in_background = in_bg;
|
||||
config
|
||||
.save()
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
if ui
|
||||
.checkbox(&mut config.run_in_background, "Run in Background")
|
||||
.clicked()
|
||||
|| ui
|
||||
.checkbox(&mut config.startup_in_background, "Startup Hidden")
|
||||
.clicked()
|
||||
|| ui
|
||||
.checkbox(&mut config.enable_notifications, "Enable Notifications")
|
||||
.clicked()
|
||||
{
|
||||
config.enable_notifications = in_bg;
|
||||
// TODO: set an atomicbool used in the notif thread
|
||||
states
|
||||
.notifs_enabled
|
||||
.store(config.enable_notifications, Ordering::SeqCst);
|
||||
config
|
||||
.save()
|
||||
.map_err(|err| {
|
||||
|
||||
Reference in New Issue
Block a user