pandora-libpnd: bump
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_battlow.sh
1 #!/bin/bash
2 # usage: op_shutdown.sh time in seconds
3
4 . /usr/pandora/scripts/op_common.sh
5 xfceuser=$(get_user)
6
7 time=$1
8 if [ x$time = "x" ]; then
9         time=30
10 fi
11 countdown () {
12   for i in $(seq $time); do
13     percentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }')
14     echo $percentage
15     remain=$(echo $time $i | awk '{ printf("%d\n", $1-$2) }')
16     echo "# Low power, shutdown in $remain"
17     sleep 1
18   done
19 }
20 countdown  | su -c 'DISPLAY=:0.0  zenity --progress --auto-close --text "Shutdown" --title "Shutdown"' $xfceuser
21 if [ $? -eq 0 ]; then
22     shutdown -h now
23 else
24     su -c 'DISPLAY=:0.0  zenity --error --text "`printf "Shutdown aborted! \n
25 Please plug in the charger ASAP or shutdown manually, the System will crash in a few minutes"`"' $xfceuser
26 fi