mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
feat: improve the cli interface
This commit is contained in:
@@ -216,6 +216,7 @@ pub struct SingleSpeed {
|
|||||||
|
|
||||||
#[argh(
|
#[argh(
|
||||||
option,
|
option,
|
||||||
|
default = "AuraZone::None",
|
||||||
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
||||||
)]
|
)]
|
||||||
pub zone: AuraZone,
|
pub zone: AuraZone,
|
||||||
@@ -237,6 +238,7 @@ pub struct SingleSpeedDirection {
|
|||||||
|
|
||||||
#[argh(
|
#[argh(
|
||||||
option,
|
option,
|
||||||
|
default = "AuraZone::None",
|
||||||
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
||||||
)]
|
)]
|
||||||
pub zone: AuraZone,
|
pub zone: AuraZone,
|
||||||
@@ -250,11 +252,12 @@ pub struct SingleSpeedDirection {
|
|||||||
description = "static single-colour effect"
|
description = "static single-colour effect"
|
||||||
)]
|
)]
|
||||||
pub struct SingleColour {
|
pub struct SingleColour {
|
||||||
#[argh(option, description = "set the RGB value e.g. ff00ff")]
|
#[argh(option, short = 'c', description = "set the RGB value e.g. ff00ff")]
|
||||||
pub colour: Colour,
|
pub colour: Colour,
|
||||||
|
|
||||||
#[argh(
|
#[argh(
|
||||||
option,
|
option,
|
||||||
|
default = "AuraZone::None",
|
||||||
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
||||||
)]
|
)]
|
||||||
pub zone: AuraZone,
|
pub zone: AuraZone,
|
||||||
@@ -268,7 +271,7 @@ pub struct SingleColour {
|
|||||||
description = "single-colour effect with speed"
|
description = "single-colour effect with speed"
|
||||||
)]
|
)]
|
||||||
pub struct SingleColourSpeed {
|
pub struct SingleColourSpeed {
|
||||||
#[argh(option, description = "set the RGB value e.g. ff00ff")]
|
#[argh(option, short = 'c', description = "set the RGB value e.g. ff00ff")]
|
||||||
pub colour: Colour,
|
pub colour: Colour,
|
||||||
|
|
||||||
#[argh(option, description = "set the speed: low, med, high")]
|
#[argh(option, description = "set the speed: low, med, high")]
|
||||||
@@ -276,6 +279,7 @@ pub struct SingleColourSpeed {
|
|||||||
|
|
||||||
#[argh(
|
#[argh(
|
||||||
option,
|
option,
|
||||||
|
default = "AuraZone::None",
|
||||||
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
||||||
)]
|
)]
|
||||||
pub zone: AuraZone,
|
pub zone: AuraZone,
|
||||||
@@ -300,6 +304,7 @@ pub struct TwoColourSpeed {
|
|||||||
|
|
||||||
#[argh(
|
#[argh(
|
||||||
option,
|
option,
|
||||||
|
default = "AuraZone::None",
|
||||||
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
|
||||||
)]
|
)]
|
||||||
pub zone: AuraZone,
|
pub zone: AuraZone,
|
||||||
|
|||||||
@@ -198,25 +198,46 @@ fn do_parsed(
|
|||||||
CliCommand::Scsi(cmd) => handle_scsi(cmd)?,
|
CliCommand::Scsi(cmd) => handle_scsi(cmd)?,
|
||||||
CliCommand::Armoury(cmd) => handle_armoury_command(cmd)?,
|
CliCommand::Armoury(cmd) => handle_armoury_command(cmd)?,
|
||||||
CliCommand::Backlight(cmd) => handle_backlight(cmd)?,
|
CliCommand::Backlight(cmd) => handle_backlight(cmd)?,
|
||||||
CliCommand::Battery(cmd) => match &cmd.command {
|
CliCommand::Battery(cmd) => handle_battery(cmd, &conn)?,
|
||||||
|
CliCommand::Info(info_opt) => {
|
||||||
|
handle_info(info_opt, supported_interfaces, supported_properties)?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_battery(
|
||||||
|
cmd: &BatteryCommand,
|
||||||
|
conn: &Connection,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
match &cmd.command {
|
||||||
BatterySubCommand::Limit(l) => {
|
BatterySubCommand::Limit(l) => {
|
||||||
let proxy = PlatformProxyBlocking::new(&conn)?;
|
let proxy = PlatformProxyBlocking::new(conn)?;
|
||||||
proxy.set_charge_control_end_threshold(l.limit)?;
|
proxy.set_charge_control_end_threshold(l.limit)?;
|
||||||
}
|
}
|
||||||
BatterySubCommand::OneShot(o) => {
|
BatterySubCommand::OneShot(o) => {
|
||||||
let proxy = PlatformProxyBlocking::new(&conn)?;
|
let proxy = PlatformProxyBlocking::new(conn)?;
|
||||||
if let Some(p) = o.percent {
|
if let Some(p) = o.percent {
|
||||||
proxy.set_charge_control_end_threshold(p)?;
|
proxy.set_charge_control_end_threshold(p)?;
|
||||||
}
|
}
|
||||||
proxy.one_shot_full_charge()?;
|
proxy.one_shot_full_charge()?;
|
||||||
}
|
}
|
||||||
BatterySubCommand::Info(_) => {
|
BatterySubCommand::Info(_) => {
|
||||||
let proxy = PlatformProxyBlocking::new(&conn)?;
|
let proxy = PlatformProxyBlocking::new(conn)?;
|
||||||
let limit = proxy.charge_control_end_threshold()?;
|
let limit = proxy.charge_control_end_threshold()?;
|
||||||
println!("Current battery charge limit: {}%", limit);
|
println!("Current battery charge limit: {}%", limit);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
CliCommand::Info(info_opt) => {
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_info(
|
||||||
|
info_opt: &InfoCommand,
|
||||||
|
supported_interfaces: &[String],
|
||||||
|
supported_properties: &[Properties],
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
|
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
|
||||||
println!();
|
println!();
|
||||||
print_info();
|
print_info();
|
||||||
@@ -242,8 +263,6 @@ fn do_parsed(
|
|||||||
println!("No aura interface found");
|
println!("No aura interface found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user