Cleanup unsafe sysfs interfaces. Bugfixes for UI

This commit is contained in:
Luke D. Jones
2025-01-16 23:56:12 +13:00
parent 7a1b45071d
commit 2b22f82b72
22 changed files with 379 additions and 553 deletions

View File

@@ -157,6 +157,25 @@ impl Attribute {
default_value, possible_values, min_value, max_value, scalar_increment
)
}
pub fn get_watcher(&self) -> Result<inotify::Inotify, PlatformError> {
let path = self.base_path.join("current_value");
if let Some(path) = path.to_str() {
let inotify = inotify::Inotify::init()?;
inotify
.watches()
.add(path, inotify::WatchMask::MODIFY)
.map_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound {
PlatformError::AttrNotFound(self.name().to_string())
} else {
PlatformError::IoPath(path.to_string(), e)
}
})?;
return Ok(inotify);
}
Err(PlatformError::AttrNotFound(self.name().to_string()))
}
}
pub struct FirmwareAttributes {

View File

@@ -1,9 +1,9 @@
//! This crate functions as a wrapper of all the relevant ASUS functionality
//! on ROG, Strix, and TUF laptops.
pub mod asus_armoury;
pub mod cpu;
pub mod error;
pub mod firmware_attributes;
pub mod hid_raw;
pub mod keyboard_led;
pub(crate) mod macros;

View File

@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::{PlatformError, Result};
use crate::{attr_bool, attr_string, attr_u8, to_device};
use crate::{attr_string, attr_u8, to_device};
/// The "platform" device provides access to things like:
/// - `dgpu_disable`
@@ -24,16 +24,6 @@ pub struct RogPlatform {
}
impl RogPlatform {
attr_bool!("dgpu_disable", path);
attr_bool!("egpu_enable", path);
attr_u8!("gpu_mux_mode", path);
attr_bool!("panel_od", path);
attr_bool!("mini_led_mode", path);
attr_u8!(
/// This is technically the same as `platform_profile` since both are
/// tied in-kernel
@@ -47,12 +37,6 @@ impl RogPlatform {
pp_path
);
attr_bool!(
/// Control the POST animation "FWOOoosh" sound
"boot_sound",
path
);
pub fn new() -> Result<Self> {
let mut enumerator = udev::Enumerator::new().map_err(|err| {
warn!("{}", err);