anchor.diff:        }
       '';
     
  +  events = [powerEvent lidEvent acEvent];
  +  
     # Called when the power button is pressed.
     powerEvent =
       { name = "power-button";
  
positive.code:       action = 
          ''
            #! ${pkgs.bash}/bin/sh
  
            if grep -q "state:.*on-line" /proc/acpi/ac_adapter/AC/state; then
               echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
            elif grep -q "state:.*off-line" /proc/acpi/ac_adapter/AC/state; then
               echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
            fi
          '';
      };
  
    events = [powerEvent lidEvent acEvent];
  
  in
  
  mkIf config.powerManagement.enable {
    require = [
      options
    ];
  
    services = {
      extraJobs = [{
        name = "acpid";
  
        job = ''
          description "ACPI daemon"
  
          start on udev
          stop on shutdown
  
          respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir}
        '';
      }];
    };
  }
  
negative.code: { config, pkgs, ... }:
  
  with pkgs.lib;
  
  let
  
  