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 anime_notified = Arc::new(AtomicBool::new(false));
|
||||||
let profiles_notified = Arc::new(AtomicBool::new(false));
|
let profiles_notified = Arc::new(AtomicBool::new(false));
|
||||||
let fans_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
|
// TODO: change this to an error instead of the nested unwraps, then use to
|
||||||
// display a bare box app with error message.
|
// display a bare box app with error message.
|
||||||
let states = PageDataStates::new(
|
let states = PageDataStates::new(
|
||||||
|
notifs_enabled.clone(),
|
||||||
charge_notified.clone(),
|
charge_notified.clone(),
|
||||||
bios_notified.clone(),
|
bios_notified.clone(),
|
||||||
aura_notified.clone(),
|
aura_notified.clone(),
|
||||||
@@ -54,6 +56,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
anime_notified,
|
anime_notified,
|
||||||
profiles_notified,
|
profiles_notified,
|
||||||
fans_notified,
|
fans_notified,
|
||||||
|
notifs_enabled,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,12 +51,16 @@ pub fn start_notifications(
|
|||||||
anime_notified: Arc<AtomicBool>,
|
anime_notified: Arc<AtomicBool>,
|
||||||
profiles_notified: Arc<AtomicBool>,
|
profiles_notified: Arc<AtomicBool>,
|
||||||
_fans_notified: Arc<AtomicBool>,
|
_fans_notified: Arc<AtomicBool>,
|
||||||
|
notifs_enabled: Arc<AtomicBool>,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
|
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
|
||||||
|
|
||||||
let executor = Executor::new();
|
let executor = Executor::new();
|
||||||
// BIOS notif
|
// 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
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
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 {
|
if let Ok(p) = proxy.receive_notify_post_boot_sound().await {
|
||||||
p.for_each(|e| {
|
p.for_each(|e| {
|
||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
if let Ok(ref mut lock) = x.try_lock() {
|
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||||
notify!(do_post_sound_notif, lock, &out.sound());
|
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(())
|
future::ready(())
|
||||||
})
|
})
|
||||||
@@ -76,8 +82,23 @@ pub fn start_notifications(
|
|||||||
})
|
})
|
||||||
.detach();
|
.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
|
// Charge notif
|
||||||
let x = last_notification.clone();
|
let last_notif = last_notification.clone();
|
||||||
|
let notifs_enabled1 = notifs_enabled.clone();
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
@@ -85,8 +106,10 @@ pub fn start_notifications(
|
|||||||
if let Ok(p) = proxy.receive_notify_charge().await {
|
if let Ok(p) = proxy.receive_notify_charge().await {
|
||||||
p.for_each(|e| {
|
p.for_each(|e| {
|
||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
if let Ok(ref mut lock) = x.try_lock() {
|
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||||
notify!(do_charge_notif, lock, &out.limit);
|
if let Ok(ref mut lock) = last_notif.try_lock() {
|
||||||
|
notify!(do_charge_notif, lock, &out.limit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
charge_notified.store(true, Ordering::SeqCst);
|
charge_notified.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
@@ -98,7 +121,8 @@ pub fn start_notifications(
|
|||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
// Profile notif
|
// Profile notif
|
||||||
let x = last_notification.clone();
|
let last_notif = last_notification.clone();
|
||||||
|
let notifs_enabled1 = notifs_enabled.clone();
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
@@ -106,8 +130,10 @@ pub fn start_notifications(
|
|||||||
if let Ok(p) = proxy.receive_notify_profile().await {
|
if let Ok(p) = proxy.receive_notify_profile().await {
|
||||||
p.for_each(|e| {
|
p.for_each(|e| {
|
||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
if let Ok(ref mut lock) = x.try_lock() {
|
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||||
notify!(do_thermal_notif, lock, &out.profile);
|
if let Ok(ref mut lock) = last_notif.try_lock() {
|
||||||
|
notify!(do_thermal_notif, lock, &out.profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
profiles_notified.store(true, Ordering::SeqCst);
|
profiles_notified.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
@@ -119,8 +145,9 @@ pub fn start_notifications(
|
|||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
// LED notif
|
// LED notif
|
||||||
let x = last_notification.clone();
|
let last_notif = last_notification.clone();
|
||||||
let a = aura_notified.clone();
|
let aura_notif = aura_notified.clone();
|
||||||
|
let notifs_enabled1 = notifs_enabled.clone();
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
@@ -128,10 +155,12 @@ pub fn start_notifications(
|
|||||||
if let Ok(p) = proxy.receive_notify_led().await {
|
if let Ok(p) = proxy.receive_notify_led().await {
|
||||||
p.for_each(|e| {
|
p.for_each(|e| {
|
||||||
if let Ok(out) = e.args() {
|
if let Ok(out) = e.args() {
|
||||||
if let Ok(ref mut lock) = x.try_lock() {
|
if notifs_enabled1.load(Ordering::SeqCst) {
|
||||||
notify!(do_led_notif, lock, &out.data);
|
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(())
|
future::ready(())
|
||||||
})
|
})
|
||||||
@@ -145,13 +174,8 @@ pub fn start_notifications(
|
|||||||
let conn = zbus::Connection::system().await.unwrap();
|
let conn = zbus::Connection::system().await.unwrap();
|
||||||
let proxy = LedProxy::new(&conn).await.unwrap();
|
let proxy = LedProxy::new(&conn).await.unwrap();
|
||||||
if let Ok(p) = proxy.receive_notify_power_states().await {
|
if let Ok(p) = proxy.receive_notify_power_states().await {
|
||||||
p.for_each(|e| {
|
p.for_each(|_| {
|
||||||
if let Ok(_out) = e.args() {
|
aura_notified.store(true, Ordering::SeqCst);
|
||||||
// if let Ok(ref mut lock) = last_notification.try_lock() {
|
|
||||||
// notify!(do_led_notif, lock, &out.data);
|
|
||||||
// }
|
|
||||||
aura_notified.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
future::ready(())
|
future::ready(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
@@ -164,13 +188,8 @@ pub fn start_notifications(
|
|||||||
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(|e| {
|
p.for_each(|_| {
|
||||||
if let Ok(_out) = e.args() {
|
anime_notified.store(true, Ordering::SeqCst);
|
||||||
// if let Ok(ref mut lock) = last_notification.try_lock() {
|
|
||||||
// notify!(do_led_notif, lock, &out.data);
|
|
||||||
// }
|
|
||||||
anime_notified.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
future::ready(())
|
future::ready(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ impl AnimeState {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PageDataStates {
|
pub struct PageDataStates {
|
||||||
|
pub notifs_enabled: Arc<AtomicBool>,
|
||||||
pub was_notified: Arc<AtomicBool>,
|
pub was_notified: Arc<AtomicBool>,
|
||||||
/// 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.
|
||||||
@@ -232,6 +233,7 @@ pub struct PageDataStates {
|
|||||||
|
|
||||||
impl PageDataStates {
|
impl PageDataStates {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
notifs_enabled: Arc<AtomicBool>,
|
||||||
charge_notified: Arc<AtomicBool>,
|
charge_notified: Arc<AtomicBool>,
|
||||||
bios_notified: Arc<AtomicBool>,
|
bios_notified: Arc<AtomicBool>,
|
||||||
aura_notified: Arc<AtomicBool>,
|
aura_notified: Arc<AtomicBool>,
|
||||||
@@ -242,6 +244,7 @@ impl PageDataStates {
|
|||||||
dbus: &RogDbusClientBlocking,
|
dbus: &RogDbusClientBlocking,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
notifs_enabled,
|
||||||
was_notified: charge_notified,
|
was_notified: charge_notified,
|
||||||
charge_limit: dbus.proxies().charge().limit().unwrap(),
|
charge_limit: dbus.proxies().charge().limit().unwrap(),
|
||||||
bios: BiosState::new(bios_notified, supported, dbus),
|
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 supported.rog_bios_ctrl.dedicated_gfx {
|
||||||
if ui
|
if ui
|
||||||
.add(egui::Checkbox::new(
|
.add(egui::Checkbox::new(
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
use crate::RogApp;
|
use crate::RogApp;
|
||||||
|
|
||||||
impl<'a> RogApp<'a> {
|
impl<'a> RogApp<'a> {
|
||||||
@@ -13,32 +15,19 @@ impl<'a> RogApp<'a> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.menu_button("Settings", |ui| {
|
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
|
if ui
|
||||||
.checkbox(&mut config.enable_notifications, "Enable Notifications")
|
.checkbox(&mut config.run_in_background, "Run in Background")
|
||||||
.clicked()
|
.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;
|
states
|
||||||
// TODO: set an atomicbool used in the notif thread
|
.notifs_enabled
|
||||||
|
.store(config.enable_notifications, Ordering::SeqCst);
|
||||||
config
|
config
|
||||||
.save()
|
.save()
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|||||||
Reference in New Issue
Block a user