More updating to zbus 4.0.1

This commit is contained in:
Luke D. Jones
2024-02-22 23:49:35 +13:00
parent a44145f487
commit 8e4b7d53f4
50 changed files with 3151 additions and 2932 deletions

View File

@@ -10,7 +10,7 @@ use rog_anime::usb::{
};
use rog_anime::{Animations, AnimeDataBuffer, DeviceState};
use zbus::export::futures_util::lock::Mutex;
use zbus::{dbus_interface, CacheProperties, Connection, SignalContext};
use zbus::{interface, CacheProperties, Connection, SignalContext};
use super::CtrlAnime;
use crate::error::RogError;
@@ -43,7 +43,7 @@ impl crate::ZbusRun for CtrlAnimeZbus {
// None of these calls can be guarnateed to succeed unless we loop until okay
// If the try_lock *does* succeed then any other thread trying to lock will not
// grab it until we finish.
#[dbus_interface(name = "org.asuslinux.Daemon")]
#[interface(name = "org.asuslinux.Daemon")]
impl CtrlAnimeZbus {
/// Writes a data stream of length. Will force system thread to exit until
/// it is restarted
@@ -58,14 +58,14 @@ impl CtrlAnimeZbus {
}
/// Set base brightness level
#[dbus_interface(property)]
#[zbus(property)]
async fn brightness(&self) -> Brightness {
let lock = self.0.lock().await;
lock.config.display_brightness
}
/// Set base brightness level
#[dbus_interface(property)]
#[zbus(property)]
async fn set_brightness(&self, brightness: Brightness) {
let mut lock = self.0.lock().await;
lock.node
@@ -86,7 +86,7 @@ impl CtrlAnimeZbus {
lock.config.write();
}
#[dbus_interface(property)]
#[zbus(property)]
async fn builtins_enabled(&self) -> bool {
let lock = self.0.lock().await;
lock.config.builtin_anims_enabled
@@ -94,7 +94,7 @@ impl CtrlAnimeZbus {
/// Enable the builtin animations or not. This is quivalent to "Powersave
/// animations" in Armory crate
#[dbus_interface(property)]
#[zbus(property)]
async fn set_builtins_enabled(&self, enabled: bool) {
let mut lock = self.0.lock().await;
lock.node
@@ -125,14 +125,14 @@ impl CtrlAnimeZbus {
}
}
#[dbus_interface(property)]
#[zbus(property)]
async fn builtin_animations(&self) -> Animations {
let lock = self.0.lock().await;
lock.config.builtin_anims
}
/// Set which builtin animation is used for each stage
#[dbus_interface(property)]
#[zbus(property)]
async fn set_builtin_animations(&self, settings: Animations) {
let mut lock = self.0.lock().await;
lock.node
@@ -157,14 +157,14 @@ impl CtrlAnimeZbus {
lock.config.write();
}
#[dbus_interface(property)]
#[zbus(property)]
async fn enable_display(&self) -> bool {
let lock = self.0.lock().await;
lock.config.display_enabled
}
/// Set whether the AniMe is enabled at all
#[dbus_interface(property)]
#[zbus(property)]
async fn set_enable_display(&self, enabled: bool) {
let mut lock = self.0.lock().await;
lock.node
@@ -177,14 +177,14 @@ impl CtrlAnimeZbus {
lock.config.write();
}
#[dbus_interface(property)]
#[zbus(property)]
async fn off_when_unplugged(&self) -> bool {
let lock = self.0.lock().await;
lock.config.off_when_unplugged
}
/// Set if to turn the AniMe Matrix off when external power is unplugged
#[dbus_interface(property)]
#[zbus(property)]
async fn set_off_when_unplugged(&self, enabled: bool) {
let mut lock = self.0.lock().await;
let manager = get_logind_manager().await;
@@ -201,28 +201,28 @@ impl CtrlAnimeZbus {
lock.config.write();
}
#[dbus_interface(property)]
#[zbus(property)]
async fn off_when_suspended(&self) -> bool {
let lock = self.0.lock().await;
lock.config.off_when_suspended
}
/// Set if to turn the AniMe Matrix off when the laptop is suspended
#[dbus_interface(property)]
#[zbus(property)]
async fn set_off_when_suspended(&self, enabled: bool) {
let mut lock = self.0.lock().await;
lock.config.off_when_suspended = enabled;
lock.config.write();
}
#[dbus_interface(property)]
#[zbus(property)]
async fn off_when_lid_closed(&self) -> bool {
let lock = self.0.lock().await;
lock.config.off_when_lid_closed
}
/// Set if to turn the AniMe Matrix off when the lid is closed
#[dbus_interface(property)]
#[zbus(property)]
async fn set_off_when_lid_closed(&self, enabled: bool) {
let mut lock = self.0.lock().await;
let manager = get_logind_manager().await;
@@ -250,7 +250,7 @@ impl CtrlAnimeZbus {
}
/// Get the device state as stored by asusd
// #[dbus_interface(property)]
// #[zbus(property)]
async fn device_state(&self) -> DeviceState {
let lock = self.0.lock().await;
DeviceState::from(&lock.config)

View File

@@ -10,7 +10,7 @@ use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
use zbus::export::futures_util::StreamExt;
use zbus::fdo::Error as ZbErr;
use zbus::{dbus_interface, Connection, SignalContext};
use zbus::{interface, Connection, SignalContext};
use super::controller::CtrlKbdLed;
use crate::error::RogError;
@@ -41,31 +41,31 @@ impl crate::ZbusRun for CtrlAuraZbus {
/// The main interface for changing, reading, or notfying signals
///
/// LED commands are split between Brightness, Modes, Per-Key
#[dbus_interface(name = "org.asuslinux.Daemon")]
#[interface(name = "org.asuslinux.Daemon")]
impl CtrlAuraZbus {
/// Return the device type for this Aura keyboard
#[dbus_interface(property)]
#[zbus(property)]
async fn device_type(&self) -> AuraDevice {
let ctrl = self.0.lock().await;
ctrl.led_prod
}
/// Return the current LED brightness
#[dbus_interface(property)]
#[zbus(property)]
async fn brightness(&self) -> Result<LedBrightness, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.sysfs_node.get_brightness().map(|n| n.into())?)
}
/// Set the keyboard brightness level (0-3)
#[dbus_interface(property)]
#[zbus(property)]
async fn set_brightness(&mut self, brightness: LedBrightness) -> Result<(), ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.sysfs_node.set_brightness(brightness.into())?)
}
/// Total levels of brightness available
#[dbus_interface(property)]
#[zbus(property)]
async fn supported_brightness(&self) -> Vec<LedBrightness> {
vec![
LedBrightness::Off,
@@ -76,26 +76,26 @@ impl CtrlAuraZbus {
}
/// The total available modes
#[dbus_interface(property)]
#[zbus(property)]
async fn supported_basic_modes(&self) -> Result<Vec<AuraModeNum>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.config.builtins.keys().cloned().collect())
}
#[dbus_interface(property)]
#[zbus(property)]
async fn supported_basic_zones(&self) -> Result<Vec<AuraZone>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.supported_data.basic_zones.clone())
}
#[dbus_interface(property)]
#[zbus(property)]
async fn supported_power_zones(&self) -> Result<Vec<PowerZones>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.supported_data.power_zones.clone())
}
/// The current mode data
#[dbus_interface(property)]
#[zbus(property)]
async fn led_mode(&self) -> Result<AuraModeNum, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.config.current_mode)
@@ -105,7 +105,7 @@ impl CtrlAuraZbus {
///
/// On success the aura config file is read to refresh cached values, then
/// the effect is stored and config written to disk.
#[dbus_interface(property)]
#[zbus(property)]
async fn set_led_mode(&mut self, num: AuraModeNum) -> Result<(), ZbErr> {
let mut ctrl = self.0.lock().await;
ctrl.config.current_mode = num;
@@ -120,7 +120,7 @@ impl CtrlAuraZbus {
}
/// The current mode data
#[dbus_interface(property)]
#[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
let ctrl = self.0.lock().await;
let mode = ctrl.config.current_mode;
@@ -134,7 +134,7 @@ impl CtrlAuraZbus {
///
/// On success the aura config file is read to refresh cached values, then
/// the effect is stored and config written to disk.
#[dbus_interface(property)]
#[zbus(property)]
async fn set_led_mode_data(&mut self, effect: AuraEffect) -> Result<(), ZbErr> {
let mut ctrl = self.0.lock().await;
if !ctrl.supported_data.basic_modes.contains(&effect.mode)
@@ -164,7 +164,7 @@ impl CtrlAuraZbus {
}
// As property doesn't work for AuraPowerDev (complexity of serialization?)
#[dbus_interface(property)]
#[zbus(property)]
async fn led_power(&self) -> AuraPowerDev {
let ctrl = self.0.lock().await;
AuraPowerDev::from(&ctrl.config.enabled)
@@ -174,7 +174,7 @@ impl CtrlAuraZbus {
/// `enabled` sets if the sent array should be disabled or enabled
///
/// For Modern ROG devices the "enabled" flag is ignored.
#[dbus_interface(property)]
#[zbus(property)]
async fn set_led_power(&mut self, options: (AuraPowerDev, bool)) -> Result<(), ZbErr> {
let enabled = options.1;
let options = options.0;

View File

@@ -10,7 +10,7 @@ use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
use serde_derive::{Deserialize, Serialize};
use tokio::sync::Mutex;
use zbus::{dbus_interface, Connection, SignalContext};
use zbus::{interface, Connection, SignalContext};
use crate::error::RogError;
use crate::{CtrlTask, CONFIG_PATH_BASE};
@@ -123,7 +123,7 @@ impl CtrlFanCurveZbus {
}
}
#[dbus_interface(name = "org.asuslinux.Daemon")]
#[interface(name = "org.asuslinux.Daemon")]
impl CtrlFanCurveZbus {
/// Set all fan curves for a profile to enabled status. Will also activate a
/// fan curve if in the same profile mode

View File

@@ -9,7 +9,7 @@ use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex;
use zbus::fdo::Error as FdoErr;
use zbus::{dbus_interface, Connection, ObjectServer, SignalContext};
use zbus::{interface, Connection, ObjectServer, SignalContext};
use crate::config::Config;
use crate::ctrl_anime::trait_impls::{CtrlAnimeZbus, ANIME_ZBUS_NAME, ANIME_ZBUS_PATH};
@@ -285,7 +285,7 @@ impl CtrlPlatform {
}
}
#[dbus_interface(name = "org.asuslinux.Daemon")]
#[interface(name = "org.asuslinux.Daemon")]
impl CtrlPlatform {
/// Returns a list of property names that this system supports
async fn supported_properties(&self) -> Vec<Properties> {
@@ -372,13 +372,13 @@ impl CtrlPlatform {
interfaces
}
#[dbus_interface(property)]
#[zbus(property)]
fn charge_control_end_threshold(&self) -> Result<u8, FdoErr> {
let limit = self.power.get_charge_control_end_threshold()?;
Ok(limit)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_charge_control_end_threshold(&mut self, limit: u8) -> Result<(), FdoErr> {
if !(20..=100).contains(&limit) {
return Err(RogError::ChargeLimit(limit))?;
@@ -388,7 +388,7 @@ impl CtrlPlatform {
Ok(())
}
#[dbus_interface(property)]
#[zbus(property)]
fn gpu_mux_mode(&self) -> Result<u8, FdoErr> {
self.platform.get_gpu_mux_mode().map_err(|err| {
warn!("RogPlatform: set_gpu_mux_mode {err}");
@@ -396,7 +396,7 @@ impl CtrlPlatform {
})
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_gpu_mux_mode(&mut self, mode: u8) -> Result<(), FdoErr> {
if self.platform.has_gpu_mux_mode() {
self.set_gfx_mode(mode.into()).map_err(|err| {
@@ -439,13 +439,13 @@ impl CtrlPlatform {
}
}
#[dbus_interface(property)]
#[zbus(property)]
fn throttle_thermal_policy(&self) -> Result<ThrottlePolicy, FdoErr> {
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into())
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
// TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() {
@@ -465,23 +465,23 @@ impl CtrlPlatform {
}
}
#[dbus_interface(property)]
#[zbus(property)]
async fn throttle_policy_linked_epp(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.throttle_policy_linked_epp)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_policy_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> {
self.config.lock().await.throttle_policy_linked_epp = linked;
Ok(())
}
#[dbus_interface(property)]
#[zbus(property)]
async fn throttle_policy_on_battery(&self) -> Result<ThrottlePolicy, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_battery)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_policy_on_battery(
&mut self,
policy: ThrottlePolicy,
@@ -491,12 +491,12 @@ impl CtrlPlatform {
Ok(())
}
#[dbus_interface(property)]
#[zbus(property)]
async fn throttle_policy_on_ac(&self) -> Result<ThrottlePolicy, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_ac)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_policy_on_ac(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_ac = policy;
self.set_throttle_thermal_policy(policy).await?;
@@ -505,12 +505,12 @@ impl CtrlPlatform {
/// The energy_performance_preference for the quiet throttle/platform
/// profile
#[dbus_interface(property)]
#[zbus(property)]
async fn throttle_quiet_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_quiet_epp)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_quiet_epp = epp;
@@ -520,12 +520,12 @@ impl CtrlPlatform {
/// The energy_performance_preference for the balanced throttle/platform
/// profile
#[dbus_interface(property)]
#[zbus(property)]
async fn throttle_balanced_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_balanced_epp)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_balanced_epp = epp;
@@ -535,12 +535,12 @@ impl CtrlPlatform {
/// The energy_performance_preference for the performance throttle/platform
/// profile
#[dbus_interface(property)]
#[zbus(property)]
async fn throttle_performance_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_performance_epp)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_throttle_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_performance_epp = epp;
@@ -550,12 +550,12 @@ impl CtrlPlatform {
/// ***********************************************************************
#[dbus_interface(property)]
#[zbus(property)]
fn post_animation_sound(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, post_animation_sound, "post_animation_sound")
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_post_animation_sound(&mut self, on: bool) -> Result<(), FdoErr> {
if self.platform.has_post_animation_sound() {
self.platform.set_post_animation_sound(on).map_err(|err| {
@@ -571,34 +571,34 @@ impl CtrlPlatform {
/// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also.
#[dbus_interface(property)]
#[zbus(property)]
fn panel_od(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, panel_od, "panel_od")
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_panel_od(&mut self, overdrive: bool) -> Result<(), FdoErr> {
platform_set_bool!(self, panel_od, "panel_od", overdrive)
}
/// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also.
#[dbus_interface(property)]
#[zbus(property)]
fn mini_led_mode(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, mini_led_mode, "mini_led_mode")
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_mini_led_mode(&mut self, on: bool) -> Result<(), FdoErr> {
platform_set_bool!(self, mini_led_mode, "mini_led_mode", on)
}
#[dbus_interface(property)]
#[zbus(property)]
fn dgpu_disable(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, dgpu_disable, "dgpu_disable")
}
#[dbus_interface(property)]
#[zbus(property)]
fn egpu_enable(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, egpu_enable, "egpu_enable")
}
@@ -607,12 +607,12 @@ impl CtrlPlatform {
/// Set the Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[dbus_interface(property)]
#[zbus(property)]
async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_pl1_spl, "ppt_pl1_spl", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_ppt_pl1_spl(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, ppt_pl1_spl, "ppt_pl1_spl", value, 5, 250)
}
@@ -620,72 +620,72 @@ impl CtrlPlatform {
/// Set the Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[dbus_interface(property)]
#[zbus(property)]
async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_pl2_sppt, "ppt_pl2_sppt", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_ppt_pl2_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value, 5, 250)
}
/// Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
/// * min=5, max=250
#[dbus_interface(property)]
#[zbus(property)]
async fn ppt_fppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_fppt, "ppt_fppt", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_ppt_fppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, ppt_fppt, "ppt_fppt", value, 5, 250)
}
/// Set the APU SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[dbus_interface(property)]
#[zbus(property)]
async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_apu_sppt, "ppt_apu_sppt", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_ppt_apu_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, ppt_apu_sppt, "ppt_apu_sppt", value, 5, 130)
}
/// Set the platform SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[dbus_interface(property)]
#[zbus(property)]
async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_platform_sppt, "ppt_platform_sppt", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_ppt_platform_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, ppt_platform_sppt, "ppt_platform_sppt", value, 5, 130)
}
/// Set the dynamic boost limit of the Nvidia dGPU:
/// * min=5, max=25
#[dbus_interface(property)]
#[zbus(property)]
async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, nv_dynamic_boost, "nv_dynamic_boost", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_nv_dynamic_boost(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, nv_dynamic_boost, "nv_dynamic_boost", value, 5, 25)
}
/// Set the target temperature limit of the Nvidia dGPU:
/// * min=75, max=87
#[dbus_interface(property)]
#[zbus(property)]
async fn nv_temp_target(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, nv_temp_target, "nv_temp_target", 5)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn set_nv_temp_target(&mut self, value: u8) -> Result<(), FdoErr> {
platform_set_with_min_max!(self, nv_temp_target, "nv_temp_target", value, 5, 87)
}

View File

@@ -123,7 +123,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
loop {
// This is just a blocker to idle and ensure the reator reacts
sleep(Duration::from_millis(1000)).await;
connection.executor().tick().await;
}
}