mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Allow changing of platform values with cli
This commit is contained in:
@@ -50,9 +50,12 @@ pub enum CliCommand {
|
|||||||
#[options(name = "scsi", help = "Manage SCSI external drive")]
|
#[options(name = "scsi", help = "Manage SCSI external drive")]
|
||||||
Scsi(ScsiCommand),
|
Scsi(ScsiCommand),
|
||||||
#[options(help = "Change bios settings")]
|
#[options(help = "Change bios settings")]
|
||||||
Platform(PlatformCommand),
|
PlatformOld(PlatformCommand),
|
||||||
#[options(help = "Change platform settings")]
|
#[options(
|
||||||
PlatformNew(PlatformNewCommand),
|
help = "Change platform settings. This is a new interface exposed by the asus-armoury \
|
||||||
|
driver, some of the settings will be the same as the older platform interface"
|
||||||
|
)]
|
||||||
|
Armoury(ArmouryCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Options)]
|
#[derive(Debug, Clone, Options)]
|
||||||
@@ -125,7 +128,7 @@ pub struct PlatformCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Options, Debug)]
|
#[derive(Options, Debug)]
|
||||||
pub struct PlatformNewCommand {
|
pub struct ArmouryCommand {
|
||||||
#[options(help = "print help message")]
|
#[options(help = "print help message")]
|
||||||
pub help: bool,
|
pub help: bool,
|
||||||
#[options(free)]
|
#[options(free)]
|
||||||
|
|||||||
@@ -186,10 +186,10 @@ fn do_parsed(
|
|||||||
Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?,
|
Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?,
|
||||||
Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?,
|
Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?,
|
||||||
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
|
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
|
||||||
Some(CliCommand::Platform(cmd)) => {
|
Some(CliCommand::PlatformOld(cmd)) => {
|
||||||
handle_platform_properties(&conn, supported_properties, cmd)?
|
handle_platform_properties(&conn, supported_properties, cmd)?
|
||||||
}
|
}
|
||||||
Some(CliCommand::PlatformNew(cmd)) => handle_platform_new_properties(&conn, cmd)?,
|
Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?,
|
||||||
None => {
|
None => {
|
||||||
if (!parsed.show_supported
|
if (!parsed.show_supported
|
||||||
&& parsed.kbd_bright.is_none()
|
&& parsed.kbd_bright.is_none()
|
||||||
@@ -245,6 +245,12 @@ fn do_parsed(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if command.trim().starts_with("platform")
|
||||||
|
&& !supported_interfaces.contains(&"xyz.ljones.AsusArmoury".to_string())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if !dev_type.is_old_laptop()
|
if !dev_type.is_old_laptop()
|
||||||
&& !dev_type.is_tuf_laptop()
|
&& !dev_type.is_tuf_laptop()
|
||||||
&& command.trim().starts_with("aura-power-old")
|
&& command.trim().starts_with("aura-power-old")
|
||||||
@@ -1070,10 +1076,60 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_platform_new_properties(
|
fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
conn: &Connection,
|
let name = attr.name()?;
|
||||||
cmd: &PlatformNewCommand,
|
println!("{name}:");
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
|
let attrs = attr.available_attrs()?;
|
||||||
|
if attrs.contains(&"min_value".to_string())
|
||||||
|
&& attrs.contains(&"max_value".to_string())
|
||||||
|
&& attrs.contains(&"current_value".to_string())
|
||||||
|
{
|
||||||
|
let c = attr.current_value()?;
|
||||||
|
let min = attr.min_value()?;
|
||||||
|
let max = attr.max_value()?;
|
||||||
|
println!(" current: {min}..[{c}]..{max}");
|
||||||
|
if attrs.contains(&"default_value".to_string()) {
|
||||||
|
println!(" default: {}\n", attr.default_value()?);
|
||||||
|
} else {
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
} else if attrs.contains(&"possible_values".to_string())
|
||||||
|
&& attrs.contains(&"current_value".to_string())
|
||||||
|
{
|
||||||
|
let c = attr.current_value()?;
|
||||||
|
let v = attr.possible_values()?;
|
||||||
|
for p in v.iter().enumerate() {
|
||||||
|
if p.0 == 0 {
|
||||||
|
print!(" current: [");
|
||||||
|
}
|
||||||
|
if *p.1 == c {
|
||||||
|
print!("({c})");
|
||||||
|
} else {
|
||||||
|
print!("{}", p.1);
|
||||||
|
}
|
||||||
|
if p.0 < v.len() - 1 {
|
||||||
|
print!(",");
|
||||||
|
}
|
||||||
|
if p.0 == v.len() - 1 {
|
||||||
|
print!("]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if attrs.contains(&"default_value".to_string()) {
|
||||||
|
println!(" default: {}\n", attr.default_value()?);
|
||||||
|
} else {
|
||||||
|
println!("\n");
|
||||||
|
}
|
||||||
|
} else if attrs.contains(&"current_value".to_string()) {
|
||||||
|
let c = attr.current_value()?;
|
||||||
|
println!(" current: {c}\n");
|
||||||
|
} else {
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
{
|
{
|
||||||
if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help {
|
if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help {
|
||||||
const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5";
|
const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5";
|
||||||
@@ -1089,85 +1145,20 @@ fn handle_platform_new_properties(
|
|||||||
println!("\n{USAGE}\n");
|
println!("\n{USAGE}\n");
|
||||||
println!("Available firmware attributes: ");
|
println!("Available firmware attributes: ");
|
||||||
for attr in attr.iter() {
|
for attr in attr.iter() {
|
||||||
let name = attr.name()?;
|
print_firmware_attr(attr)?;
|
||||||
println!("{name}:");
|
|
||||||
|
|
||||||
let attrs = attr.available_attrs()?;
|
|
||||||
if attrs.contains(&"min_value".to_string())
|
|
||||||
&& attrs.contains(&"max_value".to_string())
|
|
||||||
&& attrs.contains(&"current_value".to_string())
|
|
||||||
{
|
|
||||||
let c = attr.current_value()?;
|
|
||||||
let min = attr.min_value()?;
|
|
||||||
let max = attr.max_value()?;
|
|
||||||
println!(" current: {min}..[{c}]..{max}");
|
|
||||||
if attrs.contains(&"default_value".to_string()) {
|
|
||||||
println!(" default: {}\n", attr.default_value()?);
|
|
||||||
} else {
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
} else if attrs.contains(&"possible_values".to_string())
|
|
||||||
&& attrs.contains(&"current_value".to_string())
|
|
||||||
{
|
|
||||||
let c = attr.current_value()?;
|
|
||||||
let v = attr.possible_values()?;
|
|
||||||
for p in v.iter().enumerate() {
|
|
||||||
if p.0 == 0 {
|
|
||||||
print!(" current: [");
|
|
||||||
}
|
|
||||||
if *p.1 == c {
|
|
||||||
print!("({c})");
|
|
||||||
} else {
|
|
||||||
print!("{}", p.1);
|
|
||||||
}
|
|
||||||
if p.0 < v.len() - 1 {
|
|
||||||
print!(",");
|
|
||||||
}
|
|
||||||
if p.0 == v.len() - 1 {
|
|
||||||
print!("]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if attrs.contains(&"default_value".to_string()) {
|
|
||||||
println!(" default: {}\n", attr.default_value()?);
|
|
||||||
} else {
|
|
||||||
println!("\n");
|
|
||||||
}
|
|
||||||
} else if attrs.contains(&"current_value".to_string()) {
|
|
||||||
let c = attr.current_value()?;
|
|
||||||
println!(" current: {c}\n");
|
|
||||||
} else {
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
|
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
|
||||||
for attr in attr.iter() {
|
for cmd in cmd.free.chunks(2) {
|
||||||
let name = attr.name()?;
|
for attr in attr.iter() {
|
||||||
let attrs = attr.available_attrs()?;
|
let name = attr.name()?;
|
||||||
// dbg!(&name, &attrs);
|
if name == cmd[0] {
|
||||||
println!("{name}::");
|
attr.set_current_value(cmd[1].parse()?)?;
|
||||||
if attrs.contains(&"current_value".to_string()) {
|
print_firmware_attr(attr)?;
|
||||||
let v = attr.current_value()?;
|
}
|
||||||
println!(" current_value: {v}");
|
|
||||||
}
|
|
||||||
if attrs.contains(&"default_value".to_string()) {
|
|
||||||
let v = attr.default_value()?;
|
|
||||||
println!(" default_value: {v:?}");
|
|
||||||
}
|
|
||||||
if attrs.contains(&"min_value".to_string()) {
|
|
||||||
let v = attr.min_value()?;
|
|
||||||
println!(" min_value: {v:?}");
|
|
||||||
}
|
|
||||||
if attrs.contains(&"max_value".to_string()) {
|
|
||||||
let v = attr.max_value()?;
|
|
||||||
println!(" max_value: {v}");
|
|
||||||
}
|
|
||||||
if attrs.contains(&"possible_values".to_string()) {
|
|
||||||
let v = attr.possible_values()?;
|
|
||||||
println!(" possible_values: {v:?}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2024-12-28 22:36+0000\n"
|
"POT-Creation-Date: 2024-12-28 22:48+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user