diff --git a/Cargo.lock b/Cargo.lock index dbc659a5..b6edf589 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,7 @@ dependencies = [ "rog_dbus", "rog_platform", "rog_profiles", + "rog_slash", "tinybmp", "tokio", "toml 0.5.11", @@ -160,6 +161,7 @@ dependencies = [ "rog_aura", "rog_platform", "rog_profiles", + "rog_slash", "serde", "serde_derive", "systemd-zbus", @@ -3560,6 +3562,23 @@ dependencies = [ "uhid-virt", ] +[[package]] +name = "rog_slash" +version = "6.0.0-alpha1" +dependencies = [ + "cargo-husky", + "dmi_id", + "gif 0.12.0", + "glam", + "log", + "pix", + "png_pong", + "serde", + "serde_derive", + "typeshare", + "zbus 4.0.1", +] + [[package]] name = "ron" version = "0.8.1" diff --git a/Cargo.toml b/Cargo.toml index 5b828836..80a7e822 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "rog-aura", "rog-profiles", "rog-control-center", + "rog-slash", "simulators", ] default-members = [ diff --git a/asusctl/Cargo.toml b/asusctl/Cargo.toml index ead75c5b..d905f92f 100644 --- a/asusctl/Cargo.toml +++ b/asusctl/Cargo.toml @@ -7,6 +7,7 @@ version.workspace = true [dependencies] rog_anime = { path = "../rog-anime" } +rog_slash = { path = "../rog-slash" } rog_aura = { path = "../rog-aura" } rog_dbus = { path = "../rog-dbus" } rog_profiles = { path = "../rog-profiles" } diff --git a/asusctl/src/cli_opts.rs b/asusctl/src/cli_opts.rs index ba248371..3ff98aa2 100644 --- a/asusctl/src/cli_opts.rs +++ b/asusctl/src/cli_opts.rs @@ -4,6 +4,7 @@ use rog_platform::platform::ThrottlePolicy; use crate::anime_cli::AnimeCommand; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; use crate::fan_curve_cli::FanCurveCommand; +use crate::slash_cli::SlashCommand; #[derive(Default, Options)] pub struct CliStart { @@ -41,6 +42,8 @@ pub enum CliCommand { Graphics(GraphicsCommand), #[options(name = "anime", help = "Manage AniMe Matrix")] Anime(AnimeCommand), + #[options(name = "slash", help = "Manage Slash Ledbar")] + Slash(SlashCommand), #[options(help = "Change bios settings")] Bios(BiosCommand), } diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index e07ff71c..45ed377b 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -21,15 +21,18 @@ use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_profiles::error::ProfileError; +use rog_slash::SlashMode; use zbus::blocking::Connection; use crate::aura_cli::{AuraPowerStates, LedBrightness}; use crate::cli_opts::*; +use crate::slash_cli::{SlashCommand}; mod anime_cli; mod aura_cli; mod cli_opts; mod fan_curve_cli; +mod slash_cli; fn main() { let args: Vec = args().skip(1).collect(); @@ -168,6 +171,7 @@ fn do_parsed( } Some(CliCommand::Graphics(_)) => do_gfx(), Some(CliCommand::Anime(cmd)) => handle_anime(&conn, cmd)?, + Some(CliCommand::Slash(cmd)) => handle_slash(&conn, cmd)?, Some(CliCommand::Bios(cmd)) => { handle_platform_properties(&conn, supported_properties, cmd)? } @@ -482,6 +486,49 @@ fn verify_brightness(brightness: f32) { } } +fn handle_slash( + dbus: &RogDbusClientBlocking<'_>, + cmd: &SlashCommand, +) -> Result<(), Box> { + if ( + cmd.brightness.is_none() && + cmd.interval.is_none() && + cmd.slash_mode.is_none() && + !cmd.list && + !cmd.enable && + !cmd.disable + ) || cmd.help + { + println!("Missing arg or command\n\n{}", cmd.self_usage()); + if let Some(lst) = cmd.self_command_list() { + println!("\n{}", lst); + } + } + if cmd.enable { + dbus.proxies().slash().set_enabled(true)?; + } + if cmd.disable { + dbus.proxies().slash().set_enabled(false)?; + } + if let Some(brightness) = cmd.brightness { + dbus.proxies().slash().set_brightness(brightness)?; + } + if let Some(interval) = cmd.interval { + dbus.proxies().slash().set_interval(interval)?; + } + if let Some(slash_mode) = cmd.slash_mode { + dbus.proxies().slash().set_slash_mode(slash_mode)?; + } + if cmd.list { + let res = SlashMode::list(); + for p in &res { + println!("{:?}", p); + } + } + + Ok(()) +} + fn handle_led_mode( aura: &[AuraProxyBlocking], mode: &LedModeCommand, diff --git a/asusctl/src/slash_cli.rs b/asusctl/src/slash_cli.rs new file mode 100644 index 00000000..0c9d42d1 --- /dev/null +++ b/asusctl/src/slash_cli.rs @@ -0,0 +1,20 @@ +use gumdrop::Options; +use rog_slash::SlashMode; + +#[derive(Options)] +pub struct SlashCommand { + #[options(help = "print help message")] + pub help: bool, + #[options(help = "Enable the Slash Ledbar")] + pub enable: bool, + #[options(help = "Ddisable the Slash Ledbar")] + pub disable: bool, + #[options(meta = "", help = "Set brightness value <0-255>")] + pub brightness: Option, + #[options(meta = "", help = "Set interval value <0-255>")] + pub interval: Option, + #[options(help = "Set SlashMode (so 'list' for all options)")] + pub slash_mode: Option, + #[options(help = "list available animations")] + pub list: bool, +} \ No newline at end of file diff --git a/asusd/Cargo.toml b/asusd/Cargo.toml index 2f774baf..3257afc3 100644 --- a/asusd/Cargo.toml +++ b/asusd/Cargo.toml @@ -16,6 +16,7 @@ path = "src/daemon.rs" [dependencies] config-traits = { path = "../config-traits" } rog_anime = { path = "../rog-anime", features = ["dbus"] } +rog_slash = { path = "../rog-slash", features = ["dbus"] } rog_aura = { path = "../rog-aura", features = ["dbus"] } rog_platform = { path = "../rog-platform" } rog_profiles = { path = "../rog-profiles" } diff --git a/asusd/src/config.rs b/asusd/src/config.rs index f3a2ea95..b42aa83c 100644 --- a/asusd/src/config.rs +++ b/asusd/src/config.rs @@ -90,13 +90,13 @@ impl StdConfig for Config { } } - fn config_dir() -> std::path::PathBuf { - std::path::PathBuf::from(crate::CONFIG_PATH_BASE) - } - fn file_name(&self) -> String { CONFIG_FILE.to_owned() } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } } impl StdConfigLoad3 for Config {} diff --git a/asusd/src/ctrl_anime/config.rs b/asusd/src/ctrl_anime/config.rs index 507f1d21..2fe9a655 100644 --- a/asusd/src/ctrl_anime/config.rs +++ b/asusd/src/ctrl_anime/config.rs @@ -150,13 +150,13 @@ impl StdConfig for AnimeConfig { Self::create_default() } - fn config_dir() -> std::path::PathBuf { - std::path::PathBuf::from(crate::CONFIG_PATH_BASE) - } - fn file_name(&self) -> String { CONFIG_FILE.to_owned() } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } } impl StdConfigLoad2 for AnimeConfig {} diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index 4ad5138e..fb86f0a4 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -27,16 +27,16 @@ impl StdConfig for AuraConfig { panic!("This should not be used"); } - fn config_dir() -> std::path::PathBuf { - std::path::PathBuf::from(crate::CONFIG_PATH_BASE) - } - fn file_name(&self) -> String { if self.config_name.is_empty() { panic!("Config file name should not be empty"); } self.config_name.to_owned() } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } } impl StdConfigLoad for AuraConfig {} diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index 62003c1a..e71da8df 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -17,6 +17,7 @@ use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_NAME, AURA_ZBUS_PATH use crate::ctrl_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH}; use crate::error::RogError; use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify}; +use crate::ctrl_slash::trait_impls::{CtrlSlashZbus, SLASH_ZBUS_NAME, SLASH_ZBUS_PATH}; const PLATFORM_ZBUS_NAME: &str = "Platform"; const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux"; @@ -351,6 +352,13 @@ impl CtrlPlatform { { interfaces.push(PLATFORM_ZBUS_NAME.to_owned()); } + if server + .interface::<_, CtrlSlashZbus>(SLASH_ZBUS_PATH) + .await + .is_ok() + { + interfaces.push(SLASH_ZBUS_NAME.to_owned()); + } interfaces } diff --git a/asusd/src/ctrl_slash/config.rs b/asusd/src/ctrl_slash/config.rs new file mode 100644 index 00000000..67229247 --- /dev/null +++ b/asusd/src/ctrl_slash/config.rs @@ -0,0 +1,51 @@ +use serde_derive::{Deserialize, Serialize}; +use config_traits::{StdConfig, StdConfigLoad}; +use rog_slash::{DeviceState, SlashMode}; + +const CONFIG_FILE: &str = "slash.ron"; + +/// Config for base system actions for the anime display +#[derive(Deserialize, Serialize, Debug)] +pub struct SlashConfig { + pub slash_enabled: bool, + pub slash_brightness: u8, + pub slash_interval: u8, + pub slash_mode: SlashMode, +} + +impl Default for SlashConfig { + fn default() -> Self { + SlashConfig { + slash_enabled: true, + slash_brightness: 255, + slash_interval: 0, + slash_mode: SlashMode::Bounce, + } + } +} +impl StdConfig for SlashConfig { + fn new() -> Self { + Self::default() + } + + fn file_name(&self) -> String { + CONFIG_FILE.to_owned() + } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } +} + +impl StdConfigLoad for SlashConfig {} + +impl From<&SlashConfig> for DeviceState { + fn from(config: &SlashConfig) -> Self { + DeviceState { + slash_enabled: config.slash_enabled, + slash_brightness: config.slash_brightness, + slash_interval: config.slash_interval, + slash_mode: config.slash_mode, + } + } +} \ No newline at end of file diff --git a/asusd/src/ctrl_slash/mod.rs b/asusd/src/ctrl_slash/mod.rs new file mode 100644 index 00000000..9eb866b6 --- /dev/null +++ b/asusd/src/ctrl_slash/mod.rs @@ -0,0 +1,102 @@ +pub mod config; +pub mod trait_impls; + +use rog_platform::hid_raw::HidRaw; +use rog_platform::usb_raw::USBRaw; +use rog_slash::{SlashMode, SlashType}; +use rog_slash::error::SlashError; +use rog_slash::usb::{get_slash_type, pkt_set_mode, pkt_set_options, pkts_for_init}; +use crate::ctrl_slash::config::SlashConfig; +use crate::error::RogError; + +enum Node { + Usb(USBRaw), + Hid(HidRaw), +} + +impl Node { + pub fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> { + // TODO: map and pass on errors + match self { + Node::Usb(u) => { + u.write_bytes(message).ok(); + } + Node::Hid(h) => { + h.write_bytes(message).ok(); + } + } + Ok(()) + } +} + +pub struct CtrlSlash { + // node: HidRaw, + node: Node, + config: SlashConfig, + // slash_type: SlashType, + // // set to force thread to exit + // thread_exit: Arc, + // // Set to false when the thread exits + // thread_running: Arc, +} + +impl CtrlSlash { + #[inline] + pub fn new(config: SlashConfig) -> Result { + let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok(); + let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok(); + let node = if usb.is_some() { + unsafe { Node::Usb(usb.unwrap_unchecked()) } + } else if hid.is_some() { + unsafe { Node::Hid(hid.unwrap_unchecked()) } + } else { + return Err(RogError::NotSupported); + }; + + let slash_type = get_slash_type()?; + if slash_type == SlashType::Unknown { + return Err(RogError::Slash(SlashError::NoDevice)); + } + + let ctrl = CtrlSlash { + node, + config, + // slash_type, + // thread_exit: Arc::new(AtomicBool::new(false)), + // thread_running: Arc::new(AtomicBool::new(false)), + }; + ctrl.do_initialization()?; + + Ok(ctrl) + } + + fn do_initialization(&self) -> Result<(), RogError> { + + let init_packets = pkts_for_init(); + self.node.write_bytes(&init_packets[0])?; + self.node.write_bytes(&init_packets[1])?; + + // Apply config upon initialization + let option_packets = pkt_set_options(self.config.slash_enabled, self.config.slash_brightness, self.config.slash_interval); + self.node.write_bytes(&option_packets)?; + + let mode_packets = pkt_set_mode(self.config.slash_mode); + self.node.write_bytes(&mode_packets[0])?; + self.node.write_bytes(&mode_packets[1])?; + + Ok(()) + } + + pub fn set_options(&self, enabled: bool, brightness: u8, interval: u8) -> Result<(), RogError> { + let command_packets = pkt_set_options(enabled, brightness, interval); + self.node.write_bytes(&command_packets)?; + Ok(()) + } + + pub fn set_slash_mode(&self, slash_mode: SlashMode) -> Result<(), RogError> { + let command_packets = pkt_set_mode(slash_mode); + self.node.write_bytes(&command_packets[0])?; + self.node.write_bytes(&command_packets[1])?; + Ok(()) + } +} \ No newline at end of file diff --git a/asusd/src/ctrl_slash/trait_impls.rs b/asusd/src/ctrl_slash/trait_impls.rs new file mode 100644 index 00000000..60903086 --- /dev/null +++ b/asusd/src/ctrl_slash/trait_impls.rs @@ -0,0 +1,145 @@ +use std::sync::Arc; +use log::warn; +use zbus::{Connection, interface, SignalContext}; +use zbus::export::futures_util::lock::Mutex; +use config_traits::StdConfig; +use rog_slash::{DeviceState, SlashMode}; +use rog_slash::usb::{pkt_set_mode, pkt_set_options}; +use crate::ctrl_slash::CtrlSlash; +use crate::error::RogError; + + +pub const SLASH_ZBUS_NAME: &str = "Slash"; +pub const SLASH_ZBUS_PATH: &str = "/org/asuslinux"; + +#[derive(Clone)] +pub struct CtrlSlashZbus(pub Arc>); + +/// The struct with the main dbus methods requires this trait +impl crate::ZbusRun for CtrlSlashZbus { + async fn add_to_server(self, server: &mut Connection) { + Self::add_to_server_helper(self, SLASH_ZBUS_PATH, server).await; + } +} + +#[interface(name = "org.asuslinux.Slash")] +impl CtrlSlashZbus { + + /// Get enabled or not + #[zbus(property)] + async fn enabled(&self) -> bool { + let lock = self.0.lock().await; + lock.config.slash_enabled + } + + /// Set enabled true or false + async fn set_enabled(&self, enabled: bool) { + let mut lock = self.0.lock().await; + let brightness = if enabled && lock.config.slash_brightness == 0 { 0x88 } else { lock.config.slash_brightness }; + lock.node + .write_bytes(&pkt_set_options(enabled, brightness, lock.config.slash_interval)) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_enabled = enabled; + lock.config.slash_brightness = brightness; + lock.config.write(); + } + + /// Get brightness level + #[zbus(property)] + async fn brightness(&self) -> u8 { + let lock = self.0.lock().await; + lock.config.slash_brightness + } + + /// Set brightness level + async fn set_brightness(&self, brightness: u8) { + let mut lock = self.0.lock().await; + let enabled = brightness > 0; + lock.node + .write_bytes(&pkt_set_options(enabled, brightness, lock.config.slash_interval)) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_enabled = enabled; + lock.config.slash_brightness = brightness; + lock.config.write(); + } + + #[zbus(property)] + async fn interval(&self) -> u8 { + let lock = self.0.lock().await; + lock.config.slash_interval + } + + /// Set interval between slash animations (0-255) + async fn set_interval(&self, interval: u8) { + let mut lock = self.0.lock().await; + lock.node + .write_bytes(&pkt_set_options(lock.config.slash_enabled, lock.config.slash_brightness, interval)) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_interval = interval; + lock.config.write(); + } + + #[zbus(property)] + async fn slash_mode(&self) -> u8 { + let lock = self.0.lock().await; + lock.config.slash_interval + } + + /// Set interval between slash animations (0-255) + async fn set_slash_mode(&self, slash_mode: SlashMode) { + let mut lock = self.0.lock().await; + + let command_packets = pkt_set_mode(slash_mode); + + lock.node + .write_bytes(&command_packets[0]) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + lock.node + .write_bytes(&command_packets[1]) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_mode = slash_mode; + lock.config.write(); + } + + /// Get the device state as stored by asusd + // #[zbus(property)] + async fn device_state(&self) -> DeviceState { + let lock = self.0.lock().await; + DeviceState::from(&lock.config) + } +} + +impl crate::CtrlTask for CtrlSlashZbus { + fn zbus_path() -> &'static str { + SLASH_ZBUS_PATH + } + + async fn create_tasks(&self, _: SignalContext<'static>) -> Result<(), RogError> { + Ok(()) + } +} + +impl crate::Reloadable for CtrlSlashZbus { + async fn reload(&mut self) -> Result<(), RogError> { + Ok(()) + } +} \ No newline at end of file diff --git a/asusd/src/daemon.rs b/asusd/src/daemon.rs index b9d68cd1..f6ddefe0 100644 --- a/asusd/src/daemon.rs +++ b/asusd/src/daemon.rs @@ -12,9 +12,12 @@ use asusd::ctrl_aura::manager::AuraManager; use asusd::ctrl_fancurves::CtrlFanCurveZbus; use asusd::ctrl_platform::CtrlPlatform; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; -use config_traits::{StdConfig, StdConfigLoad2, StdConfigLoad3}; +use config_traits::{StdConfig, StdConfigLoad, StdConfigLoad2, StdConfigLoad3}; use log::{error, info}; use zbus::fdo::ObjectManager; +use asusd::ctrl_slash::config::SlashConfig; +use asusd::ctrl_slash::CtrlSlash; +use asusd::ctrl_slash::trait_impls::CtrlSlashZbus; #[tokio::main] async fn main() -> Result<(), Box> { @@ -42,6 +45,7 @@ async fn main() -> Result<(), Box> { info!(" daemon v{}", asusd::VERSION); info!(" rog-anime v{}", rog_anime::VERSION); + info!(" rog-slash v{}", rog_slash::VERSION); info!(" rog-aura v{}", rog_aura::VERSION); info!(" rog-profiles v{}", rog_profiles::VERSION); info!("rog-platform v{}", rog_platform::VERSION); @@ -105,6 +109,20 @@ async fn start_daemon() -> Result<(), Box> { } } + match CtrlSlash::new(SlashConfig::new().load()) { + Ok(ctrl) => { + let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl))); + // Currently, the Slash has no need for a loop watching power events, however, + // it could be cool to have the slash do some power-on/off animation + // (It has a built-in power on animation which plays when u plug in the power supply) + let sig_ctx = CtrlSlashZbus::signal_context(&connection)?; + start_tasks(zbus, &mut connection, sig_ctx).await?; + } + Err(err) => { + info!("AniMe control: {}", err); + } + } + let _ = AuraManager::new(connection.clone()).await?; // Request dbus name after finishing initalizing all functions diff --git a/asusd/src/error.rs b/asusd/src/error.rs index 64ef8a0f..601aab95 100644 --- a/asusd/src/error.rs +++ b/asusd/src/error.rs @@ -5,6 +5,7 @@ use config_traits::ron; use rog_anime::error::AnimeError; use rog_platform::error::PlatformError; use rog_profiles::error::ProfileError; +use rog_slash::error::SlashError; #[derive(Debug)] pub enum RogError { @@ -31,6 +32,7 @@ pub enum RogError { NoAuraKeyboard, NoAuraNode, Anime(AnimeError), + Slash(SlashError), Platform(PlatformError), SystemdUnitAction(String), SystemdUnitWaitTimeout(String), @@ -72,6 +74,7 @@ impl fmt::Display for RogError { RogError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"), RogError::NoAuraNode => write!(f, "No Aura keyboard node found"), RogError::Anime(deets) => write!(f, "AniMe Matrix error: {}", deets), + RogError::Slash(deets) => write!(f, "Slash error: {}", deets), RogError::Platform(deets) => write!(f, "Asus Platform error: {}", deets), RogError::SystemdUnitAction(action) => { write!(f, "systemd unit action {} failed", action) @@ -103,6 +106,12 @@ impl From for RogError { } } +impl From for RogError { + fn from(err: SlashError) -> Self { + RogError::Slash(err) + } +} + impl From for RogError { fn from(err: PlatformError) -> Self { RogError::Platform(err) diff --git a/asusd/src/lib.rs b/asusd/src/lib.rs index db784d39..0c740bf9 100644 --- a/asusd/src/lib.rs +++ b/asusd/src/lib.rs @@ -3,6 +3,8 @@ pub mod config; /// Control of anime matrix display pub mod ctrl_anime; +/// Control of Slash led bar +pub mod ctrl_slash; /// Keyboard LED brightness control, RGB, and LED display modes pub mod ctrl_aura; /// Control platform profiles + fan-curves if available @@ -50,7 +52,7 @@ pub static DBUS_IFACE: &str = "org.asuslinux.Daemon"; /// task_watch_item!(panel_od platform); /// task_watch_item!(gpu_mux_mode platform); /// } -/// ``` +/// ```\ /// // TODO: this is kind of useless if it can't trigger some action #[macro_export] macro_rules! task_watch_item { @@ -130,7 +132,7 @@ pub fn print_board_info() { } pub trait Reloadable { - fn reload(&mut self) -> impl std::future::Future> + Send; + fn reload(&mut self) -> impl Future> + Send; } pub trait ReloadAndNotify { @@ -140,18 +142,18 @@ pub trait ReloadAndNotify { &mut self, signal_context: &SignalContext<'static>, data: Self::Data, - ) -> impl std::future::Future> + Send; + ) -> impl Future> + Send; } pub trait ZbusRun { fn add_to_server(self, server: &mut Connection) - -> impl std::future::Future + Send; + -> impl Future + Send; fn add_to_server_helper( iface: impl zbus::Interface, path: &str, server: &mut Connection, - ) -> impl std::future::Future + Send { + ) -> impl Future + Send { async move { server .object_server() @@ -180,7 +182,7 @@ pub trait CtrlTask { fn create_tasks( &self, signal: SignalContext<'static>, - ) -> impl std::future::Future> + Send; + ) -> impl Future> + Send; // /// Create a timed repeating task // async fn repeating_task(&self, millis: u64, mut task: impl FnMut() + Send + @@ -213,7 +215,7 @@ pub trait CtrlTask { mut on_prepare_for_shutdown: F2, mut on_lid_change: F3, mut on_external_power_change: F4, - ) -> impl std::future::Future + Send + ) -> impl Future + Send where F1: FnMut(bool) -> Fut1, F2: FnMut(bool) -> Fut2, @@ -307,13 +309,13 @@ pub async fn start_tasks( where T: ZbusRun + Reloadable + CtrlTask + Clone, { - let task = zbus.clone(); + let zbus_clone = zbus.clone(); zbus.reload() .await .unwrap_or_else(|err| warn!("Controller error: {}", err)); zbus.add_to_server(connection).await; - task.create_tasks(signal_ctx).await.ok(); + zbus_clone.create_tasks(signal_ctx).await.ok(); Ok(()) -} +} \ No newline at end of file diff --git a/bindings/dbus-xml/org-asuslinux-platform-4.xml b/bindings/dbus-xml/org-asuslinux-platform-4.xml index a8708bd5..d4cf9925 100644 --- a/bindings/dbus-xml/org-asuslinux-platform-4.xml +++ b/bindings/dbus-xml/org-asuslinux-platform-4.xml @@ -1,6 +1,5 @@ - +