Le 14230ième jour après Epoch, Lothar Behrens écrivait: > Am 17.12.2008 um 13:16 schrieb Timo Juhani Lindfors: > >> Lothar Behrens <lothar.behr...@lollisoft.de> writes: >>> Is there a way to do this ? >> >> while true; do >> if [ `capacity` -lt 10 ]; then >> alert >> fi >> sleep 120 >> done >> > > this is a starting point :-)
I've a small script that works as a daemon, checking interval depends on the charge (described on a file), play sounds (except when charging) depending on the current charge. There is no doc, no install proc, it's not packaged, but it can be done easily... The config file (default values in the script) contains: # Les différents niveaux THRESHOLDS="100:20:1200: 20:10:600:low 10:5:150:critical 5:0:30:emergency" Each group of check parms is max:min:delay:sound If level is between (_max_,_min_), the "aplay" _sound_.wav and wait _delay_ for next check. Hope it helps.
#!/bin/sh # # Start or stop the bat alarm Daemon. # # Written by Francois TOURDE <fr...@tourde.org> # [ -f /etc/default/batalarm ] && . /etc/default/batalarm case "$1" in start) echo -n "Starting batalarm daemon: " start-stop-daemon -S -p /var/run/batalarm.pid -m -x /usr/bin/batalarm & if [ $? = 0 ]; then echo "batalarm." else echo "(failed.)" fi ;; stop) echo -n "Stopping batalarm daemon: " start-stop-daemon -K -p /var/run/batalarm.pid & echo "batalarm." ;; restart|force-reload) $0 stop $0 start exit ;; *) echo "Usage: /etc/init.d/batalarm {start|stop|restart|force-reload}" exit 1 ;; esac exit 0
#!/bin/sh # -*- coding: utf-8 -*- # Batalarm - An application to check bat # # Version 0.1 # # Authors: Francois TOURDE <fr...@tourde.org> # # Copyright (c) 2008 François TOURDE # # batalarm is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at your # option) any later version. # # batalarm is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # TODO # # Change List # # 2008-11-17: First release # First, the default values: BAT_CAPACITY=/sys/devices/platform/bq27000-battery.0/power_supply/bat/capacity BAT_PLUGGED=/sys/devices/platform/bq27000-battery.0/power_supply/bat/online BAT_ALERT=/usr/share/batalarm/sounds/ SLEEP_INIT=600 # # Les différents niveaux THRESHOLDS="100:20:1200: 20:10:600:low 10:5:150:critical 5:0:30:emergency" [ -f /etc/default/batalarm ] && . /etc/default/batalarm while true do v=$(cat $BAT_CAPACITY) for t in $THRESHOLDS do t=$(echo $t|sed -e 's/:/ /g') max=$(echo $t|awk '{print $1}') min=$(echo $t|awk '{print $2}') next=$(echo $t|awk '{print $3}') file=$(echo $t|awk '{print $4}') if [ $v -le $max -a $v -gt $min ] then SLEEP_VAL=$next ALERT_FILE=$file break; fi done [ ! -z $ALERT_FILE ] && [ $(cat $BAT_PLUGGED) != 1 ] && aplay ${BAT_ALERT}${ALERT_FILE}".wav" sleep $SLEEP_VAL done
-- PR: Le serveur (de news) de PacWan est en panne depuis le mois de juillet ! AT: A mon avis ils vont finir par s'en apercevoir, mais il risque de manquer des articles. -+- in: Guide du Cabaliste Usenet - La Cabale se propage (mal) -+-
_______________________________________________ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community