asusd: cleanup platform notifs, prevent more duplications

This commit is contained in:
Luke D. Jones
2023-07-01 12:30:51 +12:00
parent 83455a5ba3
commit 2a8ca0a39a
3 changed files with 14 additions and 15 deletions

View File

@@ -182,7 +182,13 @@ impl CtrlPlatform {
err err
}) })
.ok(); .ok();
Self::notify_post_boot_sound(&ctxt, on).await.ok(); Self::notify_post_boot_sound(&ctxt, on)
.await
.map_err(|err| {
warn!("CtrlRogBios: set_post_boot_sound {}", err);
err
})
.ok();
} }
fn post_boot_sound(&self) -> i8 { fn post_boot_sound(&self) -> i8 {
@@ -197,18 +203,13 @@ impl CtrlPlatform {
#[dbus_interface(signal)] #[dbus_interface(signal)]
async fn notify_post_boot_sound(ctxt: &SignalContext<'_>, on: bool) -> zbus::Result<()> {} async fn notify_post_boot_sound(ctxt: &SignalContext<'_>, on: bool) -> zbus::Result<()> {}
async fn set_panel_od( async fn set_panel_od(&mut self, overdrive: bool) {
&mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
overdrive: bool,
) {
match self.platform.set_panel_od(overdrive) { match self.platform.set_panel_od(overdrive) {
Ok(_) => { Ok(_) => {
if let Some(mut lock) = self.config.try_lock() { if let Some(mut lock) = self.config.try_lock() {
lock.panel_od = overdrive; lock.panel_od = overdrive;
lock.write(); lock.write();
} }
Self::notify_panel_od(&ctxt, overdrive).await.ok();
} }
Err(err) => warn!("CtrlRogBios: set_panel_overdrive {}", err), Err(err) => warn!("CtrlRogBios: set_panel_overdrive {}", err),
}; };
@@ -230,18 +231,13 @@ impl CtrlPlatform {
async fn notify_panel_od(signal_ctxt: &SignalContext<'_>, overdrive: bool) -> zbus::Result<()> { async fn notify_panel_od(signal_ctxt: &SignalContext<'_>, overdrive: bool) -> zbus::Result<()> {
} }
async fn set_mini_led_mode( async fn set_mini_led_mode(&mut self, on: bool) {
&mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
on: bool,
) {
match self.platform.set_mini_led_mode(on) { match self.platform.set_mini_led_mode(on) {
Ok(_) => { Ok(_) => {
if let Some(mut lock) = self.config.try_lock() { if let Some(mut lock) = self.config.try_lock() {
lock.mini_led_mode = on; lock.mini_led_mode = on;
lock.write(); lock.write();
} }
Self::notify_mini_led_mode(&ctxt, on).await.ok();
} }
Err(err) => warn!("CtrlRogBios: set_mini_led_mode {}", err), Err(err) => warn!("CtrlRogBios: set_mini_led_mode {}", err),
}; };
@@ -348,6 +344,8 @@ impl CtrlPlatform {
task_watch_item!(dgpu_disable platform); task_watch_item!(dgpu_disable platform);
task_watch_item!(egpu_enable platform); task_watch_item!(egpu_enable platform);
task_watch_item!(mini_led_mode platform);
// NOTE: see note further below // NOTE: see note further below
// task_watch_item!(gpu_mux_mode platform); // task_watch_item!(gpu_mux_mode platform);
} }
@@ -402,6 +400,7 @@ impl CtrlTask for CtrlPlatform {
self.watch_panel_od(signal_ctxt.clone()).await?; self.watch_panel_od(signal_ctxt.clone()).await?;
self.watch_dgpu_disable(signal_ctxt.clone()).await?; self.watch_dgpu_disable(signal_ctxt.clone()).await?;
self.watch_egpu_enable(signal_ctxt.clone()).await?; self.watch_egpu_enable(signal_ctxt.clone()).await?;
self.watch_mini_led_mode(signal_ctxt.clone()).await?;
// NOTE: Can't have this as a watch because on a write to it, it reverts back to // NOTE: Can't have this as a watch because on a write to it, it reverts back to
// booted-with value as it does not actually change until reboot. // booted-with value as it does not actually change until reboot.
// self.watch_gpu_mux_mode(signal_ctxt.clone()).await?; // self.watch_gpu_mux_mode(signal_ctxt.clone()).await?;

View File

@@ -1,7 +1,7 @@
{ {
"name": "asusctl-gex", "name": "asusctl-gex",
"description": "asusctl-gex is a frontend for some functionalities of asusctl and supergfxctl that were born inside the asus-linux.org community.\n\nasusctl is required.\n\nTo learn more about it, please have a look at:\nhttps://gitlab.com/asus-linux/asusctl\nhttps://gitlab.com/asus-linux/asusctl-gex\n\nhttps://asus-linux.org/", "description": "asusctl-gex is a frontend for some functionalities of asusctl and supergfxctl that were born inside the asus-linux.org community.\n\nasusctl is required.\n\nTo learn more about it, please have a look at:\nhttps://gitlab.com/asus-linux/asusctl\nhttps://gitlab.com/asus-linux/asusctl-gex\n\nhttps://asus-linux.org/",
"uuid": "asusctl-gex-dev@asus-linux.org", "uuid": "asusctl-gex@asus-linux.org",
"uuid-dev": "asusctl-gex-dev@asus-linux.org", "uuid-dev": "asusctl-gex-dev@asus-linux.org",
"settings-schema": "org.gnome.shell.extensions.asusctl-gex", "settings-schema": "org.gnome.shell.extensions.asusctl-gex",
"version": "4.3.2", "version": "4.3.2",

View File

@@ -23,7 +23,7 @@ macro_rules! watch_attr {
path.push($attr_name); path.push($attr_name);
if let Some(path) = path.to_str() { if let Some(path) = path.to_str() {
let inotify = inotify::Inotify::init()?; let inotify = inotify::Inotify::init()?;
inotify.watches().add(path, inotify::WatchMask::CLOSE_WRITE | inotify::WatchMask::MODIFY) inotify.watches().add(path, inotify::WatchMask::MODIFY)
.map_err(|e| { .map_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound { if e.kind() == std::io::ErrorKind::NotFound {
PlatformError::AttrNotFound(format!("{}", $attr_name)) PlatformError::AttrNotFound(format!("{}", $attr_name))