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