Ajout support bouton couvercle
authorgobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Mon, 16 May 2011 00:12:11 +0000 (00:12 +0000)
committergobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Mon, 16 May 2011 00:12:11 +0000 (00:12 +0000)
stage2/misc/acpi/shutdown.sh [new file with mode: 0755]
stage2/misc/acpi/suspend2ram.sh [new file with mode: 0755]
stage2/misc/hvs2ram [deleted file]
stage2/pkg/acpid

diff --git a/stage2/misc/acpi/shutdown.sh b/stage2/misc/acpi/shutdown.sh
new file mode 100755 (executable)
index 0000000..e3dfd90
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+/sbin/shutdown -h now "Power button pressed, shutting down system."
diff --git a/stage2/misc/acpi/suspend2ram.sh b/stage2/misc/acpi/suspend2ram.sh
new file mode 100755 (executable)
index 0000000..11cd412
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+if grep -q open /proc/acpi/button/lid/LID/state; then
+    # Do not act on lid opened event. Only on lid closed.
+    exit 0
+fi
+
+# discover video card's ID
+ID=`lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'`
+
+# securely create a temporary file
+TMP_FILE=`mktemp /var/tmp/video_state.XXXXXX`
+trap 'rm -f $TMP_FILE' 0 1 15
+
+# write all unwritten data (just in case)
+sync
+
+# dump current data from the video card to the
+# temporary file
+cat /proc/bus/pci/$ID > $TMP_FILE
+
+# Stopping network.
+# Sony VAIO PCG-Z505RX and PCMCIA Linksys wifi card
+/etc/rc.d/init.d/network stop
+
+echo "Entering suspend mode"
+
+# suspend
+echo -n mem > /sys/power/state
+
+echo "Resuming"
+
+# restore video card data from the temporary file
+# on resume
+cat $TMP_FILE > /proc/bus/pci/$ID
+
+/etc/rc.d/init.d/network start
+
+# remove temporary file
+rm -f $TMP_FILE
diff --git a/stage2/misc/hvs2ram b/stage2/misc/hvs2ram
deleted file mode 100755 (executable)
index 376b1db..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-# discover video card's ID
-ID=`lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'`
-
-# securely create a temporary file
-TMP_FILE=`mktemp /var/tmp/video_state.XXXXXX`
-trap 'rm -f $TMP_FILE' 0 1 15
-
-# write all unwritten data (just in case)
-sync
-
-# Unmount all removable media
-for p in $(ls /dev/disk/by-id/usb* | grep "\-part"); do
-    umount ${p}
-done
-
-# dump current data from the video card to the
-# temporary file
-cat /proc/bus/pci/$ID > $TMP_FILE
-
-# Stopping network.
-# Sony VAIO PCG-Z505RX and PCMCIA Linksys wifi card
-/etc/rc.d/init.d/network stop
-
-echo "Entering suspend mode"
-
-# suspend
-echo -n mem > /sys/power/state
-
-echo "Resuming"
-
-# restore video card data from the temporary file
-# on resume
-cat $TMP_FILE > /proc/bus/pci/$ID
-
-/etc/rc.d/init.d/network start
-
-# remove temporary file
-rm -f $TMP_FILE
index 8eabe5a..5339d26 100644 (file)
@@ -4,14 +4,19 @@ hvbuild_post()
 {
     install -d -m755 /etc/acpi/events
 
-    cat > /etc/acpi/events/s2ram << EOF
-# When a button/power event is received, the hvs2ram script is run.
+    cat > /etc/acpi/events/button-lid << EOF
+# When the lid is closed, go into suspend to ram
+event=button/lid
+action=/etc/acpi/suspend2ram.sh
+EOF
 
+    cat > /etc/acpi/events/button-power << EOF
+# When the power button is pressed, shutdown the system.
 event=button/power
-action=/usr/local/bin/hvs2ram
-EOF
+action=/etc/acpi/shutdown.shEOF
 
-    install -m755 ${SCRDIR}/misc/hvs2ram /usr/local/bin
+    install -v -m755 ${SCRDIR}/misc/acpi/suspend2ram.sh /etc/acpi
+    install -v -m755 ${SCRDIR}/misc/acpi/shutdown.sh    /etc/acpi
 
     install -v -m740 ${SCRDIR}/bootscripts/acpid /etc/rc.d/init.d
     bootscript_add_rcsysinit acpid 65 90