did some stuff

This commit is contained in:
2026-01-16 21:19:55 +00:00
parent 4aaa0684c3
commit ecec4b8739

View File

@@ -1,20 +1,69 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
battery-limit-script = pkgs.writeShellScriptBin "set-battery-limit" '' battery-limit-script = ''
#!/bin/bash start_batt() {
echo 40 > /sys/class/power_supply/BAT0/charge_control_start_threshold
echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold
}
stop_batt() {
echo "meow"
}
''; '';
gpu-limit-frequency = pkgs.writeShellScriptBin "set-gpu-limit" '' gpu-limit-frequency = ''
#!/bin/bash start_gpu() {
start() {
${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -e ${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -e
} }
stop() { stop_gpu() {
${pkgs.intel-gpu-tools}/bin/intel_gpu_frequency -d ${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-auto-profile-config = ''
# TuneD rules for recommend_profile. # TuneD rules for recommend_profile.
# #
@@ -92,69 +141,15 @@ let
''; '';
in in
{ {
# services.power-profiles-daemon.enable = true;
# services.tlp = {
# enable = true;
# settings = {
# CPU_ENERGY_PERF_POLICY_ON_BAT = "powersave";
#
# # Wireless power saving
# WIFI_PWR_ON_BAT = "1";
#
# # USB autosuspend
# USB_AUTOSUSPEND = "1";
#
# # SATA drive power management
# SATA_LINKPWR_ON_BAT = "min_power";
#
# # PCI Express Active-State Power Management (ASPM)
# PCIE_ASPM_ON_BAT = "powersave";
#
# # Runtime Power Management for PCI(e) buses/devices
# RUNTIME_PM_ON_BAT = "auto";
#
# # Disable Bluetooth on battery
# # DEVICES_TO_DISABLE_ON_BAT = "bluetooth";
#
# # Restore brightness on battery
# RESTORE_BRIGHTNESS_ON_BAT = "1";
# CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
# # CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
# CPU_ENERGY_PERF_POLICY_ON_SAV = "power";
# CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
# # PCIE_ASPM_ON_BAT = "powersave";
# CPU_SCALING_GOVERNOR_ON_AC = "balanced";
# PCIE_ASPM_ON_AC = "balanced";
# CPU_BOOST_ON_AC = 1;
# CPU_BOOST_ON_BAT = 0;
# CPU_BOOST_ON_SAV = 0;
# DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE = "bluetooth wifi wwan";
# INTEL_GPU_MIN_FREQ_ON_AC = 0;
# INTEL_GPU_MIN_FREQ_ON_BAT = 0;
# INTEL_GPU_MAX_FREQ_ON_AC = 2350;
# INTEL_GPU_MAX_FREQ_ON_BAT = 1100;
# INTEL_GPU_BOOST_FREQ_ON_BAT = 1100;
#
# TLP_DEFAULT_BATTERY_MODE = "SAV";
# CPU_HWP_DYN_BOOST_ON_AC = 1;
# CPU_HWP_DYN_BOOST_ON_BAT = 0;
# CPU_HWP_DYN_BOOST_ON_SAV = 0;
# PLATFORM_PROFILE_ON_AC = "balanced";
# PLATFORM_PROFILE_ON_BAT = "low-power";
# PLATFORM_PROFILE_ON_SAV = "quiet";
# START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge
# STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging
# };
# };
services.tuned = { services.tuned = {
enable = true; enable = true;
profiles = { profiles = {
doloro-power-saver = { doloro-power-saver = {
main = { main = {
include = "powersave"; include = "powersave, intel-best_power_efficiency_mode";
}; };
script = { script = {
script = "${battery-limit-script}/bin/set-battery-limit,${gpu-limit-frequency}/bin/set-gpu-limit"; script = "\${i:PROFILE_DIR}/script.sh";
}; };
extraProfiles = { extraProfiles = {
doloro-power-saving = { doloro-power-saving = {
@@ -185,6 +180,10 @@ in
"tuned/recommend.conf" = { "tuned/recommend.conf" = {
text = tuned-auto-profile-config; text = tuned-auto-profile-config;
}; };
"tuned/profiles/doloro-power-saver/script.sh" = {
text = "${one-with-all}";
mode = "0777";
};
}; };
systemd.services = { systemd.services = {
# Tells tuned "hey, re-eval system state and change profiles accordingly" # Tells tuned "hey, re-eval system state and change profiles accordingly"