From c83a1850905aead55b27392ccd3923094fdae116 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 10 Feb 2009 23:25:49 +0000 Subject: [PATCH] * Run the ACPI daemon. This allows the system to respond to ACPI events, like pressing the power button. The NVIDIA X11 driver also needs it to respond to the internal/external monitor switch button on laptops. The power actions should of course be made configurable. svn path=/nixos/trunk/; revision=14027 --- upstart-jobs/acpid.nix | 42 ++++++++++++++++++++++++++++++++++++++++ upstart-jobs/default.nix | 6 ++++++ 2 files changed, 48 insertions(+) create mode 100644 upstart-jobs/acpid.nix diff --git a/upstart-jobs/acpid.nix b/upstart-jobs/acpid.nix new file mode 100644 index 00000000000..5bd1fa63590 --- /dev/null +++ b/upstart-jobs/acpid.nix @@ -0,0 +1,42 @@ +{pkgs, config, ...}: + +let + + acpiConfDir = pkgs.runCommand "acpi-events" {} + '' + ensureDir $out + ln -s ${acpiConfFile} $out/events.conf + ''; + + acpiConfFile = pkgs.writeText "acpi.conf" + '' + event=button/power.* + action=${powerEventHandler} "%e" + ''; + + # Called when the power button is pressed. + powerEventHandler = pkgs.writeScript "acpi-power.sh" + '' + #! ${pkgs.bash}/bin/sh + # Suspend to RAM. + #echo mem > /sys/power/state + exit 0 + ''; + +in + +{ + name = "acpid"; + + extraPath = [pkgs.acpid]; + + job = '' + description "ACPI daemon" + + start on udev + stop on shutdown + + respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir} + ''; + +} diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index bd0581b5870..bd45dda4991 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -342,6 +342,12 @@ let inherit (pkgs) alsaUtils; }) + # ACPI daemon. + ++ optional true /* !!! need some option */ + (import ../upstart-jobs/acpid.nix { + inherit config pkgs; + }) + # D-Bus system-wide daemon. ++ optional config.services.dbus.enable (import ../upstart-jobs/dbus.nix {