diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d5519a9..8d84004c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +## [v6.1.7] + +### Changed +- Fix Slash display enable + ## [v6.1.6] ### Changed diff --git a/Cargo.lock b/Cargo.lock index 9a3744d6..be18a5d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,7 +250,7 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" [[package]] name = "asusctl" -version = "6.1.6" +version = "6.1.7" dependencies = [ "dmi_id", "env_logger", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "asusd" -version = "6.1.6" +version = "6.1.7" dependencies = [ "cargo-husky", "concat-idents", @@ -296,7 +296,7 @@ dependencies = [ [[package]] name = "asusd-user" -version = "6.1.6" +version = "6.1.7" dependencies = [ "config-traits", "dirs", @@ -1084,7 +1084,7 @@ dependencies = [ [[package]] name = "config-traits" -version = "6.1.6" +version = "6.1.7" dependencies = [ "log", "ron", @@ -1476,7 +1476,7 @@ dependencies = [ [[package]] name = "dmi_id" -version = "6.1.6" +version = "6.1.7" dependencies = [ "log", "udev 0.8.0", @@ -4743,7 +4743,7 @@ dependencies = [ [[package]] name = "rog-control-center" -version = "6.1.6" +version = "6.1.7" dependencies = [ "asusd", "concat-idents", @@ -4774,7 +4774,7 @@ dependencies = [ [[package]] name = "rog_anime" -version = "6.1.6" +version = "6.1.7" dependencies = [ "dmi_id", "gif 0.12.0", @@ -4788,7 +4788,7 @@ dependencies = [ [[package]] name = "rog_aura" -version = "6.1.6" +version = "6.1.7" dependencies = [ "dmi_id", "log", @@ -4799,7 +4799,7 @@ dependencies = [ [[package]] name = "rog_dbus" -version = "6.1.6" +version = "6.1.7" dependencies = [ "asusd", "rog_anime", @@ -4813,7 +4813,7 @@ dependencies = [ [[package]] name = "rog_platform" -version = "6.1.6" +version = "6.1.7" dependencies = [ "concat-idents", "inotify", @@ -4826,7 +4826,7 @@ dependencies = [ [[package]] name = "rog_profiles" -version = "6.1.6" +version = "6.1.7" dependencies = [ "log", "rog_platform", @@ -4837,7 +4837,7 @@ dependencies = [ [[package]] name = "rog_scsi" -version = "6.1.6" +version = "6.1.7" dependencies = [ "ron", "serde", @@ -4847,7 +4847,7 @@ dependencies = [ [[package]] name = "rog_simulators" -version = "6.1.6" +version = "6.1.7" dependencies = [ "log", "rog_anime", @@ -4857,7 +4857,7 @@ dependencies = [ [[package]] name = "rog_slash" -version = "6.1.6" +version = "6.1.7" dependencies = [ "dmi_id", "serde", diff --git a/Cargo.toml b/Cargo.toml index 5a5d5fe5..54489f63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "6.1.6" +version = "6.1.7" rust-version = "1.82" license = "MPL-2.0" readme = "README.md" diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index c03f2b44..b4b8df9a 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -575,6 +575,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box> { && cmd.show_on_sleep.is_none() && cmd.show_on_battery.is_none() && cmd.show_battery_warning.is_none() + // && cmd.show_on_lid_closed.is_none() && cmd.mode.is_none() && !cmd.list && !cmd.enable @@ -620,6 +621,9 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box> { if let Some(show) = cmd.show_battery_warning { proxy.set_show_battery_warning(show)?; } + // if let Some(show) = cmd.show_on_lid_closed { + // proxy.set_show_on_lid_closed(show)?; + // } } if cmd.list { let res = SlashMode::list(); diff --git a/asusctl/src/slash_cli.rs b/asusctl/src/slash_cli.rs index 67c251eb..fec5d8f2 100644 --- a/asusctl/src/slash_cli.rs +++ b/asusctl/src/slash_cli.rs @@ -26,6 +26,8 @@ pub struct SlashCommand { pub show_on_sleep: Option, #[options(short = "b", meta = "", help = "Show the animation on battery")] pub show_on_battery: Option, + // #[options(short = "L", meta = "", help = "Show the animation on lid closed")] + // pub show_on_lid_closed: Option, #[options( short = "w", meta = "", diff --git a/asusd/src/aura_slash/config.rs b/asusd/src/aura_slash/config.rs index f44c5743..545dc630 100644 --- a/asusd/src/aura_slash/config.rs +++ b/asusd/src/aura_slash/config.rs @@ -18,6 +18,7 @@ pub struct SlashConfig { pub show_on_sleep: bool, pub show_on_battery: bool, pub show_battery_warning: bool, + pub show_on_lid_closed: bool, } impl Default for SlashConfig { @@ -33,6 +34,7 @@ impl Default for SlashConfig { show_on_sleep: true, show_on_battery: true, show_battery_warning: true, + show_on_lid_closed: true, } } } diff --git a/asusd/src/aura_slash/mod.rs b/asusd/src/aura_slash/mod.rs index ca88b8cd..ef9517f0 100644 --- a/asusd/src/aura_slash/mod.rs +++ b/asusd/src/aura_slash/mod.rs @@ -4,8 +4,7 @@ use config::SlashConfig; use futures_util::lock::{Mutex, MutexGuard}; use rog_platform::hid_raw::HidRaw; use rog_platform::usb_raw::USBRaw; -use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init}; -use rog_slash::SlashType; +use rog_slash::usb::{slash_pkt_enable, slash_pkt_init, slash_pkt_options, slash_pkt_set_mode}; use crate::error::RogError; @@ -46,14 +45,14 @@ impl Slash { pub async fn do_initialization(&self) -> Result<(), RogError> { // Don't try to initialise these models as the asus drivers already did let config = self.config.lock().await; - if !matches!(config.slash_type, SlashType::GA605 | SlashType::GU605) { - for pkt in &pkts_for_init(config.slash_type) { - self.write_bytes(pkt).await?; - } + for pkt in &slash_pkt_init(config.slash_type) { + self.write_bytes(pkt).await?; } + self.write_bytes(&slash_pkt_enable(config.slash_type, config.enabled)) + .await?; // Apply config upon initialization - let option_packets = get_options_packet( + let option_packets = slash_pkt_options( config.slash_type, config.enabled, config.brightness, @@ -61,7 +60,7 @@ impl Slash { ); self.write_bytes(&option_packets).await?; - let mode_packets = pkt_set_mode(config.slash_type, config.display_mode); + let mode_packets = slash_pkt_set_mode(config.slash_type, config.display_mode); // self.node.write_bytes(&mode_packets[0])?; self.write_bytes(&mode_packets[1]).await?; diff --git a/asusd/src/aura_slash/trait_impls.rs b/asusd/src/aura_slash/trait_impls.rs index 7de7cfbe..f154597a 100644 --- a/asusd/src/aura_slash/trait_impls.rs +++ b/asusd/src/aura_slash/trait_impls.rs @@ -1,8 +1,9 @@ use config_traits::StdConfig; use log::{debug, error, warn}; use rog_slash::usb::{ - get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet, - get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode, + slash_pkt_battery_saver, slash_pkt_boot, slash_pkt_enable, slash_pkt_lid_closed, + slash_pkt_low_battery, slash_pkt_options, slash_pkt_save, slash_pkt_set_mode, + slash_pkt_shutdown, slash_pkt_sleep, }; use rog_slash::{DeviceState, SlashMode}; use zbus::zvariant::OwnedObjectPath; @@ -58,7 +59,14 @@ impl SlashZbus { config.brightness }; self.0 - .write_bytes(&get_options_packet( + .write_bytes(&slash_pkt_enable(config.slash_type, enabled)) + .await + .map_err(|err| { + warn!("ctrl_slash::enable {}", err); + }) + .ok(); + self.0 + .write_bytes(&slash_pkt_options( config.slash_type, enabled, brightness, @@ -88,7 +96,7 @@ impl SlashZbus { let mut config = self.0.lock_config().await; let enabled = brightness > 0; self.0 - .write_bytes(&get_options_packet( + .write_bytes(&slash_pkt_options( config.slash_type, enabled, brightness, @@ -116,7 +124,7 @@ impl SlashZbus { async fn set_interval(&self, interval: u8) { let mut config = self.0.lock_config().await; self.0 - .write_bytes(&get_options_packet( + .write_bytes(&slash_pkt_options( config.slash_type, config.enabled, config.brightness, interval, )) .await @@ -140,10 +148,12 @@ impl SlashZbus { async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> { let mut config = self.0.lock_config().await; - let command_packets = pkt_set_mode(config.slash_type, mode); + let command_packets = slash_pkt_set_mode(config.slash_type, mode); // self.node.write_bytes(&command_packets[0])?; self.0.write_bytes(&command_packets[1]).await?; - self.0.write_bytes(&pkt_save(config.slash_type)).await?; + self.0 + .write_bytes(&slash_pkt_save(config.slash_type)) + .await?; config.display_mode = mode; config.write(); @@ -167,7 +177,7 @@ impl SlashZbus { async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> { let mut config = self.0.lock_config().await; self.0 - .write_bytes(&get_boot_packet(config.slash_type, enable)) + .write_bytes(&slash_pkt_boot(config.slash_type, enable)) .await?; config.show_on_boot = enable; config.write(); @@ -184,7 +194,7 @@ impl SlashZbus { async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> { let mut config = self.0.lock_config().await; self.0 - .write_bytes(&get_sleep_packet(config.slash_type, enable)) + .write_bytes(&slash_pkt_sleep(config.slash_type, enable)) .await?; config.show_on_sleep = enable; config.write(); @@ -201,7 +211,7 @@ impl SlashZbus { async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> { let mut config = self.0.lock_config().await; self.0 - .write_bytes(&get_shutdown_packet(config.slash_type, enable)) + .write_bytes(&slash_pkt_shutdown(config.slash_type, enable)) .await?; config.show_on_shutdown = enable; config.write(); @@ -218,7 +228,7 @@ impl SlashZbus { async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> { let mut config = self.0.lock_config().await; self.0 - .write_bytes(&get_battery_saver_packet(config.slash_type, enable)) + .write_bytes(&slash_pkt_battery_saver(config.slash_type, enable)) .await?; config.show_on_battery = enable; config.write(); @@ -235,12 +245,32 @@ impl SlashZbus { async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> { let mut config = self.0.lock_config().await; self.0 - .write_bytes(&get_low_battery_packet(config.slash_type, enable)) + .write_bytes(&slash_pkt_low_battery(config.slash_type, enable)) .await?; config.show_battery_warning = enable; config.write(); Ok(()) } + + #[zbus(property)] + async fn show_on_lid_closed(&self) -> zbus::fdo::Result { + let config = self.0.lock_config().await; + Ok(config.show_on_lid_closed) + } + + #[zbus(property)] + async fn set_show_on_lid_closed(&self, enable: bool) -> zbus::Result<()> { + let mut config = self.0.lock_config().await; + self.0 + .write_bytes(&slash_pkt_lid_closed(config.slash_type, enable)) + .await?; + self.0 + .write_bytes(&slash_pkt_save(config.slash_type)) + .await?; + config.show_on_lid_closed = enable; + config.write(); + Ok(()) + } } impl Reloadable for SlashZbus { @@ -248,7 +278,7 @@ impl Reloadable for SlashZbus { debug!("reloading slash settings"); let config = self.0.lock_config().await; self.0 - .write_bytes(&get_options_packet( + .write_bytes(&slash_pkt_options( config.slash_type, config.enabled, config.brightness, @@ -272,12 +302,12 @@ impl Reloadable for SlashZbus { }; } - write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot"); - write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep"); - write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown"); - write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery"); + write_bytes_with_warning!(slash_pkt_boot, show_on_boot, "show_on_boot"); + write_bytes_with_warning!(slash_pkt_sleep, show_on_sleep, "show_on_sleep"); + write_bytes_with_warning!(slash_pkt_shutdown, show_on_shutdown, "show_on_shutdown"); + write_bytes_with_warning!(slash_pkt_battery_saver, show_on_battery, "show_on_battery"); write_bytes_with_warning!( - get_low_battery_packet, + slash_pkt_low_battery, show_battery_warning, "show_battery_warning" ); diff --git a/rog-dbus/src/zbus_slash.rs b/rog-dbus/src/zbus_slash.rs index 3c42e6cb..ac39ab89 100644 --- a/rog-dbus/src/zbus_slash.rs +++ b/rog-dbus/src/zbus_slash.rs @@ -60,4 +60,10 @@ pub trait Slash { fn show_on_sleep(&self) -> zbus::Result; #[zbus(property)] fn set_show_on_sleep(&self, value: bool) -> zbus::Result<()>; + + /// ShowOnLidClosed property + #[zbus(property)] + fn show_on_lid_closed(&self) -> zbus::Result; + #[zbus(property)] + fn set_show_on_lid_closed(&self, value: bool) -> zbus::Result<()>; } diff --git a/rog-slash/src/usb.rs b/rog-slash/src/usb.rs index d8ab4d96..74183df8 100644 --- a/rog-slash/src/usb.rs +++ b/rog-slash/src/usb.rs @@ -62,7 +62,7 @@ pub const fn report_id(slash_type: SlashType) -> u8 { /// Get the two device initialization packets. These are required for device /// start after the laptop boots. #[inline] -pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] { +pub fn slash_pkt_init(slash_type: SlashType) -> [SlashUsbPacket; 2] { let report_id = report_id(slash_type); let mut pkt1 = [0; PACKET_SIZE]; @@ -87,7 +87,20 @@ pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] { } #[inline] -pub const fn pkt_save(slash_type: SlashType) -> SlashUsbPacket { +pub const fn slash_pkt_enable(slash_type: SlashType, enabled: bool) -> SlashUsbPacket { + let mut pkt = [0; PACKET_SIZE]; + pkt[0] = report_id(slash_type); + pkt[1] = 0xd8; + pkt[2] = 0x02; + pkt[3] = 0x00; + pkt[4] = 0x01; + pkt[5] = if enabled { 0x00 } else { 0x80 }; + + pkt +} + +#[inline] +pub const fn slash_pkt_save(slash_type: SlashType) -> SlashUsbPacket { let mut pkt = [0; PACKET_SIZE]; pkt[0] = report_id(slash_type); pkt[1] = 0xd4; @@ -100,7 +113,7 @@ pub const fn pkt_save(slash_type: SlashType) -> SlashUsbPacket { } #[inline] -pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPacket; 2] { +pub const fn slash_pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPacket; 2] { let report_id = report_id(slash_type); let mut pkt1 = [0; PACKET_SIZE]; pkt1[0] = report_id; @@ -133,7 +146,7 @@ pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPa ] } -pub const fn get_options_packet( +pub const fn slash_pkt_options( slash_type: SlashType, enabled: bool, brightness: u8, @@ -146,7 +159,7 @@ pub const fn get_options_packet( ] } -pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] { +pub const fn slash_pkt_boot(slash_type: SlashType, enabled: bool) -> [u8; 12] { let typ = report_id(slash_type); let status = enabled as u8; [ @@ -154,7 +167,7 @@ pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] { ] } -pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] { +pub const fn slash_pkt_sleep(slash_type: SlashType, enabled: bool) -> [u8; 12] { let typ = report_id(slash_type); let status = (!enabled) as u8; [ @@ -162,7 +175,7 @@ pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] ] } -pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] { +pub const fn slash_pkt_low_battery(slash_type: SlashType, enabled: bool) -> [u8; 12] { let typ = report_id(slash_type); let status = enabled as u8; [ @@ -170,7 +183,7 @@ pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8 ] } -pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] { +pub const fn slash_pkt_shutdown(slash_type: SlashType, enabled: bool) -> [u8; 12] { let typ = report_id(slash_type); let status = enabled as u8; [ @@ -178,7 +191,7 @@ pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 1 ] } -pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [u8; 6] { +pub const fn slash_pkt_battery_saver(slash_type: SlashType, enabled: bool) -> [u8; 6] { let typ = report_id(slash_type); let status = if enabled { 0x00 } else { 0x80 }; [ @@ -186,7 +199,7 @@ pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [ ] } -pub const fn get_lid_closed_packet(slash_type: SlashType, enabled: bool) -> [u8; 7] { +pub const fn slash_pkt_lid_closed(slash_type: SlashType, enabled: bool) -> [u8; 7] { let typ = report_id(slash_type); let status = if enabled { 0x00 } else { 0x80 }; [