]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/acpid.nix
nix: fix private matching
[julm/julm-nix.git] / nixos / profiles / acpid.nix
1 { config, lib, pkgs, ... }:
2 {
3 hardware.acpilight.enable = true;
4 boot.kernelModules = [ "msr" "acpi_cpufreq" ];
5 system.activationScripts.acPlug = {
6 deps = [ "modprobe" ];
7 text = ''
8 PATH="${pkgs.kmod}/bin:$PATH"
9 modprobe msr
10 modprobe acpi_cpufreq
11 ${pkgs.acpi}/bin/acpi -a | grep -q 'Adapter .*: on-line' ||
12 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave
13 '';
14 };
15 services.acpid = {
16 enable = true;
17 handlers = {
18 brightnessDown = {
19 event = "video/brightnessdown.*";
20 action = "${pkgs.acpilight}/bin/xbacklight -dec 10";
21 };
22 brightnessUp = {
23 event = "video/brightnessup.*";
24 action = "${pkgs.acpilight}/bin/xbacklight -inc 10";
25 };
26 };
27 acEventCommands = ''
28 vals=($1)
29 case ''${vals[3]} in
30 00000000) # unplugged
31 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
32 00000001) # plugged in
33 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
34 esac
35 '';
36 };
37 }