mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Add disable_nvidia_powerd_on_battery option
This commit is contained in:
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Changed
|
||||
- Added option to set `disable_nvidia_powerd_on_battery`
|
||||
- Add short log entry to throttle_thermal_policy change detection
|
||||
|
||||
## [v4.5.8]
|
||||
### Changed
|
||||
- Fix incorrect stop/start order of nvidia-powerd on AC plug/unplug
|
||||
|
||||
@@ -11,6 +11,7 @@ pub struct Config {
|
||||
/// Save charge limit for restoring on boot
|
||||
pub bat_charge_limit: u8,
|
||||
pub panel_od: bool,
|
||||
pub disable_nvidia_powerd_on_battery: bool,
|
||||
pub ac_command: String,
|
||||
pub bat_command: String,
|
||||
}
|
||||
@@ -20,6 +21,7 @@ impl Config {
|
||||
Config {
|
||||
bat_charge_limit: 100,
|
||||
panel_od: false,
|
||||
disable_nvidia_powerd_on_battery: true,
|
||||
ac_command: String::new(),
|
||||
bat_command: String::new(),
|
||||
}
|
||||
@@ -42,6 +44,8 @@ impl Config {
|
||||
config = data;
|
||||
} else if let Ok(data) = serde_json::from_str::<Config455>(&buf) {
|
||||
config = data.into();
|
||||
} else if let Ok(data) = serde_json::from_str::<Config458>(&buf) {
|
||||
config = data.into();
|
||||
} else {
|
||||
warn!(
|
||||
"Could not deserialise {}.\nWill rename to {}-old and recreate config",
|
||||
@@ -100,8 +104,30 @@ impl From<Config455> for Config {
|
||||
Self {
|
||||
bat_charge_limit: c.bat_charge_limit,
|
||||
panel_od: c.panel_od,
|
||||
disable_nvidia_powerd_on_battery: true,
|
||||
ac_command: String::new(),
|
||||
bat_command: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Default)]
|
||||
pub struct Config458 {
|
||||
/// Save charge limit for restoring on boot
|
||||
pub bat_charge_limit: u8,
|
||||
pub panel_od: bool,
|
||||
pub ac_command: String,
|
||||
pub bat_command: String,
|
||||
}
|
||||
|
||||
impl From<Config458> for Config {
|
||||
fn from(c: Config458) -> Self {
|
||||
Self {
|
||||
bat_charge_limit: c.bat_charge_limit,
|
||||
panel_od: c.panel_od,
|
||||
disable_nvidia_powerd_on_battery: true,
|
||||
ac_command: c.ac_command,
|
||||
bat_command: c.bat_command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +176,10 @@ impl CtrlTask for CtrlPower {
|
||||
})
|
||||
.ok();
|
||||
|
||||
if let Ok(value) = power.power.get_online() {
|
||||
do_nvidia_powerd_action(&sysd, value == 1).await;
|
||||
if lock.disable_nvidia_powerd_on_battery {
|
||||
if let Ok(value) = power.power.get_online() {
|
||||
do_nvidia_powerd_action(&sysd, value == 1).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -196,8 +198,10 @@ impl CtrlTask for CtrlPower {
|
||||
})
|
||||
.ok();
|
||||
|
||||
if let Ok(value) = power.power.get_online() {
|
||||
do_nvidia_powerd_action(&sysd, value == 1).await;
|
||||
if lock.disable_nvidia_powerd_on_battery {
|
||||
if let Ok(value) = power.power.get_online() {
|
||||
do_nvidia_powerd_action(&sysd, value == 1).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -215,14 +219,17 @@ impl CtrlTask for CtrlPower {
|
||||
if let Ok(value) = ctrl.power.get_online() {
|
||||
if online != value {
|
||||
online = value;
|
||||
do_nvidia_powerd_action(&sysd3, value == 1).await;
|
||||
let mut config = config.lock().await;
|
||||
config.read();
|
||||
|
||||
if config.disable_nvidia_powerd_on_battery {
|
||||
do_nvidia_powerd_action(&sysd3, value == 1).await;
|
||||
}
|
||||
|
||||
Self::notify_mains_online(&signal_ctxt, value == 1)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut config = config.lock().await;
|
||||
config.read();
|
||||
let mut prog: Vec<&str> = Vec::new();
|
||||
if value == 1 {
|
||||
// AC ONLINE
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use async_trait::async_trait;
|
||||
use log::info;
|
||||
use log::warn;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::fan_curve_set::FanCurveSet;
|
||||
@@ -200,29 +201,6 @@ impl CtrlTask for ProfileZbus {
|
||||
}
|
||||
|
||||
async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> {
|
||||
// let ctrl = self.0.clone();
|
||||
// let mut watch = self.0.lock().await.platform.monitor_platform_profile()?;
|
||||
// let sig_ctx = signal_ctxt.clone();
|
||||
// tokio::spawn(async move {
|
||||
// let mut buffer = [0; 32];
|
||||
// watch
|
||||
// .event_stream(&mut buffer)
|
||||
// .unwrap()
|
||||
// .for_each(|_| async {
|
||||
// let mut lock = ctrl.lock().await;
|
||||
// let new_profile = Profile::get_active_profile().unwrap();
|
||||
// if new_profile != lock.config.active_profile {
|
||||
// lock.config.active_profile = new_profile;
|
||||
// lock.write_profile_curve_to_platform().unwrap();
|
||||
// lock.save_config();
|
||||
// }
|
||||
// Self::notify_profile(&sig_ctx, lock.config.active_profile)
|
||||
// .await
|
||||
// .ok();
|
||||
// })
|
||||
// .await;
|
||||
// });
|
||||
|
||||
let ctrl = self.0.clone();
|
||||
let mut watch = self
|
||||
.0
|
||||
@@ -241,6 +219,7 @@ impl CtrlTask for ProfileZbus {
|
||||
let new_thermal = lock.platform.get_throttle_thermal_policy().unwrap();
|
||||
let new_profile = Profile::from_throttle_thermal_policy(new_thermal);
|
||||
if new_profile != lock.config.active_profile {
|
||||
info!("throttle_thermal_policy changed to {new_profile}");
|
||||
lock.config.active_profile = new_profile;
|
||||
lock.write_profile_curve_to_platform().unwrap();
|
||||
lock.save_config();
|
||||
|
||||
Reference in New Issue
Block a user