new file: testdata/scripts/op_battlow.sh
authorvimacs <vimacs@pndtest>
Thu, 18 Feb 2010 16:25:55 +0000 (17:25 +0100)
committervimacs <vimacs@pndtest>
Thu, 18 Feb 2010 16:25:55 +0000 (17:25 +0100)
testdata/scripts/op_battlow.sh [new file with mode: 0755]

diff --git a/testdata/scripts/op_battlow.sh b/testdata/scripts/op_battlow.sh
new file mode 100755 (executable)
index 0000000..15c2831
--- /dev/null
@@ -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