2024-02-15 17:04:34 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
inputs,
|
2024-07-05 00:41:59 +02:00
|
|
|
lib,
|
2024-02-15 17:04:34 +01:00
|
|
|
pkgs,
|
|
|
|
...
|
2024-07-24 18:47:53 +02:00
|
|
|
}: let
|
|
|
|
inherit (lib.meta) getExe getExe';
|
2024-02-15 17:04:34 +01:00
|
|
|
|
2024-07-24 18:47:53 +02:00
|
|
|
asusctl = getExe' config.services.asusd.package "asusctl";
|
|
|
|
supergfxctl = getExe' config.services.asusd.package "supergfxctl";
|
|
|
|
cpupower = getExe config.boot.kernelPackages.cpupower;
|
2024-10-13 23:25:45 +02:00
|
|
|
hyprctl = getExe' inputs.hyprland.packages.${pkgs.stdenv.system}.hyprland "hyprctl";
|
2024-07-24 18:47:53 +02:00
|
|
|
|
2024-08-30 20:41:42 +02:00
|
|
|
inherit (pkgs) writeShellScript;
|
2024-07-24 18:47:53 +02:00
|
|
|
in {
|
|
|
|
services.udev.extraRules = let
|
2024-08-30 20:41:42 +02:00
|
|
|
power_supply = writeShellScript "on_power_supply" ''
|
2024-07-05 00:41:59 +02:00
|
|
|
${asusctl} profile -P Performance
|
|
|
|
#${supergfxctl} -m Hybrid
|
2024-08-30 20:40:34 +02:00
|
|
|
${cpupower} frequency-set -g performance
|
2024-07-05 00:41:59 +02:00
|
|
|
${hyprctl} keyword decoration:blur:enabled true
|
|
|
|
${hyprctl} keyword animations:enabled true
|
2024-02-15 17:04:34 +01:00
|
|
|
'';
|
2024-08-30 20:41:42 +02:00
|
|
|
battery = writeShellScript "on_battery" ''
|
2024-07-05 00:41:59 +02:00
|
|
|
${asusctl} profile -P Quiet
|
|
|
|
#${supergfxctl} -m Integrated
|
2024-08-30 20:40:34 +02:00
|
|
|
${cpupower} frequency-set -g powersave
|
2024-07-05 00:41:59 +02:00
|
|
|
${hyprctl} keyword decoration:blur:enabled false
|
|
|
|
${hyprctl} keyword animations:enabled false
|
2024-04-23 12:11:25 +02:00
|
|
|
'';
|
|
|
|
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
|
|
|
}
|