]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/acpid.nix
wg-intra: polish
[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 systemd.services.acpid.postStart = ''
6 ${pkgs.acpi}/bin/acpi -a | grep -q 'Adapter .*: on-line' ||
7 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave
8 '';
9 services.acpid = {
10 enable = true;
11 handlers = {
12 brightnessDown = {
13 event = "video/brightnessdown.*";
14 action = "${pkgs.acpilight}/bin/xbacklight -dec 10";
15 };
16 brightnessUp = {
17 event = "video/brightnessup.*";
18 action = "${pkgs.acpilight}/bin/xbacklight -inc 10";
19 };
20 };
21 acEventCommands = ''
22 vals=($1)
23 case ''${vals[3]} in
24 00000000) # unplugged
25 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
26 00000001) # plugged in
27 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
28 esac
29 '';
30 };
31 }