From: Hugo Villeneuve Date: Mon, 5 Aug 2013 04:48:45 +0000 (-0400) Subject: Add sleep and volume acpi buttons handler X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=8a12114ecc9a0f7d97ab543785a1a758ea4d0973;p=hvlinux.git Add sleep and volume acpi buttons handler --- diff --git a/stage2/misc/acpi/events/button-lid b/stage2/misc/acpi/events/button-lid new file mode 100644 index 0000000..f0b9022 --- /dev/null +++ b/stage2/misc/acpi/events/button-lid @@ -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 index 0000000..14c1999 --- /dev/null +++ b/stage2/misc/acpi/events/button-power @@ -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 index 0000000..3624cc7 --- /dev/null +++ b/stage2/misc/acpi/events/button-sleep @@ -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 index 0000000..c1d5f6c --- /dev/null +++ b/stage2/misc/acpi/events/mute @@ -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 index 0000000..062ce8d --- /dev/null +++ b/stage2/misc/acpi/events/vol_d @@ -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 index 0000000..58cf41f --- /dev/null +++ b/stage2/misc/acpi/events/vol_u @@ -0,0 +1,3 @@ +event=button/volumeup +action=/etc/acpi/vol.sh + + diff --git a/stage2/misc/acpi/suspend2ram.sh b/stage2/misc/acpi/suspend2ram.sh index f7db74c..5283375 100755 --- a/stage2/misc/acpi/suspend2ram.sh +++ b/stage2/misc/acpi/suspend2ram.sh @@ -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@:@/@'` diff --git a/stage2/pkg/acpid b/stage2/pkg/acpid index afb39ec..f9156b9 100644 --- a/stage2/pkg/acpid +++ b/stage2/pkg/acpid @@ -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