From e88e7be8ae5d250633e5c5f592dbced0874066be Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 15 Nov 2023 17:45:25 +1300 Subject: [PATCH] Anime: expose new options in CLI --- CHANGELOG.md | 6 +++--- asusctl/src/anime_cli.rs | 20 ++++++++++++++++++++ asusctl/src/main.rs | 16 ++++++++++++++++ rog-dbus/src/zbus_anime.rs | 5 +---- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6af5f8b..3dbb8c99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support Rog Ally LED modes (basic) - Add on_lid_closed and on_external_power_changed events for running certain tasks - Anime dbus: add: - - SetOffWhenUnplugged - - SetOffWhenSuspended - - SetOffWhenLidClosed + - SetOffWhenUnplugged, also add asusctl CLI option + - SetOffWhenSuspended, also add asusctl CLI option + - SetOffWhenLidClosed, also add asusctl CLI option ### Changed - asusd: remove set_image_brightness for anime diff --git a/asusctl/src/anime_cli.rs b/asusctl/src/anime_cli.rs index 69916233..15dc17e2 100644 --- a/asusctl/src/anime_cli.rs +++ b/asusctl/src/anime_cli.rs @@ -19,6 +19,26 @@ pub struct AnimeCommand { pub brightness: Option, #[options(help = "clear the display")] pub clear: bool, + #[options( + no_short, + meta = "", + help = "turn the anime off when external power is unplugged" + )] + pub off_when_unplugged: Option, + #[options( + no_short, + meta = "", + help = "turn the anime off when the laptop suspends" + )] + pub off_when_suspended: Option, + #[options( + no_short, + meta = "", + help = "turn the anime off when the lid is closed" + )] + pub off_when_lid_closed: Option, + #[options(no_short, meta = "", help = "Off with his head!!!")] + pub off_with_his_head: Option, #[options(command)] pub command: Option, } diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index f42cc5e3..c6a16877 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -207,6 +207,10 @@ fn handle_anime( && cmd.enable_display.is_none() && cmd.enable_powersave_anim.is_none() && cmd.brightness.is_none() + && cmd.off_when_lid_closed.is_none() + && cmd.off_when_suspended.is_none() + && cmd.off_when_unplugged.is_none() + && cmd.off_with_his_head.is_none() && !cmd.clear) || cmd.help { @@ -225,6 +229,18 @@ fn handle_anime( if let Some(bright) = cmd.brightness { dbus.proxies().anime().set_brightness(bright)?; } + if let Some(enable) = cmd.off_when_lid_closed { + dbus.proxies().anime().set_off_when_lid_closed(enable)?; + } + if let Some(enable) = cmd.off_when_suspended { + dbus.proxies().anime().set_off_when_suspended(enable)?; + } + if let Some(enable) = cmd.off_when_unplugged { + dbus.proxies().anime().set_off_when_unplugged(enable)?; + } + if cmd.off_with_his_head.is_some() { + println!("Did Alice _really_ make it back from Wonderland?"); + } let mut anime_type = get_anime_type()?; if let AnimeType::Unknown = anime_type { diff --git a/rog-dbus/src/zbus_anime.rs b/rog-dbus/src/zbus_anime.rs index 6f394b0c..9c1b90fd 100644 --- a/rog-dbus/src/zbus_anime.rs +++ b/rog-dbus/src/zbus_anime.rs @@ -44,8 +44,5 @@ trait Anime { /// NotifyDeviceState signal #[dbus_proxy(signal)] - fn notify_device_state( - &self, - data: (bool, &str, bool, (&str, &str, &str, &str)), - ) -> zbus::Result<()>; + fn notify_device_state(&self, data: AnimeDeviceState) -> zbus::Result<()>; }