diff --git a/hosts/doloro-laptop/laptop.nix b/hosts/doloro-laptop/laptop.nix index ff2399f..b9573b5 100644 --- a/hosts/doloro-laptop/laptop.nix +++ b/hosts/doloro-laptop/laptop.nix @@ -65,13 +65,13 @@ let [doloro-power-saver] virt= system= - /sys/class/power_supply/AC/online=0 + /sys/class/power_supply/BAT0/status=Discharging # Profile for devices on AC power [doloro-balanced] virt= system= - /sys/class/power_supply/AC/online=1 + /sys/class/power_supply/BAT0/status=Charging [atomic-host] virt= @@ -148,52 +148,52 @@ in # }; services.tuned = { enable = true; - autoProfile = true; - extraProfiles = { - doloro-power-saving = { - description = "Custom power-saving profile inheriting from powersave"; - config = '' - include=powersave - - [plugins] - script=on - - [script] - script=${battery-limit-script}/bin/set-battery-limit,${gpu-limit-frequency}/bin/set-gpu-limit - mode=start - ''; + profiles = { + doloro-power-saver = { + main = { + include = "powersave"; + }; + script = { + script = "${battery-limit-script}/bin/set-battery-limit,${gpu-limit-frequency}/bin/set-gpu-limit"; + }; }; doloro-balanced = { - description = "Custom balanced profile inheriting from balanced"; - config = '' - include=balanced - - [plugins] - script=on - - [script] - script=${battery-limit-script}/bin/set-battery-limit - mode=start - ''; + main = { + include = "balanced"; + }; + script = { + script = "${battery-limit-script}/bin/set-battery-limit"; + }; }; }; }; environment.etc = { - tuned.recommend.conf = { + "tuned/recommend.conf" = { text = tuned-auto-profile-config; }; }; - systemd.services.tuned-auto-profile = { - description = "Enable Auto Profile in TuneD"; - after = [ "network.target" ]; # Ensure network is up (if needed for TuneD) - wantedBy = [ "multi-user.target" ]; # Start in the default target mode + systemd.services = { + # Tells tuned "hey, re-eval system state and change profiles accordingly" + send-sighup-to-tuned = { + serviceConfig = { + ExecStart = "${pkgs.killall}/bin/killall -1 .tuned-wrapped"; + Restart = "always"; + RestartSec = "30s"; + }; + wantedBy = [ "multi-user.target" ]; + }; + tuned-auto-profile = { + description = "Enable Auto Profile in TuneD"; + after = [ "network.target" ]; # Ensure network is up (if needed for TuneD) + wantedBy = [ "multi-user.target" ]; # Start in the default target mode - # Command to run - serviceConfig = { - ExecStart = "${pkgs.tuned}/bin/tuned-adm auto_profile"; - Restart = "on-failure"; - RestartSec = 5; # Wait 5 seconds before retrying if it fails - Environment = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; # Ensure PATH is correct + # Command to run + serviceConfig = { + ExecStart = "${pkgs.tuned}/bin/tuned-adm auto_profile"; + Restart = "on-failure"; + RestartSec = 5; # Wait 5 seconds before retrying if it fails + Environment = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; # Ensure PATH is correct + }; }; }; services.thermald.enable = true;