qol(laptop): huge battery optimisations
This commit is contained in:
@@ -1,143 +1,12 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
battery-limit-script = ''
|
batt-gpu = pkgs.writeShellScript "batt-igpu" ''
|
||||||
start_batt() {
|
${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -e
|
||||||
echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold
|
echo "800" > /sys/class/drm/card1/gt_boost_freq_mhz
|
||||||
}
|
|
||||||
stop_batt() {
|
|
||||||
echo "meow"
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
gpu-limit-frequency = ''
|
ac-gpu = pkgs.writeShellScript "ac-igpu" ''
|
||||||
start_gpu() {
|
${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -d
|
||||||
${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -e
|
echo "2350" > /sys/class/drm/card1/gt_boost_freq_mhz
|
||||||
}
|
|
||||||
|
|
||||||
stop_gpu() {
|
|
||||||
${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -d
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
cpu-power-efficency = ''
|
|
||||||
start_cpu_effic() {
|
|
||||||
n=$(nproc)
|
|
||||||
i=0
|
|
||||||
while [ "$i" -lt $n ]; do
|
|
||||||
echo 178 | tee /sys/devices/system/cpu/cpu$i/cpufreq/energy_performance_preference
|
|
||||||
echo 8 | tee /sys/devices/system/cpu/cpu$i/power/energy_perf_bias
|
|
||||||
i=$(( i + 1 ))
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_cpu_effic() {
|
|
||||||
n=$(nproc)
|
|
||||||
i=0
|
|
||||||
while [ "$i" -lt $n ]; do
|
|
||||||
echo "balance_performance" | tee /sys/devices/system/cpu/cpu$i/cpufreq/energy_performance_preference
|
|
||||||
echo 6 | tee /sys/devices/system/cpu/cpu$i/power/energy_perf_bias
|
|
||||||
i=$(( i + 1 ))
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
one-with-all = ''
|
|
||||||
#!/bin/sh
|
|
||||||
${battery-limit-script}
|
|
||||||
${gpu-limit-frequency}
|
|
||||||
${cpu-power-efficency}
|
|
||||||
start() {
|
|
||||||
echo "meow"
|
|
||||||
echo "mreoww" > /home/doloro/meow.txt
|
|
||||||
start_gpu
|
|
||||||
start_batt
|
|
||||||
start_cpu_effic
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
stop_gpu
|
|
||||||
stop_batt
|
|
||||||
stop_cpu_effic
|
|
||||||
}
|
|
||||||
if [ "$1" == "start" ]; then
|
|
||||||
start
|
|
||||||
fi
|
|
||||||
if [ "$1" == "stop" ]; then
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
tuned-auto-profile-config = ''
|
|
||||||
# TuneD rules for recommend_profile.
|
|
||||||
#
|
|
||||||
# Syntax:
|
|
||||||
# [PROFILE1]
|
|
||||||
# KEYWORD11=RE11
|
|
||||||
# KEYWORD21=RE12
|
|
||||||
#
|
|
||||||
# [PROFILE2]
|
|
||||||
# KEYWORD21=RE21
|
|
||||||
# KEYWORD22=RE22
|
|
||||||
|
|
||||||
# KEYWORD can be:
|
|
||||||
# virt - for RE to match output of virt-what
|
|
||||||
# system - for RE to match content of /etc/system-release-cpe
|
|
||||||
# process - for RE to match running processes. It can have arbitrary
|
|
||||||
# suffix, all process* lines have to match for the PROFILE
|
|
||||||
# to match (i.e. the AND operator)
|
|
||||||
# /FILE - for RE to match content of the FILE, e.g.:
|
|
||||||
# '/etc/passwd=.+'. If file doesn't exist, its RE will not
|
|
||||||
# match.
|
|
||||||
# chassis_type - for RE to match the chassis type as reported by dmidecode
|
|
||||||
# syspurpose_role - for RE to match the system role as reported by syspurpose
|
|
||||||
|
|
||||||
# All REs for all KEYWORDs have to match for PROFILE to match (i.e. the AND operator).
|
|
||||||
# If 'virt' or 'system' is not specified, it matches for every string.
|
|
||||||
# If 'virt' or 'system' is empty, i.e. 'virt=', it matches only empty string (alias for '^$').
|
|
||||||
# If several profiles matched, the first match is taken.
|
|
||||||
#
|
|
||||||
# Limitation:
|
|
||||||
# Each profile can be specified only once, because there cannot be
|
|
||||||
# multiple sections in the configuration file with the same name
|
|
||||||
# (ConfigParser limitation).
|
|
||||||
# If there is a need to specify the profile multiple times, unique
|
|
||||||
# suffix like ',ANYSTRING' can be used. Everything after the last ','
|
|
||||||
# is stripped by the parser, e.g.:
|
|
||||||
#
|
|
||||||
# [balanced,1]
|
|
||||||
# /FILE1=RE1
|
|
||||||
#
|
|
||||||
# [balanced,2]
|
|
||||||
# /FILE2=RE2
|
|
||||||
#
|
|
||||||
# This will set 'balanced' profile in case there is FILE1 matching RE1 or
|
|
||||||
# FILE2 matching RE2 or both.
|
|
||||||
|
|
||||||
# Profile for devices on battery
|
|
||||||
[doloro-power-saver]
|
|
||||||
virt=
|
|
||||||
system=
|
|
||||||
/sys/class/power_supply/BAT0/status=Discharging
|
|
||||||
|
|
||||||
# Profile for devices on AC power
|
|
||||||
[doloro-balanced]
|
|
||||||
virt=
|
|
||||||
system=
|
|
||||||
/sys/class/power_supply/BAT0/status=Charging
|
|
||||||
|
|
||||||
[atomic-host]
|
|
||||||
virt=
|
|
||||||
system=.*atomic.*
|
|
||||||
|
|
||||||
[atomic-guest]
|
|
||||||
virt=.+
|
|
||||||
system=.*atomic.*
|
|
||||||
|
|
||||||
[throughput-performance]
|
|
||||||
virt=
|
|
||||||
system=.*(computenode|server).*
|
|
||||||
|
|
||||||
[virtual-guest]
|
|
||||||
virt=.+
|
|
||||||
|
|
||||||
[balanced]
|
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -156,7 +25,7 @@ in
|
|||||||
# PCI Express Active-State Power Management (ASPM)
|
# PCI Express Active-State Power Management (ASPM)
|
||||||
PCIE_ASPM_ON_BAT = "powersupersave";
|
PCIE_ASPM_ON_BAT = "powersupersave";
|
||||||
|
|
||||||
# Runtime Power Management for PCI(e) buses/devices
|
RUNTIME_PM_ON_AC = "on";
|
||||||
RUNTIME_PM_ON_BAT = "auto";
|
RUNTIME_PM_ON_BAT = "auto";
|
||||||
|
|
||||||
# Disable Bluetooth on battery
|
# Disable Bluetooth on battery
|
||||||
@@ -165,9 +34,13 @@ in
|
|||||||
# Restore brightness on battery
|
# Restore brightness on battery
|
||||||
RESTORE_BRIGHTNESS_ON_BAT = "1";
|
RESTORE_BRIGHTNESS_ON_BAT = "1";
|
||||||
PCIE_ASPM_ON_AC = "balanced";
|
PCIE_ASPM_ON_AC = "balanced";
|
||||||
DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE = "bluetooth wifi wwan";
|
DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE = "bluetooth";
|
||||||
INTEL_GPU_MAX_FREQ_ON_AC = 0;
|
INTEL_GPU_MAX_FREQ_ON_AC = 0;
|
||||||
INTEL_GPU_MAX_FREQ_ON_BAT = 800;
|
INTEL_GPU_MAX_FREQ_ON_BAT = 800;
|
||||||
|
INTEL_GPU_BOOST_FREQ_ON_AC = 0;
|
||||||
|
INTEL_GPU_BOOST_FREQ_ON_BAT = 800;
|
||||||
|
|
||||||
|
CPU_MAX_PERF_ON_BAT = 50;
|
||||||
|
|
||||||
PLATFORM_PROFILE_ON_AC = "balanced";
|
PLATFORM_PROFILE_ON_AC = "balanced";
|
||||||
PLATFORM_PROFILE_ON_BAT = "quiet";
|
PLATFORM_PROFILE_ON_BAT = "quiet";
|
||||||
@@ -213,7 +86,7 @@ in
|
|||||||
};
|
};
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
# "mem_sleep_default=deep"
|
# "mem_sleep_default=deep"
|
||||||
"i915.fastboot=1"
|
# "i915.fastboot=1"
|
||||||
"pcie_aspm=force"
|
"pcie_aspm=force"
|
||||||
"ahci.mobile_lpm_policy=1"
|
"ahci.mobile_lpm_policy=1"
|
||||||
];
|
];
|
||||||
@@ -234,7 +107,7 @@ in
|
|||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -e";
|
ExecStart = "${batt-gpu}";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
};
|
};
|
||||||
wantedBy = [ "battery.target" ];
|
wantedBy = [ "battery.target" ];
|
||||||
@@ -247,7 +120,7 @@ in
|
|||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -d";
|
ExecStart = "${ac-gpu}";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
};
|
};
|
||||||
wantedBy = [ "ac.target" ];
|
wantedBy = [ "ac.target" ];
|
||||||
|
|||||||
Reference in New Issue
Block a user