dbus: send/recv notifications for bios options

This commit is contained in:
Luke D. Jones
2021-05-26 21:17:45 +12:00
parent 36bba75c50
commit f0e5bb4ad1
4 changed files with 25 additions and 14 deletions

2
Cargo.lock generated
View File

@@ -887,7 +887,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_dbus" name = "rog_dbus"
version = "3.4.0" version = "3.5.0"
dependencies = [ dependencies = [
"rog_anime", "rog_anime",
"rog_aura", "rog_aura",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "rog_dbus" name = "rog_dbus"
version = "3.4.0" version = "3.5.0"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]

View File

@@ -54,6 +54,8 @@ impl<'a> DbusProxies<'a> {
recv.receive_for(self.charge.proxy()); recv.receive_for(self.charge.proxy());
recv.receive_for(self.gfx.proxy()); recv.receive_for(self.gfx.proxy());
recv.receive_for(self.profile.proxy()); recv.receive_for(self.profile.proxy());
recv.receive_for(self.rog_bios.proxy());
recv.receive_for(self.supported.proxy());
recv recv
} }
@@ -95,6 +97,8 @@ pub struct Signals {
pub led_power_state: Receiver<LedPowerStates>, pub led_power_state: Receiver<LedPowerStates>,
pub anime_power_state: Receiver<AnimePowerStates>, pub anime_power_state: Receiver<AnimePowerStates>,
pub charge: Receiver<u8>, pub charge: Receiver<u8>,
pub bios_gsync: Receiver<bool>,
pub bios_sound: Receiver<bool>,
} }
impl Signals { impl Signals {
@@ -136,6 +140,16 @@ impl Signals {
proxies.anime.connect_notify_power_states(tx)?; proxies.anime.connect_notify_power_states(tx)?;
rx rx
}, },
bios_gsync: {
let (tx, rx) = channel();
proxies.rog_bios.connect_notify_dedicated_graphic_mode(tx)?;
rx
},
bios_sound: {
let (tx, rx) = channel();
proxies.rog_bios.connect_notify_post_boot_sound(tx)?;
rx
},
}) })
} }
} }
@@ -170,6 +184,8 @@ impl<'a> RogDbusClient<'a> {
recv.receive_for(self.proxies.charge.proxy()); recv.receive_for(self.proxies.charge.proxy());
recv.receive_for(self.proxies.gfx.proxy()); recv.receive_for(self.proxies.gfx.proxy());
recv.receive_for(self.proxies.profile.proxy()); recv.receive_for(self.proxies.profile.proxy());
recv.receive_for(self.proxies.rog_bios.proxy());
recv.receive_for(self.proxies.supported.proxy());
recv recv
} }

View File

@@ -19,7 +19,7 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use std::sync::{Arc, Mutex}; use std::sync::{mpsc::Sender};
use zbus::{dbus_proxy, Connection, Result}; use zbus::{dbus_proxy, Connection, Result};
@@ -84,25 +84,20 @@ impl<'a> RogBiosProxy<'a> {
#[inline] #[inline]
pub fn connect_notify_dedicated_graphic_mode( pub fn connect_notify_dedicated_graphic_mode(
&self, &self,
dedicated: Arc<Mutex<Option<bool>>>, send: Sender<bool>,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.0.connect_notify_dedicated_graphic_mode(move |data| { self.0.connect_notify_dedicated_graphic_mode(move |data| {
if let Ok(mut lock) = dedicated.lock() { send.send(data)
*lock = Some(data); .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?;
}
Ok(()) Ok(())
}) })
} }
#[inline] #[inline]
pub fn connect_notify_post_boot_sound( pub fn connect_notify_post_boot_sound(&self, send: Sender<bool>) -> zbus::fdo::Result<()> {
&self,
sound: Arc<Mutex<Option<bool>>>,
) -> zbus::fdo::Result<()> {
self.0.connect_notify_post_boot_sound(move |data| { self.0.connect_notify_post_boot_sound(move |data| {
if let Ok(mut lock) = sound.lock() { send.send(data)
*lock = Some(data); .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?;
}
Ok(()) Ok(())
}) })
} }