niksos/options/desktop/power-supply.nix

29 lines
1.2 KiB
Nix
Raw Normal View History

2024-02-15 17:04:34 +01:00
{
config,
inputs,
pkgs,
...
}: {
2024-04-23 12:11:25 +02:00
services.udev.extraRules = let
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;
2024-02-15 17:04:34 +01:00
2024-04-23 12:11:25 +02:00
power_supply = pkgs.writeShellScript "on_power_supply" ''
${pkgs.asusctl}/bin/asusctl profile -P Performance
#${pkgs.supergfxctl}/bin/supergfxctl -m Hybrid
${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g performance
${hyprland}/bin/hyprctl keyword decoration:blur:enabled true
${hyprland}/bin/hyprctl keyword animations:enabled true
2024-02-15 17:04:34 +01:00
'';
2024-04-23 12:11:25 +02:00
battery = pkgs.writeShellScript "on_battery" ''
${pkgs.asusctl}/bin/asusctl profile -P Quiet
#${pkgs.supergfxctl}/bin/supergfxctl -m Integrated
${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g powersave
${hyprland}/bin/hyprctl keyword decoration:blur:enabled false
${hyprland}/bin/hyprctl keyword animations:enabled false
'';
in ''
SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="1",RUN+="${power_supply}"
SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="0",RUN+="${battery}"
'';
2024-02-15 17:04:34 +01:00
}