feat: nb battery improvement
This commit is contained in:
15
hosts/nb/modules/battery-brightness.nix
Normal file
15
hosts/nb/modules/battery-brightness.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
# Udev rules for battery optimizations
|
||||
services.udev.extraRules = ''
|
||||
# Reduce brightness to 40% when switching to battery
|
||||
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${pkgs.light}/bin/light -S 40"
|
||||
|
||||
# AMD GPU power management - force battery profile when unplugged
|
||||
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${pkgs.bash}/bin/bash -c 'echo battery > /sys/class/drm/card*/device/power_dpm_force_performance_level'"
|
||||
|
||||
# AMD GPU power management - auto when plugged in
|
||||
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${pkgs.bash}/bin/bash -c 'echo auto > /sys/class/drm/card*/device/power_dpm_force_performance_level'"
|
||||
'';
|
||||
}
|
||||
@@ -96,7 +96,8 @@ in {
|
||||
services.gnome.gnome-keyring.enable = true;
|
||||
services.gvfs.enable = true;
|
||||
|
||||
virtualisation.virtualbox.host.enable = true;
|
||||
# VirtualBox disabled by default to save battery - enable manually if needed
|
||||
# virtualisation.virtualbox.host.enable = true;
|
||||
users.extraGroups.vboxusers.members = [ "dominik" ];
|
||||
|
||||
fonts.packages = with pkgs; [
|
||||
@@ -111,7 +112,7 @@ in {
|
||||
programs.light.enable = true;
|
||||
|
||||
hardware.bluetooth.enable = true;
|
||||
hardware.bluetooth.powerOnBoot = true;
|
||||
hardware.bluetooth.powerOnBoot = false; # Save battery - enable manually when needed
|
||||
hardware.bluetooth.settings = {
|
||||
General = { ControllerMode = "bredr"; };
|
||||
};
|
||||
@@ -123,14 +124,52 @@ in {
|
||||
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
|
||||
|
||||
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
|
||||
CPU_ENERGY_PERF_POLICY_ON_BAT = "balance_power";
|
||||
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
|
||||
|
||||
CPU_BOOST_ON_AC = 1;
|
||||
CPU_BOOST_ON_BAT = 0;
|
||||
|
||||
CPU_MIN_PERF_ON_AC = 0;
|
||||
CPU_MAX_PERF_ON_AC = 100;
|
||||
CPU_MIN_PERF_ON_BAT = 0;
|
||||
CPU_MAX_PERF_ON_BAT = 30;
|
||||
|
||||
RUNTIME_PM_ON_AC = "auto";
|
||||
RUNTIME_PM_ON_BAT = "auto";
|
||||
|
||||
# WiFi power saving
|
||||
WIFI_PWR_ON_AC = "off";
|
||||
WIFI_PWR_ON_BAT = "on";
|
||||
|
||||
# Disable wake on LAN on battery
|
||||
WOL_DISABLE = "Y";
|
||||
|
||||
# SATA aggressive link power management
|
||||
SATA_LINKPWR_ON_AC = "med_power_with_dipm";
|
||||
SATA_LINKPWR_ON_BAT = "min_power";
|
||||
|
||||
# PCIe Active State Power Management
|
||||
PCIE_ASPM_ON_AC = "default";
|
||||
PCIE_ASPM_ON_BAT = "powersupersave";
|
||||
|
||||
# USB autosuspend
|
||||
USB_AUTOSUSPEND = 1;
|
||||
USB_EXCLUDE_AUDIO = 1;
|
||||
USB_EXCLUDE_BTUSB = 0;
|
||||
USB_EXCLUDE_PHONE = 0;
|
||||
USB_EXCLUDE_PRINTER = 1;
|
||||
USB_EXCLUDE_WWAN = 0;
|
||||
|
||||
# Audio power saving
|
||||
SOUND_POWER_SAVE_ON_AC = 0;
|
||||
SOUND_POWER_SAVE_ON_BAT = 1;
|
||||
SOUND_POWER_SAVE_CONTROLLER = "Y";
|
||||
|
||||
# Disk idle timeout
|
||||
DISK_IDLE_SECS_ON_AC = 0;
|
||||
DISK_IDLE_SECS_ON_BAT = 2;
|
||||
|
||||
# Battery charge thresholds (Framework 13 recommendation)
|
||||
START_CHARGE_THRESH_BAT0 = 60;
|
||||
STOP_CHARGE_THRESH_BAT0 = 80;
|
||||
};
|
||||
|
||||
@@ -47,7 +47,10 @@ in {
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
virtualisation.libvirtd = {
|
||||
enable = true; # Turn on the libvirtd daemon
|
||||
enable = true;
|
||||
# Socket activation - only start when needed to save battery
|
||||
onBoot = "ignore";
|
||||
onShutdown = "shutdown";
|
||||
qemu = {
|
||||
ovmf = {
|
||||
enable = true; # Enable OVMF firmware support
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
port = 11434;
|
||||
openFirewall = false;
|
||||
acceleration = "rocm";
|
||||
loadModels = [
|
||||
"mxbai-embed-large"
|
||||
];
|
||||
# Don't preload models - start on-demand to save battery
|
||||
loadModels = [ ];
|
||||
};
|
||||
|
||||
# ROCm GPU configuration for AMD Ryzen 7 7840U (gfx1103)
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
services.qdrant = {
|
||||
enable = true;
|
||||
settings = {
|
||||
storage.performance.max_search_threads = 8;
|
||||
storage.optimizers.default_segment_number = 4;
|
||||
# Reduced thread count for better battery life
|
||||
storage.performance.max_search_threads = 4;
|
||||
storage.optimizers.default_segment_number = 2;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -302,8 +302,10 @@ exec cryptomator
|
||||
exec swayidle \
|
||||
before-sleep 'loginctl lock-session $XDG_SESSION_ID' \
|
||||
lock 'swaylock -c 252525 -s center -i ~/.wallpaper.png' \
|
||||
timeout 300 'swaylock -c 252525 -s center -i ~/.wallpaper.png' \
|
||||
timeout 1800 'systemctl suspend'
|
||||
timeout 120 'light -O && light -S 10' \
|
||||
resume 'light -I' \
|
||||
timeout 180 'swaylock -c 252525 -s center -i ~/.wallpaper.png' \
|
||||
timeout 600 'systemctl suspend'
|
||||
exec dunst
|
||||
#exec --no-startup-id swaybg -c "#000000" -m fill -i ~/.config/wallpaper/wot.jpg
|
||||
# exec --no-startup-id gnome-keyring-daemon --start --components=pkcs11,secrets,ssh
|
||||
|
||||
Reference in New Issue
Block a user