mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Trial fix for 1854
This commit is contained in:
@@ -281,21 +281,39 @@ impl CtrlKbdBacklight {
|
||||
config: Arc<Mutex<Config>>,
|
||||
) -> Result<Self, RogError> {
|
||||
// TODO: return error if *all* nodes are None
|
||||
let led_node = Self::get_node_failover(
|
||||
id_product,
|
||||
None,
|
||||
Self::scan_led_node,
|
||||
).map_or_else(|err| {
|
||||
warn!("led_node: {}", err);
|
||||
None
|
||||
}, |node| Some(node));
|
||||
|
||||
let kbd_node = Self::get_node_failover(
|
||||
id_product,
|
||||
condev_iface,
|
||||
Self::scan_kbd_node,
|
||||
).map_or_else(|err| {
|
||||
warn!("kbd_node: {}", err);
|
||||
None
|
||||
}, |node| Some(node));
|
||||
|
||||
let bright_node = Self::get_kbd_bright_path();
|
||||
|
||||
if led_node.is_none() && kbd_node.is_none() && Self::get_kbd_bright_path().is_err() {
|
||||
return Err(RogError::MissingFunction(
|
||||
"All keyboard features missing, you may require a v5.11 series kernel or newer".into(),
|
||||
));
|
||||
}
|
||||
|
||||
let ctrl = CtrlKbdBacklight {
|
||||
// Using `ok` here so we can continue without keyboard features but
|
||||
// still get brightness control at least... maybe...
|
||||
led_node: Some(Self::get_node_failover(
|
||||
id_product,
|
||||
None,
|
||||
Self::scan_led_node,
|
||||
)?),
|
||||
kbd_node: Some(Self::get_node_failover(
|
||||
id_product,
|
||||
condev_iface,
|
||||
Self::scan_kbd_node,
|
||||
)?),
|
||||
led_node,
|
||||
kbd_node,
|
||||
// TODO: Check for existance
|
||||
bright_node: Self::get_kbd_bright_path()?.to_owned(),
|
||||
bright_node: bright_node?.to_owned(),
|
||||
supported_modes,
|
||||
flip_effect_write: false,
|
||||
config,
|
||||
@@ -318,23 +336,12 @@ impl CtrlKbdBacklight {
|
||||
iface: Option<&String>,
|
||||
fun: fn(&str, Option<&String>) -> Result<String, RogError>,
|
||||
) -> Result<String, RogError> {
|
||||
// We do three tries here just to be certain that we avoid systemd unit
|
||||
// load order issues
|
||||
for n in 0..=2 {
|
||||
// 0,1,2 inclusive
|
||||
match fun(id_product, iface) {
|
||||
Ok(o) => return Ok(o),
|
||||
Err(e) => {
|
||||
if n == 2 {
|
||||
warn!("Looking for node: {}", e.to_string());
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
match fun(id_product, iface) {
|
||||
Ok(o) => return Ok(o),
|
||||
Err(e) => {
|
||||
warn!("Looking for node: {}", e.to_string());
|
||||
}
|
||||
}
|
||||
// Shouldn't be possible to reach this...
|
||||
Err(RogError::NotFound(format!("{}, {:?}", id_product, iface)))
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
)
|
||||
.map_err(|err| {
|
||||
error!("Keyboard control: {}", err);
|
||||
err
|
||||
}) {
|
||||
let tmp = Arc::new(Mutex::new(ctrl));
|
||||
DbusKbdBacklight::new(tmp.clone()).add_to_server(&mut object_server);
|
||||
@@ -181,7 +182,10 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
object_server.with(&"/org/asuslinux/Charge".try_into()?, |obj: &CtrlCharge| {
|
||||
let x = obj.limit();
|
||||
obj.notify_charge(x as u8)
|
||||
})?;
|
||||
}).map_err(|err| {
|
||||
warn!("object_server notify_charge error: {}", err);
|
||||
})
|
||||
.ok();
|
||||
|
||||
loop {
|
||||
if let Err(err) = object_server.try_handle_next() {
|
||||
|
||||
Reference in New Issue
Block a user