This bug quickly degrades the battery making me recharge it too often. To prevent the system from discharging the battery I've wrote the following startup script:
#!/bin/sh
### BEGIN INIT INFO
# Provides: haltIfNousers
# Required-Start:
# Required-Stop:
# Should-Start: gdm
# Default-Start: 2 3
# Default-Stop: 4 5
# Short-Description: Execute the halt command.
# Description:
### END INIT INFO
#Powers off the system if no user is logged in in 30 seconds
BLOCK_FILE=/tmp/haltIfNousers
case "$1" in
start)
$0 wait &
;;
wait)
touch "$BLOCK_FILE"
sleep 30
[ -e "$BLOCK_FILE" ] || exit 0
if ! who|grep '.*' -q ; then
echo $0: No users are logged in. Halting now.
shutdown -h now
exit 0
fi
rm -f "$BLOCK_FILE"
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
rm -f "$BLOCK_FILE"
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
This script checks if a user is logged on in 30 seconds after system boot and if he is not, shuts the system down.
Commented lines at the top of the script are Debian LSB header that drives its new dependecy based boot system. This header requests starting the script after gdb making measured time interval for user to login more precise.
Комментариев нет:
Отправить комментарий