Merge branch 'formatted_supported_functions_message' into 'main'

Improving message formatting of supported functions

See merge request asus-linux/asusctl!61
This commit is contained in:
Luke Jones
2021-05-26 19:44:47 +00:00
2 changed files with 49 additions and 1 deletions

View File

@@ -223,7 +223,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if parsed.show_supported {
let dat = dbus.proxies().supported().get_supported_functions()?;
println!("Supported laptop functions:\n{:?}", dat);
println!("Supported laptop functions:\n\n{}", dat);
}
if let Some(chg_limit) = parsed.chg_limit {

View File

@@ -1,6 +1,7 @@
use rog_aura::AuraModeNum;
use serde_derive::{Deserialize, Serialize};
use zvariant_derive::Type;
use std::fmt;
#[derive(Serialize, Deserialize, Type, Debug)]
pub struct SupportedFunctions {
@@ -39,3 +40,50 @@ pub struct RogBiosSupportedFunctions {
pub post_sound_toggle: bool,
pub dedicated_gfx_toggle: bool,
}
impl fmt::Display for SupportedFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "{}", self.anime_ctrl)?;
writeln!(f, "{}", self.charge_ctrl)?;
writeln!(f, "{}", self.fan_cpu_ctrl)?;
writeln!(f, "{}", self.keyboard_led)?;
writeln!(f, "{}", self.rog_bios_ctrl)
}
}
impl fmt::Display for AnimeSupportedFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "AniMe Matrix:")?;
writeln!(f, "\tAnime Matrix control: {}", self.0)
}
}
impl fmt::Display for ChargeSupportedFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Charge:")?;
writeln!(f, "\tBattery charge limit control: {}", self.charge_level_set)
}
}
impl fmt::Display for FanCpuSupportedFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Fan:")?;
writeln!(f, "\tStock fan modes: {}", self.stock_fan_modes)?;
writeln!(f, "\tMin/max frequency: {}", self.min_max_freq)?;
writeln!(f, "\tFan curve control: {}", self.fan_curve_set)
}
}
impl fmt::Display for LedSupportedFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "LED:")?;
writeln!(f, "\tBrightness control: {}", self.brightness_set)?;
writeln!(f, "\tStock LED modes: {:?}", self.stock_led_modes)?;
writeln!(f, "\tMultizone LED mode: {}", self.multizone_led_mode)?;
writeln!(f, "\tPer key LED mode: {}", self.per_key_led_mode)
}
}
impl fmt::Display for RogBiosSupportedFunctions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "ROG BIOS:")?;
writeln!(f, "\tPOST sound toggle: {}", self.post_sound_toggle)?;
writeln!(f, "\tDedicated GFX toggle: {}", self.dedicated_gfx_toggle)
}
}