mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Use enable/disable commands and cleanup build warnings
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
use std::fmt::Display;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use gumdrop::Options;
|
use gumdrop::Options;
|
||||||
|
|||||||
@@ -485,11 +485,12 @@ fn handle_slash(
|
|||||||
cmd: &SlashCommand,
|
cmd: &SlashCommand,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
if (
|
if (
|
||||||
cmd.enabled.is_none() &&
|
|
||||||
cmd.brightness.is_none() &&
|
cmd.brightness.is_none() &&
|
||||||
cmd.interval.is_none() &&
|
cmd.interval.is_none() &&
|
||||||
cmd.slash_mode.is_none() &&
|
cmd.slash_mode.is_none() &&
|
||||||
!cmd.list
|
!cmd.list &&
|
||||||
|
!cmd.enable &&
|
||||||
|
!cmd.disable
|
||||||
) || cmd.help
|
) || cmd.help
|
||||||
{
|
{
|
||||||
println!("Missing arg or command\n\n{}", cmd.self_usage());
|
println!("Missing arg or command\n\n{}", cmd.self_usage());
|
||||||
@@ -497,8 +498,11 @@ fn handle_slash(
|
|||||||
println!("\n{}", lst);
|
println!("\n{}", lst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(enabled) = cmd.enabled {
|
if cmd.enable {
|
||||||
dbus.proxies().slash().set_enabled(enabled)?;
|
dbus.proxies().slash().set_enabled(true)?;
|
||||||
|
}
|
||||||
|
if cmd.disable {
|
||||||
|
dbus.proxies().slash().set_enabled(false)?;
|
||||||
}
|
}
|
||||||
if let Some(brightness) = cmd.brightness {
|
if let Some(brightness) = cmd.brightness {
|
||||||
dbus.proxies().slash().set_brightness(brightness)?;
|
dbus.proxies().slash().set_brightness(brightness)?;
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ use rog_slash::SlashMode;
|
|||||||
pub struct SlashCommand {
|
pub struct SlashCommand {
|
||||||
#[options(help = "print help message")]
|
#[options(help = "print help message")]
|
||||||
pub help: bool,
|
pub help: bool,
|
||||||
#[options(meta = "", help = "enable/disable the display")]
|
#[options(help = "Enable the Slash Ledbar")]
|
||||||
pub enabled: Option<bool>,
|
pub enable: bool,
|
||||||
#[options(meta = "", help = "set brightness value <0-255>")]
|
#[options(help = "Ddisable the Slash Ledbar")]
|
||||||
|
pub disable: bool,
|
||||||
|
#[options(meta = "", help = "Set brightness value <0-255>")]
|
||||||
pub brightness: Option<u8>,
|
pub brightness: Option<u8>,
|
||||||
#[options(meta = "", help = "set interval value <0-255>")]
|
#[options(meta = "", help = "Set interval value <0-255>")]
|
||||||
pub interval: Option<u8>,
|
pub interval: Option<u8>,
|
||||||
#[options(help = "Set the SlashMode")]
|
#[options(help = "Set SlashMode (so 'list' for all options)")]
|
||||||
pub slash_mode: Option<SlashMode>,
|
pub slash_mode: Option<SlashMode>,
|
||||||
#[options(help = "list available animations")]
|
#[options(help = "list available animations")]
|
||||||
pub list: bool,
|
pub list: bool,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
// - If udev sees device removed then remove the zbus path
|
// - If udev sees device removed then remove the zbus path
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use mio::{Events, Interest, Poll, Token};
|
use mio::{Events, Interest, Poll, Token};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub struct CtrlSlash {
|
|||||||
// node: HidRaw,
|
// node: HidRaw,
|
||||||
node: Node,
|
node: Node,
|
||||||
config: SlashConfig,
|
config: SlashConfig,
|
||||||
slash_type: SlashType,
|
// slash_type: SlashType,
|
||||||
// // set to force thread to exit
|
// // set to force thread to exit
|
||||||
// thread_exit: Arc<AtomicBool>,
|
// thread_exit: Arc<AtomicBool>,
|
||||||
// // Set to false when the thread exits
|
// // Set to false when the thread exits
|
||||||
@@ -53,7 +53,6 @@ impl CtrlSlash {
|
|||||||
return Err(RogError::NotSupported);
|
return Err(RogError::NotSupported);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Maybe, detecting the slash-type may become necessary
|
|
||||||
let slash_type = get_slash_type()?;
|
let slash_type = get_slash_type()?;
|
||||||
if slash_type == SlashType::Unknown {
|
if slash_type == SlashType::Unknown {
|
||||||
return Err(RogError::Slash(SlashError::NoDevice));
|
return Err(RogError::Slash(SlashError::NoDevice));
|
||||||
@@ -62,7 +61,7 @@ impl CtrlSlash {
|
|||||||
let ctrl = CtrlSlash {
|
let ctrl = CtrlSlash {
|
||||||
node,
|
node,
|
||||||
config,
|
config,
|
||||||
slash_type,
|
// slash_type,
|
||||||
// thread_exit: Arc::new(AtomicBool::new(false)),
|
// thread_exit: Arc::new(AtomicBool::new(false)),
|
||||||
// thread_running: Arc::new(AtomicBool::new(false)),
|
// thread_running: Arc::new(AtomicBool::new(false)),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fn main() -> Result<()> {
|
|||||||
let board_name = dmi.board_name;
|
let board_name = dmi.board_name;
|
||||||
let prod_family = dmi.product_family;
|
let prod_family = dmi.product_family;
|
||||||
info!("Running on {board_name}, product: {prod_family}");
|
info!("Running on {board_name}, product: {prod_family}");
|
||||||
let is_rog_ally = prod_family == "RC71L";
|
// let is_rog_ally = prod_family == "RC71L";
|
||||||
|
|
||||||
// tmp-dir must live to the end of program life
|
// tmp-dir must live to the end of program life
|
||||||
let _tmp_dir = tempfile::Builder::new()
|
let _tmp_dir = tempfile::Builder::new()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::any::Any;
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user