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