From be7af38c6b2a8bdbeb144326403c570c073d3c1e Mon Sep 17 00:00:00 2001 From: vimacs Date: Thu, 18 Feb 2010 17:25:55 +0100 Subject: [PATCH] new file: testdata/scripts/op_battlow.sh --- testdata/scripts/op_battlow.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 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 -- 2.39.5