Add sleep and volume acpi buttons handler
authorHugo Villeneuve <hugo@hugovil.com>
Mon, 5 Aug 2013 04:48:45 +0000 (00:48 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Wed, 7 Aug 2013 17:50:22 +0000 (13:50 -0400)
stage2/misc/acpi/events/button-lid [new file with mode: 0644]
stage2/misc/acpi/events/button-power [new file with mode: 0644]
stage2/misc/acpi/events/button-sleep [new file with mode: 0644]
stage2/misc/acpi/events/mute [new file with mode: 0644]
stage2/misc/acpi/events/vol_d [new file with mode: 0644]
stage2/misc/acpi/events/vol_u [new file with mode: 0644]
stage2/misc/acpi/suspend2ram.sh
stage2/pkg/acpid

diff --git a/stage2/misc/acpi/events/button-lid b/stage2/misc/acpi/events/button-lid
new file mode 100644 (file)
index 0000000..f0b9022
--- /dev/null
@@ -0,0 +1,3 @@
+# When the lid is closed, go into suspend to ram
+event=button/lid
+action=/etc/acpi/suspend2ram.sh button-lid
diff --git a/stage2/misc/acpi/events/button-power b/stage2/misc/acpi/events/button-power
new file mode 100644 (file)
index 0000000..14c1999
--- /dev/null
@@ -0,0 +1,3 @@
+# When the power button is pressed, shutdown the system.
+event=button/power
+action=/etc/acpi/shutdown.sh
diff --git a/stage2/misc/acpi/events/button-sleep b/stage2/misc/acpi/events/button-sleep
new file mode 100644 (file)
index 0000000..3624cc7
--- /dev/null
@@ -0,0 +1,3 @@
+# When the lid is closed, go into suspend to ram
+event=button/sleep
+action=/etc/acpi/suspend2ram.sh button-sleep
diff --git a/stage2/misc/acpi/events/mute b/stage2/misc/acpi/events/mute
new file mode 100644 (file)
index 0000000..c1d5f6c
--- /dev/null
@@ -0,0 +1,2 @@
+event=button/mute
+action=/usr/bin/amixer set Master toggle
diff --git a/stage2/misc/acpi/events/vol_d b/stage2/misc/acpi/events/vol_d
new file mode 100644 (file)
index 0000000..062ce8d
--- /dev/null
@@ -0,0 +1,2 @@
+event=button/volumedown
+action=/etc/acpi/vol.sh -
diff --git a/stage2/misc/acpi/events/vol_u b/stage2/misc/acpi/events/vol_u
new file mode 100644 (file)
index 0000000..58cf41f
--- /dev/null
@@ -0,0 +1,3 @@
+event=button/volumeup
+action=/etc/acpi/vol.sh +
+
index f7db74c..5283375 100755 (executable)
@@ -1,11 +1,26 @@
 #!/bin/sh
 
-if [ -f /proc/acpi/button/lid/LID/state ]; then
-    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
-fi
+case "$1" in
+    button-sleep)
+        logger "Sleep button pressed"
+        ;;
+    button-lid)
+        if [ -f /proc/acpi/button/lid/LID/state ]; then
+            if grep -q open /proc/acpi/button/lid/LID/state; then
+                logger "Lid opened detected, do nothing"
+                # Do not act on lid opened event. Only on lid closed.
+                exit 0
+            fi
+
+            logger "Lid closed detected"
+        fi
+        ;;
+    *)
+        logger "Unknown event: ${1}"
+        ;;
+esac
+
+logger "Going to sleep"
 
 # discover video card's ID
 ID=`lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'`
index afb39ec..f9156b9 100644 (file)
@@ -4,17 +4,7 @@ hvbuild_post()
 {
     install -v -d -m755 /etc/acpi/events
 
-    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=/etc/acpi/shutdown.sh
-EOF
+    install -v -m644 ${SCRDIR}/misc/acpi/events/* /etc/acpi/events
 
     install -v -m755 ${SCRDIR}/misc/acpi/suspend2ram.sh /etc/acpi
     install -v -m755 ${SCRDIR}/misc/acpi/shutdown.sh    /etc/acpi