mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Merge branch 'fix/one-shot-charge-persistence' into 'devel'
fix: one-shot charging loses original charge limit after restart See merge request asus-linux/asusctl!242
This commit is contained in:
@@ -8,6 +8,12 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
const CONFIG_FILE: &str = "asusd.ron";
|
const CONFIG_FILE: &str = "asusd.ron";
|
||||||
|
|
||||||
|
/// Default value for base_charge_control_end_threshold when not present in config.
|
||||||
|
/// Returns 0 so restore_charge_limit() skips restoration for upgraded configs.
|
||||||
|
fn default_base_charge_limit() -> u8 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
pub struct Tuning {
|
pub struct Tuning {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
@@ -19,8 +25,8 @@ type Tunings = HashMap<PlatformProfile, Tuning>;
|
|||||||
pub struct Config {
|
pub struct Config {
|
||||||
// The current charge limit applied
|
// The current charge limit applied
|
||||||
pub charge_control_end_threshold: u8,
|
pub charge_control_end_threshold: u8,
|
||||||
/// Save charge limit for restoring
|
/// Save charge limit for restoring after one-shot full charge
|
||||||
#[serde(skip)]
|
#[serde(default = "default_base_charge_limit")]
|
||||||
pub base_charge_control_end_threshold: u8,
|
pub base_charge_control_end_threshold: u8,
|
||||||
pub disable_nvidia_powerd_on_battery: bool,
|
pub disable_nvidia_powerd_on_battery: bool,
|
||||||
/// An optional command/script to run when power is changed to AC
|
/// An optional command/script to run when power is changed to AC
|
||||||
@@ -86,6 +92,9 @@ impl Default for Config {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
charge_control_end_threshold: 100,
|
charge_control_end_threshold: 100,
|
||||||
|
// NOTE: This is intentionally 100 (not 0 like the serde default).
|
||||||
|
// New installs get 100 (no limit). Upgraded configs missing this
|
||||||
|
// field get 0 via serde, which skips restore_charge_limit().
|
||||||
base_charge_control_end_threshold: 100,
|
base_charge_control_end_threshold: 100,
|
||||||
disable_nvidia_powerd_on_battery: true,
|
disable_nvidia_powerd_on_battery: true,
|
||||||
ac_command: Default::default(),
|
ac_command: Default::default(),
|
||||||
|
|||||||
Reference in New Issue
Block a user