Use enable/disable commands and cleanup build warnings

This commit is contained in:
jochen@g14
2024-03-31 00:34:44 +01:00
parent 2f73577e91
commit 4468a58487
7 changed files with 18 additions and 16 deletions

View File

@@ -1,4 +1,3 @@
use std::fmt::Display;
use std::str::FromStr;
use gumdrop::Options;

View File

@@ -485,11 +485,12 @@ fn handle_slash(
cmd: &SlashCommand,
) -> Result<(), Box<dyn std::error::Error>> {
if (
cmd.enabled.is_none() &&
cmd.brightness.is_none() &&
cmd.interval.is_none() &&
cmd.slash_mode.is_none() &&
!cmd.list
!cmd.list &&
!cmd.enable &&
!cmd.disable
) || cmd.help
{
println!("Missing arg or command\n\n{}", cmd.self_usage());
@@ -497,8 +498,11 @@ fn handle_slash(
println!("\n{}", lst);
}
}
if let Some(enabled) = cmd.enabled {
dbus.proxies().slash().set_enabled(enabled)?;
if cmd.enable {
dbus.proxies().slash().set_enabled(true)?;
}
if cmd.disable {
dbus.proxies().slash().set_enabled(false)?;
}
if let Some(brightness) = cmd.brightness {
dbus.proxies().slash().set_brightness(brightness)?;

View File

@@ -5,13 +5,15 @@ use rog_slash::SlashMode;
pub struct SlashCommand {
#[options(help = "print help message")]
pub help: bool,
#[options(meta = "", help = "enable/disable the display")]
pub enabled: Option<bool>,
#[options(meta = "", help = "set brightness value <0-255>")]
#[options(help = "Enable the Slash Ledbar")]
pub enable: bool,
#[options(help = "Ddisable the Slash Ledbar")]
pub disable: bool,
#[options(meta = "", help = "Set brightness value <0-255>")]
pub brightness: Option<u8>,
#[options(meta = "", help = "set interval value <0-255>")]
#[options(meta = "", help = "Set interval value <0-255>")]
pub interval: Option<u8>,
#[options(help = "Set the SlashMode")]
#[options(help = "Set SlashMode (so 'list' for all options)")]
pub slash_mode: Option<SlashMode>,
#[options(help = "list available animations")]
pub list: bool,

View File

@@ -5,7 +5,6 @@
// - If udev sees device removed then remove the zbus path
use std::collections::HashSet;
use std::time::Duration;
use log::{debug, error, info, warn};
use mio::{Events, Interest, Poll, Token};

View File

@@ -33,7 +33,7 @@ pub struct CtrlSlash {
// node: HidRaw,
node: Node,
config: SlashConfig,
slash_type: SlashType,
// slash_type: SlashType,
// // set to force thread to exit
// thread_exit: Arc<AtomicBool>,
// // Set to false when the thread exits
@@ -53,7 +53,6 @@ impl CtrlSlash {
return Err(RogError::NotSupported);
};
// Maybe, detecting the slash-type may become necessary
let slash_type = get_slash_type()?;
if slash_type == SlashType::Unknown {
return Err(RogError::Slash(SlashError::NoDevice));
@@ -62,7 +61,7 @@ impl CtrlSlash {
let ctrl = CtrlSlash {
node,
config,
slash_type,
// slash_type,
// thread_exit: Arc::new(AtomicBool::new(false)),
// thread_running: Arc::new(AtomicBool::new(false)),
};

View File

@@ -32,7 +32,7 @@ fn main() -> Result<()> {
let board_name = dmi.board_name;
let prod_family = dmi.product_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
let _tmp_dir = tempfile::Builder::new()

View File

@@ -1,4 +1,3 @@
use std::any::Any;
use std::fmt::Display;
use std::str::FromStr;