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 "2" ]; then # button was pressed 1-2sec, "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 900 ]; then
23 # echo $oldspeed > /proc/pandora/cpu_mhz_max
25 # echo 500 > /proc/pandora/cpu_mhz_max
27 hcistate=$(cat /tmp/hcistate)
28 if [ ! $hcistate ]; then
31 wlstate=$(cat /tmp/wlstate)
32 if [ ! $wlstate ]; then
33 /etc/init.d/wl1251-init start
35 pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
38 kill -18 $PID #send SIGCONT
42 echo 1 > /tmp/powerstate
43 #cat /proc/pandora/cpu_mhz_max > /tmp/oldspeed
44 cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright
45 pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
48 kill -19 $PID #send SIGSTOP
51 hcistate=$(hciconfig hci0 | grep DOWN)
52 if [ $hcistate ]; then
53 echo "down" > /tmp/hcistate
58 wlstate=$(lsmod | grep -m1 wl1251)
59 if [ ! $wlstate ]; then
60 echo "down" > /tmp/wlstate
62 /etc/init.d/wl1251-init stop
64 echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
65 #echo 14 > /proc/pandora/cpu_mhz_max
67 elif [ "$1" -ge "3" ]; then #button was pressed 3 sec or longer, shutdown
68 xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
71 for i in $(seq $time); do
72 precentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }')
74 echo "# Shutdown in $(($time-$i))"
78 countdown | su -c 'DISPLAY=:0.0 zenity --progress --auto-close --text "Shutdown in X" --title "Shutdown"' $xfceuser
82 su -c 'DISPLAY=:0.0 zenity --error --text "Shutdown aborted!"' $xfceuser