Skip to content

Commit

Permalink
Recognize the backlight on x86 Macs
Browse files Browse the repository at this point in the history
  • Loading branch information
kekrby authored and sharpenedblade committed Mar 27, 2024
1 parent 10cdf1d commit 9d79a85
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/backlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ fn read_attr(path: &Path, attr: &str) -> u32 {
fn find_backlight() -> Result<PathBuf> {
for entry in fs::read_dir("/sys/class/backlight/")? {
let entry = entry?;
if entry.file_name().to_string_lossy().contains("display-pipe") {
let file_name = entry.file_name();
let name = file_name.to_string_lossy();

if ["display-pipe", "appletb_backlight"].iter().any(|s| name.contains(s)) {
return Ok(entry.path());
}
}
Expand All @@ -39,7 +42,7 @@ fn find_backlight() -> Result<PathBuf> {
fn find_display_backlight() -> Result<PathBuf> {
for entry in fs::read_dir("/sys/class/backlight/")? {
let entry = entry?;
if entry.file_name().to_string_lossy().eq("apple-panel-bl") {
if ["apple_panel_bl", "intel_backlight"].iter().any(|s| entry.file_name().to_string_lossy().contains(s)) {
return Ok(entry.path());
}
}
Expand Down

0 comments on commit 9d79a85

Please sign in to comment.