From: vimacs Date: Thu, 18 Feb 2010 16:25:55 +0000 (+0100) Subject: new file: testdata/scripts/op_battlow.sh X-Git-Tag: Release-2010-05/1~108 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be7af38c6b2a8bdbeb144326403c570c073d3c1e;p=pandora-libraries.git new file: testdata/scripts/op_battlow.sh --- diff --git a/testdata/scripts/op_battlow.sh b/testdata/scripts/op_battlow.sh new file mode 100755 index 0000000..15c2831 --- /dev/null +++ b/testdata/scripts/op_battlow.sh @@ -0,0 +1,19 @@ +#!/bin/bash +#usage op_shutdown.sh time in seconds +xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}') +time=$1 +countdown () { + for i in $(seq $time); do + precentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }') + echo $precentage + echo "# Low power, shutdown in $i" + sleep 1 + done +} +countdown | su -c 'DISPLAY=:0.0 zenity --progress --auto-close --text "Shutdown" --title "Shutdown"' $xfceuser +if [ $? -eq 0 ]; then +shutdown -h now +else +su -c 'DISPLAY=:0.0 zenity --error --text "`printf "Shutdown aborted! \n +Pleas plug in the charger ASAP or shutdown manually, the System will crash in a few minuts"`"' $xfceuser +fi \ No newline at end of file