mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
rog-platform: additional check against manufacturer attr
Should close #242
This commit is contained in:
@@ -39,7 +39,8 @@ impl GetSupported for CtrlKbdLed {
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(p) = KeyboardLed::new() {
|
||||
let rgb = KeyboardLed::new();
|
||||
if let Ok(p) = rgb.as_ref() {
|
||||
if p.has_kbd_rgb_mode() {
|
||||
prod_id = AuraDevice::Tuf;
|
||||
}
|
||||
@@ -47,7 +48,7 @@ impl GetSupported for CtrlKbdLed {
|
||||
|
||||
LedSupportedFunctions {
|
||||
prod_id,
|
||||
brightness_set: KeyboardLed::new().is_ok(),
|
||||
brightness_set: rgb.is_ok(),
|
||||
stock_led_modes,
|
||||
multizone_led_mode,
|
||||
per_key_led_mode,
|
||||
@@ -186,10 +187,9 @@ impl CtrlKbdLed {
|
||||
}
|
||||
}
|
||||
|
||||
let bright_node = KeyboardLed::new();
|
||||
let platform = KeyboardLed::new()?;
|
||||
let rgb_led = KeyboardLed::new()?;
|
||||
|
||||
if led_node.is_none() && !platform.has_kbd_rgb_mode() {
|
||||
if led_node.is_none() && !rgb_led.has_kbd_rgb_mode() {
|
||||
let dmi = sysfs_class::DmiId::default();
|
||||
if let Ok(prod_family) = dmi.product_family() {
|
||||
if prod_family.contains("TUF") {
|
||||
@@ -202,9 +202,9 @@ impl CtrlKbdLed {
|
||||
let led_node = if let Some(rog) = led_node {
|
||||
info!("Found ROG USB keyboard");
|
||||
LEDNode::Rog(rog)
|
||||
} else if platform.has_kbd_rgb_mode() {
|
||||
} else if rgb_led.has_kbd_rgb_mode() {
|
||||
info!("Found TUF keyboard");
|
||||
LEDNode::KbdLed(platform)
|
||||
LEDNode::KbdLed(rgb_led.clone())
|
||||
} else {
|
||||
LEDNode::None
|
||||
};
|
||||
@@ -212,7 +212,7 @@ impl CtrlKbdLed {
|
||||
let ctrl = CtrlKbdLed {
|
||||
led_prod,
|
||||
led_node,
|
||||
kd_brightness: bright_node?, // If was none then we already returned above
|
||||
kd_brightness: rgb_led, // If was none then we already returned above
|
||||
supported_modes,
|
||||
flip_effect_write: false,
|
||||
config,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use log::warn;
|
||||
use log::{info, warn};
|
||||
|
||||
use crate::{
|
||||
attr_u8,
|
||||
@@ -36,6 +36,7 @@ impl KeyboardLed {
|
||||
warn!("{}", err);
|
||||
PlatformError::Udev("scan_devices failed".into(), err)
|
||||
})? {
|
||||
info!("Found keyboard LED controls at {:?}", device.sysname());
|
||||
return Ok(Self {
|
||||
path: device.syspath().to_owned(),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use log::warn;
|
||||
use log::{info, warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zvariant::Type;
|
||||
|
||||
@@ -41,6 +41,7 @@ impl AsusPlatform {
|
||||
warn!("{}", err);
|
||||
PlatformError::Udev("scan_devices failed".into(), err)
|
||||
})? {
|
||||
info!("Found platform support at {:?}", device.sysname());
|
||||
return Ok(Self {
|
||||
path: device.syspath().to_owned(),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use log::warn;
|
||||
use log::{info, warn};
|
||||
|
||||
use crate::{
|
||||
attr_u8,
|
||||
@@ -43,9 +43,25 @@ impl AsusPower {
|
||||
})? {
|
||||
if let Some(attr) = device.attribute_value("type") {
|
||||
match attr.to_os_string().as_os_str().to_str() {
|
||||
Some("Mains") => mains = device.syspath().to_path_buf(),
|
||||
Some("Battery") => battery = device.syspath().to_path_buf(),
|
||||
Some("USB") => usb = Some(device.syspath().to_path_buf()),
|
||||
Some("Mains") => {
|
||||
info!("Found mains power at {:?}", device.sysname());
|
||||
mains = device.syspath().to_path_buf();
|
||||
}
|
||||
Some("Battery") => {
|
||||
// This check required due to an instance where another "not"
|
||||
// battery can be found
|
||||
if let Some(m) = device.attribute_value("manufacturer") {
|
||||
// Should always be ASUSTeK, but match on a lowercase part to be sure
|
||||
if m.to_string_lossy().to_lowercase().contains("asus") {
|
||||
info!("Found battery power at {:?}", device.sysname());
|
||||
battery = device.syspath().to_path_buf();
|
||||
}
|
||||
}
|
||||
}
|
||||
Some("USB") => {
|
||||
info!("Found USB-C power at {:?}", device.sysname());
|
||||
usb = Some(device.syspath().to_path_buf());
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user