mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Break config-traits out in to crate
This commit is contained in:
13
Cargo.lock
generated
13
Cargo.lock
generated
@@ -657,6 +657,17 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "config-traits"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ron",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.3"
|
||||
@@ -782,6 +793,7 @@ version = "4.5.8"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"concat-idents",
|
||||
"config-traits",
|
||||
"env_logger",
|
||||
"log",
|
||||
"logind-zbus",
|
||||
@@ -797,7 +809,6 @@ dependencies = [
|
||||
"sysfs-class",
|
||||
"systemd-zbus",
|
||||
"tokio",
|
||||
"toml",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[workspace]
|
||||
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
|
||||
members = ["asusctl", "config-traits", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
|
||||
|
||||
[workspace.package]
|
||||
version = "4.5.8"
|
||||
|
||||
63
MANUAL.md
63
MANUAL.md
@@ -47,35 +47,7 @@ The LED controller (e.g, aura) enables setting many of the factory modes availab
|
||||
|
||||
#### Supported laptops
|
||||
|
||||
Models GA401, GA502, GU502 support LED brightness change only (no RGB). However the GA401Q model can actually use three modes; static, breathe, and pulse, plus also use red to control the LED brightness intensity.
|
||||
|
||||
All models that have any form of LED mode control need to be enabled via the config file at `/etc/asusd/asusd-ledmodes.toml`. Unfortunately ASUS doesn't provide any easy way to find all the supported modes for all laptops (not even through Armory Crate and its various files, that progrma downloads only the required settings for the laptop it runs on) so each model must be added as needed.
|
||||
|
||||
#### Config options
|
||||
|
||||
The defaults are located at `/etc/asusd/asusd-ledmodes.toml`, and on `asusd` start it creates `/etc/asusd/aura.conf` whcih stores the per-mode settings. If you edit the defaults file you must remove `/etc/asusd/aura.conf` and restart `asusd.service` with `systemctl restart asusd`.
|
||||
|
||||
##### /etc/asusd/asusd-ledmodes.toml
|
||||
|
||||
Example:
|
||||
```toml
|
||||
[[led_data]]
|
||||
prod_family = "Strix"
|
||||
board_names = ["GL504G"]
|
||||
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"]
|
||||
multizone = ["Key1", "Key2", "Key3", "Key4", "Logo", "BarLeft", "BarRight"]
|
||||
per_key = false
|
||||
```
|
||||
|
||||
1. `prod_family`: you can find this in `journalctl -b -u asusd`, or `cat /sys/class/dmi/id/product_name`. It should be copied as written. There can be multiple `led-data` groups of the same `prod_family` with differing `board_names`.
|
||||
2. `board_names`: is an array of board names in this product family. Find this in the journal as above or by `cat /sys/class/dmi/id/board_name`.
|
||||
3. `standard` are the factory preset modes, the names should corrospond to Armory Crate names
|
||||
4. `multizone`: some models have 4 to 7 zones of LED control as shown in the example. If the laptop has no zones then an empty array will suffice.
|
||||
5. `per_key`: enable per-key RGB effects. The keyboard must support this or it has no effect.
|
||||
|
||||
##### /etc/asusd/aura.conf
|
||||
|
||||
This file can be manually edited if desired, but the `asusctl` CLI tool, or dbus methods are the preferred method. Any manual changes to this file mean that the `asusd.service` will need to be restarted, or you need to cycle between modes to force a reload.
|
||||
There are over 60 supported laptops as of 01-01-2023. Please see [the rog-aura crate readme for further details](/rog-aura/README.md).
|
||||
|
||||
### Charge control
|
||||
|
||||
@@ -199,33 +171,20 @@ An Aura config itself is a file with contents:
|
||||
|
||||
If your laptop supports multizone, `"led_type"` can also be `"Zone": <one of the following>`
|
||||
- `"None"`
|
||||
- `"KeyboardLeft"`
|
||||
- `"KeyboardCenterLeft"`
|
||||
- `"KeyboardCenterRight"`
|
||||
- `"KeyboardRight"`
|
||||
- `"LightbarRight"`
|
||||
- `"LightbarRightCorner"`
|
||||
- `"LightbarRightBottom"`
|
||||
- `"LightbarLeftBottom"`
|
||||
- `"LightbarLeftCorner"`
|
||||
- `"LightbarLeft"`
|
||||
- `ZonedKbLeft` // keyboard left
|
||||
- `ZonedKbLeftMid` // keyboard left-middle
|
||||
- `ZonedKbRightMid` // etc
|
||||
- `ZonedKbRight`
|
||||
- `LightbarRight`
|
||||
- `LightbarRightCorner`
|
||||
- `LightbarRightBottom`
|
||||
- `LightbarLeftBottom`
|
||||
- `LightbarLeftCorner`
|
||||
- `LightbarLeft`
|
||||
|
||||
At the moment there are only three effects available as shown in the example. More will come in the future
|
||||
but this may take me some time.
|
||||
|
||||
**Aura layouts**: `asusd-user` does its best to find a suitable layout to use based on `/sys/class/dmi/id/board_name`.
|
||||
It looks at each of the files in `/usr/share/rog-gui/layouts/` and matches against the toml block looking like:
|
||||
```toml
|
||||
matches = [
|
||||
'GX502',
|
||||
'GU502',
|
||||
]
|
||||
```
|
||||
|
||||
My laptop is a `GX502GW`, so `GX502` is a match. Note that these layouts are the physical representation of
|
||||
the keyboard and are used in the GUI also. The config that tells if per-key is supported is located in
|
||||
`/etc/asusd/asusd-ledmodes.toml`
|
||||
|
||||
#### Config options: AniMe
|
||||
|
||||
`~/.config/rog/rog-user.cfg` contains a setting `"active_anime": "<FILENAME>"` where `<FILENAME>` is the name of the AniMe config to use, located in the same directory and without the file postfix, e.g, `"active_anime": "anime-doom"`
|
||||
|
||||
@@ -13,6 +13,8 @@ Now includes a GUI, `rog-control-center`.
|
||||
|
||||
**The minimum supported kernel version is 5.17**
|
||||
|
||||
**For TUF laptops, the minimum supported kernel version is 6.1**
|
||||
|
||||
## Goals
|
||||
|
||||
1. To provide an interface for rootless control of some system functions most users wish to control such as fan speeds, keyboard LEDs, graphics modes.
|
||||
@@ -43,8 +45,6 @@ Bus 001 Device 002: ID 0b05:1866 ASUSTek Computer, Inc. N-KEY Device
|
||||
then it may work without tweaks. Technically all other functions except the LED
|
||||
and AniMe parts should work regardless of your latop make.
|
||||
|
||||
**TUF Laptops**: now supported provided the kernel is patched. These patches are submitted upstream and will be in version 6.1.x of the kernel (or thereabouts). See the blog on asus-linux.org for more info.
|
||||
|
||||
## Implemented
|
||||
|
||||
- [X] System daemon
|
||||
|
||||
14
config-traits/Cargo.toml
Normal file
14
config-traits/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "config-traits"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
serde_json.workspace = true
|
||||
ron.workspace = true
|
||||
|
||||
log.workspace = true
|
||||
@@ -7,8 +7,6 @@ use ron::ser::PrettyConfig;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
|
||||
const CONFIG_PATH_BASE: &str = "/etc/asusd/";
|
||||
|
||||
/// Config file helper traits. Only `new()` and `file_name()` are required to be
|
||||
/// implemented, the rest are intended to be free methods.
|
||||
pub trait StdConfig
|
||||
@@ -19,11 +17,13 @@ where
|
||||
|
||||
fn file_name() -> &'static str;
|
||||
|
||||
fn config_dir() -> PathBuf;
|
||||
|
||||
fn file_path() -> PathBuf {
|
||||
let mut config = PathBuf::from(CONFIG_PATH_BASE);
|
||||
let mut config = Self::config_dir();
|
||||
if !config.exists() {
|
||||
create_dir(config.as_path())
|
||||
.unwrap_or_else(|e| panic!("Could not create {CONFIG_PATH_BASE} {e}"));
|
||||
.unwrap_or_else(|e| panic!("Could not create {:?} {e}", Self::config_dir()));
|
||||
}
|
||||
config.push(Self::file_name());
|
||||
config
|
||||
@@ -18,6 +18,7 @@ name = "asusd"
|
||||
path = "src/daemon.rs"
|
||||
|
||||
[dependencies]
|
||||
config-traits = { path = "../config-traits" }
|
||||
rog_anime = { path = "../rog-anime", features = ["dbus"] }
|
||||
rog_aura = { path = "../rog-aura", features = ["dbus"] }
|
||||
rog_platform = { path = "../rog-platform" }
|
||||
@@ -38,7 +39,6 @@ logind-zbus.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
serde_json.workspace = true
|
||||
toml.workspace = true
|
||||
ron.workspace = true
|
||||
|
||||
# Device control
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use config_traits::{StdConfig, StdConfigLoad3};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::config_traits::{StdConfig, StdConfigLoad3};
|
||||
|
||||
const CONFIG_FILE: &str = "asusd.conf";
|
||||
|
||||
#[derive(Deserialize, Serialize, Default)]
|
||||
@@ -25,6 +24,10 @@ impl StdConfig for Config {
|
||||
}
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name() -> &'static str {
|
||||
CONFIG_FILE
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad3};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::{ActionData, ActionLoader, AnimTime, AnimeType, Fade, Vec2};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::config_traits::{StdConfig, StdConfigLoad3};
|
||||
|
||||
const CONFIG_FILE: &str = "anime.conf";
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
@@ -141,6 +140,10 @@ impl StdConfig for AnimeConfig {
|
||||
Self::create_default()
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name() -> &'static str {
|
||||
CONFIG_FILE
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{info, warn};
|
||||
use rog_anime::usb::{pkt_for_apply, pkt_for_set_boot, pkt_for_set_on};
|
||||
use rog_anime::{AnimeDataBuffer, AnimePowerStates};
|
||||
@@ -9,7 +10,6 @@ use zbus::export::futures_util::lock::{Mutex, MutexGuard};
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
|
||||
use super::CtrlAnime;
|
||||
use crate::config_traits::StdConfig;
|
||||
use crate::error::RogError;
|
||||
|
||||
pub(super) const ZBUS_PATH: &str = "/org/asuslinux/Anime";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad1};
|
||||
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
|
||||
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
|
||||
@@ -7,8 +8,6 @@ use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::keyboard_led::KeyboardLed;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::config_traits::{StdConfig, StdConfigLoad1};
|
||||
|
||||
const CONFIG_FILE: &str = "aura.conf";
|
||||
|
||||
/// Enable/disable LED control in various states such as
|
||||
@@ -191,6 +190,10 @@ impl StdConfig for AuraConfig {
|
||||
Self::create_default(&LaptopLedData::get_data())
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(crate::CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name() -> &'static str {
|
||||
CONFIG_FILE
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use config_traits::StdConfig;
|
||||
use log::{info, warn};
|
||||
use rog_aura::advanced::{LedUsbPackets, UsbPackets};
|
||||
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
|
||||
@@ -10,7 +11,6 @@ use rog_platform::keyboard_led::KeyboardLed;
|
||||
use rog_platform::supported::LedSupportedFunctions;
|
||||
|
||||
use super::config::{AuraConfig, AuraPowerConfig};
|
||||
use crate::config_traits::StdConfig;
|
||||
use crate::error::RogError;
|
||||
use crate::GetSupported;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{error, info, warn};
|
||||
use rog_aura::advanced::UsbPackets;
|
||||
use rog_aura::usb::AuraPowerDev;
|
||||
@@ -11,7 +12,6 @@ use zbus::export::futures_util::StreamExt;
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
|
||||
use super::controller::CtrlKbdLed;
|
||||
use crate::config_traits::StdConfig;
|
||||
use crate::error::RogError;
|
||||
use crate::CtrlTask;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{info, warn};
|
||||
use rog_platform::platform::{AsusPlatform, GpuMode};
|
||||
use rog_platform::supported::RogBiosSupportedFunctions;
|
||||
@@ -12,7 +13,6 @@ use zbus::export::futures_util::lock::Mutex;
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::config_traits::StdConfig;
|
||||
use crate::error::RogError;
|
||||
use crate::{task_watch_item, CtrlTask, GetSupported};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{error, info, warn};
|
||||
use rog_platform::power::AsusPower;
|
||||
use rog_platform::supported::ChargeSupportedFunctions;
|
||||
@@ -12,7 +13,6 @@ use zbus::export::futures_util::lock::Mutex;
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::config_traits::StdConfig;
|
||||
use crate::error::RogError;
|
||||
use crate::{task_watch_item, CtrlTask, GetSupported};
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad1};
|
||||
use rog_profiles::fan_curve_set::FanCurveSet;
|
||||
use rog_profiles::{FanCurveProfiles, Profile};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::config_traits::{StdConfig, StdConfigLoad1};
|
||||
use crate::CONFIG_PATH_BASE;
|
||||
|
||||
const CONFIG_FILE: &str = "profile.conf";
|
||||
const CONFIG_FAN_FILE: &str = "fan_curves.conf";
|
||||
@@ -19,6 +23,10 @@ impl StdConfig for ProfileConfig {
|
||||
}
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
PathBuf::from(CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name() -> &'static str {
|
||||
CONFIG_FILE
|
||||
}
|
||||
@@ -26,9 +34,46 @@ impl StdConfig for ProfileConfig {
|
||||
|
||||
impl StdConfigLoad1<ProfileConfig> for ProfileConfig {}
|
||||
|
||||
impl StdConfig for FanCurveProfiles {
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
pub struct FanCurveConfig {
|
||||
balanced: FanCurveSet,
|
||||
performance: FanCurveSet,
|
||||
quiet: FanCurveSet,
|
||||
#[serde(skip)]
|
||||
device: FanCurveProfiles,
|
||||
}
|
||||
|
||||
impl FanCurveConfig {
|
||||
pub fn update_device_config(&mut self) {
|
||||
self.balanced = self.device.balanced.clone();
|
||||
self.performance = self.device.performance.clone();
|
||||
self.quiet = self.device.quiet.clone();
|
||||
}
|
||||
|
||||
pub fn update_config(&mut self) {
|
||||
self.balanced = self.device.balanced.clone();
|
||||
self.performance = self.device.performance.clone();
|
||||
self.quiet = self.device.quiet.clone();
|
||||
}
|
||||
|
||||
pub fn device(&self) -> &FanCurveProfiles {
|
||||
&self.device
|
||||
}
|
||||
|
||||
pub fn device_mut(&mut self) -> &mut FanCurveProfiles {
|
||||
&mut self.device
|
||||
}
|
||||
}
|
||||
|
||||
impl StdConfig for FanCurveConfig {
|
||||
fn new() -> Self {
|
||||
Self::default()
|
||||
let mut tmp = Self::default();
|
||||
tmp.update_device_config();
|
||||
tmp
|
||||
}
|
||||
|
||||
fn config_dir() -> std::path::PathBuf {
|
||||
PathBuf::from(CONFIG_PATH_BASE)
|
||||
}
|
||||
|
||||
fn file_name() -> &'static str {
|
||||
@@ -36,4 +81,4 @@ impl StdConfig for FanCurveProfiles {
|
||||
}
|
||||
}
|
||||
|
||||
impl StdConfigLoad1<ProfileConfig> for FanCurveProfiles {}
|
||||
impl StdConfigLoad1<ProfileConfig> for FanCurveConfig {}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
use config_traits::StdConfig;
|
||||
use log::{info, warn};
|
||||
use rog_platform::platform::AsusPlatform;
|
||||
use rog_platform::supported::PlatformProfileFunctions;
|
||||
use rog_profiles::error::ProfileError;
|
||||
use rog_profiles::{FanCurveProfiles, Profile};
|
||||
|
||||
use super::config::ProfileConfig;
|
||||
use crate::config_traits::StdConfig;
|
||||
use super::config::{FanCurveConfig, ProfileConfig};
|
||||
use crate::error::RogError;
|
||||
use crate::GetSupported;
|
||||
|
||||
pub struct CtrlPlatformProfile {
|
||||
pub profile_config: ProfileConfig,
|
||||
pub fan_config: Option<FanCurveProfiles>,
|
||||
pub fan_config: Option<FanCurveConfig>,
|
||||
pub platform: AsusPlatform,
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ impl CtrlPlatformProfile {
|
||||
if let Some(curves) = controller.fan_config.as_ref() {
|
||||
info!(
|
||||
"{active:?}: {}",
|
||||
String::from(curves.get_fan_curves_for(active))
|
||||
String::from(curves.device().get_fan_curves_for(active))
|
||||
);
|
||||
curves.write();
|
||||
}
|
||||
@@ -83,9 +83,10 @@ impl CtrlPlatformProfile {
|
||||
Err(ProfileError::NotSupported.into())
|
||||
}
|
||||
|
||||
pub fn save_config(&self) {
|
||||
pub fn save_config(&mut self) {
|
||||
self.profile_config.write();
|
||||
if let Some(fans) = self.fan_config.as_ref() {
|
||||
if let Some(fans) = self.fan_config.as_mut() {
|
||||
fans.update_config();
|
||||
fans.write();
|
||||
}
|
||||
}
|
||||
@@ -116,7 +117,7 @@ impl CtrlPlatformProfile {
|
||||
pub(super) fn write_profile_curve_to_platform(&mut self) -> Result<(), RogError> {
|
||||
if let Some(curves) = &mut self.fan_config {
|
||||
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
||||
curves.write_profile_curve_to_platform(
|
||||
curves.device_mut().write_profile_curve_to_platform(
|
||||
self.profile_config.active_profile,
|
||||
&mut device,
|
||||
)?;
|
||||
@@ -128,10 +129,11 @@ impl CtrlPlatformProfile {
|
||||
pub(super) fn set_active_curve_to_defaults(&mut self) -> Result<(), RogError> {
|
||||
if let Some(curves) = self.fan_config.as_mut() {
|
||||
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
||||
curves.set_active_curve_to_defaults(
|
||||
curves.device_mut().set_active_curve_to_defaults(
|
||||
self.profile_config.active_profile,
|
||||
&mut device,
|
||||
)?;
|
||||
curves.update_config();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{error, info, warn};
|
||||
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet};
|
||||
use rog_profiles::{FanCurveProfiles, Profile};
|
||||
@@ -11,7 +12,6 @@ use zbus::fdo::Error;
|
||||
use zbus::{dbus_interface, Connection, SignalContext};
|
||||
|
||||
use super::controller::CtrlPlatformProfile;
|
||||
use crate::config_traits::StdConfig;
|
||||
use crate::error::RogError;
|
||||
use crate::CtrlTask;
|
||||
|
||||
@@ -82,8 +82,8 @@ impl ProfileZbus {
|
||||
async fn enabled_fan_profiles(&mut self) -> zbus::fdo::Result<Vec<Profile>> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.profile_config.read();
|
||||
if let Some(curves) = &ctrl.fan_config {
|
||||
return Ok(curves.get_enabled_curve_profiles());
|
||||
if let Some(curves) = &mut ctrl.fan_config {
|
||||
return Ok(curves.device().get_enabled_curve_profiles());
|
||||
}
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
||||
}
|
||||
@@ -98,7 +98,10 @@ impl ProfileZbus {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.profile_config.read();
|
||||
if let Some(curves) = &mut ctrl.fan_config {
|
||||
curves.set_profile_curve_enabled(profile, enabled);
|
||||
curves
|
||||
.device_mut()
|
||||
.set_profile_curve_enabled(profile, enabled);
|
||||
curves.update_config();
|
||||
|
||||
ctrl.write_profile_curve_to_platform()
|
||||
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
|
||||
@@ -115,8 +118,8 @@ impl ProfileZbus {
|
||||
async fn fan_curve_data(&mut self, profile: Profile) -> zbus::fdo::Result<FanCurveSet> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.profile_config.read();
|
||||
if let Some(curves) = &ctrl.fan_config {
|
||||
let curve = curves.get_fan_curves_for(profile);
|
||||
if let Some(curves) = &mut ctrl.fan_config {
|
||||
let curve = curves.device().get_fan_curves_for(profile);
|
||||
return Ok(curve.clone());
|
||||
}
|
||||
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
||||
@@ -129,8 +132,10 @@ impl ProfileZbus {
|
||||
ctrl.profile_config.read();
|
||||
if let Some(curves) = &mut ctrl.fan_config {
|
||||
curves
|
||||
.device_mut()
|
||||
.save_fan_curve(curve, profile)
|
||||
.map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?;
|
||||
curves.update_config();
|
||||
} else {
|
||||
return Err(Error::Failed(UNSUPPORTED_MSG.to_owned()));
|
||||
}
|
||||
@@ -295,7 +300,10 @@ impl crate::Reloadable for ProfileZbus {
|
||||
// There is a possibility that the curve was default zeroed, so this call
|
||||
// initialises the data from system read and we need to save it
|
||||
// after
|
||||
curves.write_profile_curve_to_platform(active, &mut device)?;
|
||||
curves
|
||||
.device_mut()
|
||||
.write_profile_curve_to_platform(active, &mut device)?;
|
||||
curves.update_config();
|
||||
ctrl.profile_config.write();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ use std::time::Duration;
|
||||
|
||||
use ::zbus::export::futures_util::lock::Mutex;
|
||||
use ::zbus::Connection;
|
||||
use config_traits::{StdConfigLoad1, StdConfigLoad3};
|
||||
use daemon::config::Config;
|
||||
use daemon::config_traits::{StdConfigLoad1, StdConfigLoad3};
|
||||
use daemon::ctrl_anime::config::AnimeConfig;
|
||||
use daemon::ctrl_anime::trait_impls::CtrlAnimeZbus;
|
||||
use daemon::ctrl_anime::CtrlAnime;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#![deny(unused_must_use)]
|
||||
/// Configuration loading, saving
|
||||
pub mod config;
|
||||
/// Base traits for configuration file loading
|
||||
pub mod config_traits;
|
||||
/// Control of anime matrix display
|
||||
pub mod ctrl_anime;
|
||||
/// Keyboard LED brightness control, RGB, and LED display modes
|
||||
@@ -30,6 +28,8 @@ use zbus::{Connection, SignalContext};
|
||||
|
||||
use crate::error::RogError;
|
||||
|
||||
const CONFIG_PATH_BASE: &str = "/etc/asusd/";
|
||||
|
||||
/// This macro adds a function which spawns an `inotify` task on the passed in
|
||||
/// `Executor`.
|
||||
///
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::advanced::LedCode;
|
||||
use crate::Colour;
|
||||
|
||||
pub struct InputBased {
|
||||
address: LedCode,
|
||||
led: LedCode,
|
||||
colour: Colour,
|
||||
/// - audio
|
||||
/// - cpu freq
|
||||
@@ -24,10 +24,10 @@ impl EffectState for InputBased {
|
||||
}
|
||||
|
||||
fn get_led(&self) -> LedCode {
|
||||
self.address
|
||||
self.led
|
||||
}
|
||||
|
||||
fn set_led(&mut self, address: LedCode) {
|
||||
self.address = address
|
||||
self.led = address
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{effect_state_impl, Colour, Speed};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Breathe {
|
||||
address: LedCode,
|
||||
led: LedCode,
|
||||
/// The starting colour
|
||||
start_colour1: Colour,
|
||||
/// The secondary starting colour
|
||||
@@ -26,7 +26,7 @@ pub struct Breathe {
|
||||
impl Breathe {
|
||||
pub fn new(address: LedCode, colour1: Colour, colour2: Colour, speed: Speed) -> Self {
|
||||
Self {
|
||||
address,
|
||||
led: address,
|
||||
start_colour1: colour1,
|
||||
start_colour2: colour2,
|
||||
speed,
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{effect_state_impl, Colour};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DoomFlicker {
|
||||
address: LedCode,
|
||||
led: LedCode,
|
||||
start_colour: Colour,
|
||||
max_percentage: u8,
|
||||
min_percentage: u8,
|
||||
@@ -20,7 +20,7 @@ pub struct DoomFlicker {
|
||||
impl DoomFlicker {
|
||||
pub fn new(address: LedCode, colour: Colour, max_percentage: u8, min_percentage: u8) -> Self {
|
||||
Self {
|
||||
address,
|
||||
led: address,
|
||||
colour,
|
||||
count: 4,
|
||||
max_percentage,
|
||||
@@ -94,7 +94,7 @@ pub struct LightFlash {
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct DoomLightFlash {
|
||||
address: LedCode,
|
||||
led: LedCode,
|
||||
start_colour: Colour,
|
||||
max_percentage: u8,
|
||||
min_percentage: u8,
|
||||
@@ -111,7 +111,7 @@ pub struct DoomLightFlash {
|
||||
impl DoomLightFlash {
|
||||
pub fn new(address: LedCode, colour: Colour, max_percentage: u8, min_percentage: u8) -> Self {
|
||||
Self {
|
||||
address,
|
||||
led: address,
|
||||
colour,
|
||||
count: 4,
|
||||
max_percentage,
|
||||
|
||||
@@ -133,12 +133,12 @@ macro_rules! effect_state_impl {
|
||||
}
|
||||
|
||||
fn get_led(&self) -> $crate::advanced::LedCode {
|
||||
self.address.clone()
|
||||
self.led.clone()
|
||||
}
|
||||
|
||||
/// Change the led type
|
||||
fn set_led(&mut self, address: $crate::advanced::LedCode) {
|
||||
self.address = address;
|
||||
self.led = address;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,14 +7,17 @@ use crate::{effect_state_impl, Colour};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Static {
|
||||
address: LedCode,
|
||||
led: LedCode,
|
||||
/// The starting colour
|
||||
colour: Colour,
|
||||
}
|
||||
|
||||
impl Static {
|
||||
pub fn new(address: LedCode, colour: Colour) -> Self {
|
||||
Self { address, colour }
|
||||
Self {
|
||||
led: address,
|
||||
colour,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,9 +162,9 @@ impl Default for FanCurvePU {
|
||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
pub struct FanCurveProfiles {
|
||||
balanced: FanCurveSet,
|
||||
performance: FanCurveSet,
|
||||
quiet: FanCurveSet,
|
||||
pub balanced: FanCurveSet,
|
||||
pub performance: FanCurveSet,
|
||||
pub quiet: FanCurveSet,
|
||||
}
|
||||
|
||||
impl FanCurveProfiles {
|
||||
|
||||
Reference in New Issue
Block a user