Fix: non-rgb keyboard backlight control

This commit is contained in:
Luke D Jones
2021-03-23 13:44:07 +13:00
parent 96ceef1bdb
commit df7ae4d014
6 changed files with 35 additions and 29 deletions

View File

@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
# [3.2.2] - 2021-03-23
### Changed
- Fix brightness control, again, for non-RGB keyboards
# [3.2.1] - 2021-03-21
### Changed
- Fix brightness control

2
Cargo.lock generated
View File

@@ -196,7 +196,7 @@ dependencies = [
[[package]]
name = "daemon"
version = "3.2.1"
version = "3.2.2"
dependencies = [
"env_logger",
"intel-pstate",

View File

@@ -1,6 +1,6 @@
[package]
name = "daemon"
version = "3.2.1"
version = "3.2.2"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -37,14 +37,10 @@ impl GetSupported for CtrlKbdBacklight {
let multizone_led_mode = false;
let per_key_led_mode = false;
let laptop = LaptopLedData::get_data();
let stock_led_modes = if let Some(data) = laptop {
if data.standard.is_empty() {
None
} else {
Some(data.standard)
}
} else {
let stock_led_modes = if laptop.standard.is_empty() {
None
} else {
Some(laptop.standard)
};
LedSupportedFunctions {

View File

@@ -135,23 +135,20 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
DbusFanAndCpu::new(tmp).add_to_server(&mut object_server);
};
if let Some(laptop) = LaptopLedData::get_data() {
if !laptop.standard.is_empty() {
let aura_config = AuraConfig::load(&laptop);
if let Ok(ctrl) = CtrlKbdBacklight::new(
laptop,
aura_config,
)
.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);
tasks.push(tmp);
}
}}
let laptop = LaptopLedData::get_data();
let aura_config = AuraConfig::load(&laptop);
if let Ok(ctrl) = CtrlKbdBacklight::new(
laptop,
aura_config,
)
.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);
tasks.push(tmp);
}
// TODO: implement messaging between threads to check fails
// These tasks generally read a sys path or file to check for a

View File

@@ -49,15 +49,24 @@ pub struct LaptopLedData {
}
impl LaptopLedData {
pub fn get_data() -> Option<Self> {
pub fn get_data() -> Self {
let dmi = sysfs_class::DmiId::default();
let board_name = dmi.board_name().expect("Could not get board_name");
let prod_family = dmi.product_family().expect("Could not get product_family");
if let Some(modes) = LedSupportFile::load_from_config() {
return modes.matcher(&prod_family, &board_name);
if let Some(data) = modes.matcher(&prod_family, &board_name) {
return data;
}
}
info!("Using generic LED control for keyboard brightness only");
LaptopLedData {
prod_family,
board_names: vec![board_name],
standard: vec![],
multizone: false,
per_key: false,
}
None
}
}