Code: Select all
--- /initrd/pup_ro2/sbin/pup_event_frontend_d 2012-02-15 15:14:53.000000000 +0100
+++ /sbin/pup_event_frontend_d 2012-06-01 21:40:35.778876979 +0100
Code: Select all
@@ -102,6 +142,26 @@ RETVALm=1
PREVSIZETMPM=0
PREVSIZEFREEM=0
+proc_acpi_func(){
+BAT_0_info_file=/proc/acpi/battery/BAT0/info
+BAT_0_state_file=/proc/acpi/battery/BAT0/state
+BAT_0='0'
+if [ -f "$BAT_0_info_file" -a -f "$BAT_0_info_file" ];then
+BAT_0_DESIGN_CAPACITY=`grep 'design capacity:' "$BAT_0_info_file"`
+BAT_0_DESIGN_CAPACITY="${BAT_0_DESIGN_CAPACITY//[^[:digit:]]/}"
+BAT_0_WARN=$((BAT_0_DESIGN_CAPACITY/15))
+BAT_0_CURRENT=`grep 'remaining capacity:' "$BAT_0_state_file"`
+BAT_0_CURRENT="${BAT_0_CURRENT//[^[:digit:]]/}"
+[ "$BAT_0_DESIGN_CAPACITY" -a "$BAT_0_CURRENT" ] && BAT_0='1'
+fi
+}
+proc_acpi_func
+echo "BAT_0_DESIGN_CAPACITY='$BAT_0_DESIGN_CAPACITY'
+BAT_0_CURRENT='$BAT_0_CURRENT'
+BAT_0_WARN='$BAT_0_WARN'
+BAT_0='$BAT_0'
+"
+
#v424 experiment, automatic unmounting...
auto_unmount_func() {
for ONEMNTPT in `mount | grep '^/dev/' | grep -vE '^/dev/loop|^/dev/ram' | cut -f 3 -d ' ' | grep -v '^/initrd/' | grep -v '^/$' | tr '\n' ' '`
Code: Select all
@@ -764,17 +824,30 @@ do
touch /tmp/snapmergepuppyrequest #request to savepuppy_func.
SAVECNT=0
fi
- if [ $POWERTIMEOUT -ne 0 ];then #w007 power-off computer after inactivity.
+ MINUTECNT=$((MINUTECNT+4))
+ if [ $MINUTECNT -gt 59 ];then #come in here every minute...
+ MINUTECNT=0;echo "Next Minute"
+ if [ "$BAT_0" = '1' ];then echo "BAT_0 detected"
+ BAT_0_CURRENT=`grep 'remaining capacity:' "$BAT_0_state_file"`
+ BAT_0_CURRENT="${BAT_0_CURRENT//[^[:digit:]]/}"
+ echo "BAT_0_CURRENT='$BAT_0_CURRENT'"
+ if [ $BAT_0_CURRENT -lt $BAT_0_WARN ];then
+ aplay /usr/share/audio/2barks.au;aplay /usr/share/audio/2barks.au
+ pupmessage -bg red -timeout 30 "Battery State is: $BAT_0_CURRENT
+better to plug in ac adapter or poweroff the laptop "
+ fi #warn
+ fi #bat
+ if [ $POWERTIMEOUT -ne 0 ];then #w007 power-off computer after inactivity.
MOUSECNT=`expr $MOUSECNT + 4`
- MINUTECNT=`expr $MINUTECNT + 4`
- if [ $MINUTECNT -gt 59 ];then #come in here every minute...
- MINUTECNT=0
- CURPOS2="`getcurpos`"
- echo "MOUSECNT=$MOUSECNT CURPOS2=$CURPOS2" >> /tmp/pup_event_frontend_d_curpos.log
- [ "$CURPOS1" = "" ] && CURPOS1="$CURPOS2"
- [ "$CURPOS1" != "$CURPOS2" ] && MOUSECNT=0
- CURPOS1="$CURPOS2"
- [ $MOUSECNT -gt $POWERTIMEOUT ] && wmpoweroff &
+ #MINUTECNT=`expr $MINUTECNT + 4`
+ #if [ $MINUTECNT -gt 59 ];then #come in here every minute...
+ #MINUTECNT=0
+ CURPOS2="`getcurpos`"
+ #echo "MOUSECNT=$MOUSECNT CURPOS2=$CURPOS2" >> /tmp/pup_event_frontend_d_curpos.log
+ [ "$CURPOS1" = "" ] && CURPOS1="$CURPOS2"
+ [ "$CURPOS1" != "$CURPOS2" ] && MOUSECNT=0
+ CURPOS1="$CURPOS2"
+ [ $MOUSECNT -gt $POWERTIMEOUT ] && wmpoweroff &
fi
fi
#some apps should not be disturbed by this background stuff...
I have only one netbook, the path to /proc/acpi/battery/BAT0/state might vary. Probably worth a tab in the eventmanager GUI.
NOTE 2:
Tested on two frugal installs and worked ok.
NOTE 3:
Might have too much debugging echo output.