1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

config: modularize; add config watcher and move error variants

This commit is contained in:
NotAShelf 2025-05-14 01:17:42 +03:00
parent dde938b638
commit 9f7d86ff01
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
10 changed files with 349 additions and 126 deletions

View file

@ -1,11 +1,10 @@
use crate::config::AppConfig;
use crate::core::{BatteryInfo, CpuCoreInfo, CpuGlobalInfo, SystemInfo, SystemLoad, SystemReport};
use crate::cpu::{get_logical_core_count, get_platform_profiles};
use crate::util::error::ControlError;
use crate::cpu::get_logical_core_count;
use crate::util::error::SysMonitorError;
use std::{
collections::HashMap,
fs, io,
fs,
path::{Path, PathBuf},
str::FromStr,
thread,
@ -13,8 +12,6 @@ use std::{
time::SystemTime,
};
impl std::error::Error for SysMonitorError {}
pub type Result<T, E = SysMonitorError> = std::result::Result<T, E>;
// Read a sysfs file to a string, trimming whitespace
@ -417,8 +414,8 @@ pub fn get_cpu_global_info(cpu_cores: &[CpuCoreInfo]) -> CpuGlobalInfo {
None
};
let available_governors = if cpufreq_base.join("scaling_available_governors").exists() {
read_sysfs_file_trimmed(cpufreq_base.join("scaling_available_governors")).map_or_else(
let available_governors = if cpufreq_base_path.join("scaling_available_governors").exists() {
read_sysfs_file_trimmed(cpufreq_base_path.join("scaling_available_governors")).map_or_else(
|_| vec![],
|s| s.split_whitespace().map(String::from).collect(),
)