mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
171 lines
4.8 KiB
Rust
171 lines
4.8 KiB
Rust
//! # DBus interface proxy for: `org.asuslinux.Daemon`
|
|
//!
|
|
//! This code was generated by `zbus-xmlgen` `1.0.0` from DBus introspection data.
|
|
//! Source: `Interface '/org/asuslinux/Profile' from service 'org.asuslinux.Daemon' on system bus`.
|
|
//!
|
|
//! You may prefer to adapt it, instead of using it verbatim.
|
|
//!
|
|
//! More information can be found in the
|
|
//! [Writing a client proxy](https://zeenix.pages.freedesktop.org/zbus/client.html)
|
|
//! section of the zbus documentation.
|
|
//!
|
|
//! This DBus object implements
|
|
//! [standard DBus interfaces](https://dbus.freedesktop.org/doc/dbus-specification.html),
|
|
//! (`org.freedesktop.DBus.*`) for which the following zbus proxies can be used:
|
|
//!
|
|
//! * [`zbus::fdo::IntrospectableProxy`]
|
|
//! * [`zbus::fdo::PeerProxy`]
|
|
//! * [`zbus::fdo::PropertiesProxy`]
|
|
//!
|
|
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
use rog_types::profile::ProfileEvent;
|
|
use zbus::{dbus_proxy, Connection, Result};
|
|
|
|
#[dbus_proxy(
|
|
interface = "org.asuslinux.Daemon",
|
|
default_path = "/org/asuslinux/Profile"
|
|
)]
|
|
trait Daemon {
|
|
/// ActiveProfileName method
|
|
fn active_profile_name(&self) -> zbus::Result<String>;
|
|
|
|
/// NextProfile method
|
|
fn next_profile(&self) -> zbus::Result<()>;
|
|
|
|
/// Profile, get the active profile
|
|
fn profile(&self) -> zbus::Result<String>;
|
|
|
|
/// Profiles method
|
|
fn profiles(&self) -> zbus::Result<String>;
|
|
|
|
/// ProfileNames method
|
|
fn profile_names(&self) -> zbus::Result<Vec<String>>;
|
|
|
|
/// Remove method
|
|
fn remove(&self, profile: &str) -> zbus::Result<()>;
|
|
|
|
/// SetProfile method
|
|
fn set_profile(&self, profile: &str) -> zbus::Result<()>;
|
|
|
|
/// SetFanCurve method
|
|
fn set_fan_curve(&self, curve: &str) -> zbus::Result<()>;
|
|
|
|
/// SetFanPreset method
|
|
fn set_fan_preset(&self, preset: u8) -> zbus::Result<()>;
|
|
|
|
/// SetMaxFrequency method
|
|
fn set_max_frequency(&self, percentage: u8) -> zbus::Result<()>;
|
|
|
|
/// SetMinFrequency method
|
|
fn set_min_frequency(&self, percentage: u8) -> zbus::Result<()>;
|
|
|
|
/// SetTurbo method
|
|
fn set_turbo(&self, enable: bool) -> zbus::Result<()>;
|
|
|
|
/// NotifyProfile signal
|
|
#[dbus_proxy(signal)]
|
|
fn notify_profile(&self, profile: &str) -> zbus::Result<()>;
|
|
}
|
|
|
|
pub struct ProfileProxy<'a>(DaemonProxy<'a>);
|
|
|
|
impl<'a> ProfileProxy<'a> {
|
|
#[inline]
|
|
pub fn new(conn: &Connection) -> Result<Self> {
|
|
Ok(ProfileProxy(DaemonProxy::new(&conn)?))
|
|
}
|
|
|
|
pub fn proxy(&self) -> &DaemonProxy<'a> {
|
|
&self.0
|
|
}
|
|
|
|
#[inline]
|
|
pub fn active_profile_name(&self) -> Result<String> {
|
|
self.0.active_profile_name()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn active_profile_data(&self) -> Result<String> {
|
|
self.0.profile()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn all_profile_data(&self) -> Result<String> {
|
|
self.0.profiles()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn next_fan(&self) -> Result<()> {
|
|
self.0.next_profile()
|
|
}
|
|
|
|
/// SetFanCurve, set fan curve for active profile
|
|
#[inline]
|
|
pub fn set_fan_curve(&self, curve: &str) -> zbus::Result<()> {
|
|
self.0.set_fan_curve(curve)
|
|
}
|
|
|
|
/// SetFanPreset, set fan preset for active profile
|
|
#[inline]
|
|
pub fn set_fan_preset(&self, preset: u8) -> zbus::Result<()> {
|
|
self.0.set_fan_preset(preset)
|
|
}
|
|
|
|
/// SetMaxFrequency, set max percentage of frequency for active profile
|
|
#[inline]
|
|
pub fn set_max_frequency(&self, percentage: u8) -> zbus::Result<()> {
|
|
self.0.set_max_frequency(percentage)
|
|
}
|
|
|
|
/// SetMinFrequency, set min percentage of frequency for active profile
|
|
#[inline]
|
|
pub fn set_min_frequency(&self, percentage: u8) -> zbus::Result<()> {
|
|
self.0.set_min_frequency(percentage)
|
|
}
|
|
|
|
/// SetTurbo, set turbo enable for active profile
|
|
#[inline]
|
|
pub fn set_turbo(&self, enable: bool) -> zbus::Result<()> {
|
|
self.0.set_turbo(enable)
|
|
}
|
|
|
|
// TODO: remove
|
|
#[inline]
|
|
pub fn write_fan_mode(&self, level: u8) -> Result<()> {
|
|
self.0
|
|
.set_profile(&serde_json::to_string(&ProfileEvent::ChangeMode(level)).unwrap())
|
|
}
|
|
|
|
// TODO: remove
|
|
#[inline]
|
|
pub fn write_command(&self, cmd: &ProfileEvent) -> Result<()> {
|
|
self.0.set_profile(&serde_json::to_string(cmd).unwrap())
|
|
}
|
|
|
|
#[inline]
|
|
pub fn profile_names(&self) -> Result<Vec<String>> {
|
|
self.0.profile_names()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn remove(&self, profile: &str) -> Result<()> {
|
|
self.0.remove(profile)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn connect_notify_profile(
|
|
&self,
|
|
charge: Arc<Mutex<Option<String>>>,
|
|
) -> zbus::fdo::Result<()> {
|
|
self.0.connect_notify_profile(move |data| {
|
|
if let Ok(mut lock) = charge.lock() {
|
|
*lock = Some(data.to_owned());
|
|
}
|
|
Ok(())
|
|
})
|
|
}
|
|
}
|