2 #actions done when the power button is pressed
3 #only argument is the time the button was pressed in seconds
5 if [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend"
6 if [ -e /tmp/powerstate ]; then
7 powerstate=$(cat /tmp/powerstate)
11 if [ $powerstate -eq "1" ]; then
13 echo 0 > /tmp/powerstate
14 oldbright=$(cat /tmp/oldbright)
15 maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
16 oldspeed=$(cat /tmp/oldspeed)
17 if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then
18 /usr/pandora/scripts/op_bright.sh $oldbright
20 /usr/pandora/scripts/op_bright.sh $maxbright
22 if [ $oldspeed -gt 14 ] && [ $oldspeed -le 1000 ]; then
23 echo $oldspeed > /proc/pandora/cpu_mhz_max
25 echo 500 > /proc/pandora/cpu_mhz_max
28 /etc/init.d/wl1251-init start
29 pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
32 kill -18 $PID #send SIGCONT
36 echo 1 > /tmp/powerstate
37 cat /proc/pandora/cpu_mhz_max > /tmp/oldspeed
38 cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright
39 pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
42 kill -19 $PID #send SIGSTOP
45 /etc/init.d/wl1251-init stop
46 echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
47 echo 14 > /proc/pandora/cpu_mhz_max
49 elif [ "$1" -ge "4" ]; then #button was pressed 4 sec or longer, shutdown
50 xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
53 for i in $(seq $time); do
54 precentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }')
56 echo "# Shutdown in $i"
60 countdown | su -c 'DISPLAY=:0.0 zenity --progress --auto-close --text "Shutdown in X" --title "Shutdown"' $xfceuser
64 su -c 'DISPLAY=:0.0 zenity --error --text "Shutdown aborted!"' $xfceuser