You are not logged in.
Pages: 1
Hi,
I found an interesting script in the gentoo wiki http://de.gentoo-wiki.com/Aktivieren_vo … hlafskript, which let your PC hibernate, if idle. So, thats the skript:
#!/bin/bash
ZEITBISSCHLAF=20
schleife () {
while [ "$HIBERNATE" -eq "0" ]
do
ZEITSTEMPELNEU=$(date +%s)
if [ ! "$ZEITSTEMPELALT" ];then ZEITSTEMPELALT=$ZEITSTEMPELNEU;fi;
INTNEU=$(cat /proc/interrupts|grep i8042|awk '{ print $2 }');
if [ ! "$INTALT" ];then INTALT="012345";fi;
if [ ! "$INTNEU" == "$INTALT" ];
then
ZAEHLER=0;
# echo $ZAEHLER
else
ZAEHLER=$(($ZAEHLER+($ZEITSTEMPELNEU-$ZEITSTEMPELALT)));
# echo $ZAEHLER
fi;
if [ "$ZAEHLER" -ge "$(($ZEITBISSCHLAF*60))" ];
then HIBERNATE=1
fi;
ZEITSTEMPELALT=$ZEITSTEMPELNEU
INTALT=$INTNEU
#alle 10s prüfen
sleep 10
#echo $ZAEHLER
done;
}
#schleife starten
while [ 1 ]
do
ZAEHLER=0
DUNKEL=0
HIBERNATE=0
schleife
Xdialog --title "Hibernate" --timeout 20 --beep --yesno "Rechner einschlafen lassen?" 0 0
case "$?" in
0)
#/etc/init.d/laptop_mode stop
hibernate
#schlafen
#/etc/init.d/laptop_mode start
;;
1) exit ;;
255)
#/etc/init.d/laptop_mode stop
hibernate
#schlafen
#/etc/init.d/laptop_mode start
;;
esac
done
After 20min, there is a dialog where you can choose "yes or no". If you choose "no", the script exits.
1) exit ;;
But is it possible, that you choose "no" and the script/loop starts again? So you could abort the hibernate progress, but after 20min idle, the skript will ask again.
Thanks for your help
dante
"Lasciate ogni speranza, voi ch' entrate"
- Laßt jede Hoffnung hinter euch, ihr, die ihr eintretet -
Dante Alighieri
Offline
Pages: 1