Priest of the Order of the Butterfly
Posts: 874 from 2007/4/9
From: Kingston upon ...
And one final one which I've posted a link to before, but may as well dump here again with the other scripts (also a slightly cleaner version).
EDIT: updated to include warning if battery level at 0% :) and up to 15%. Removed downloadable version.This one monitors the battery level and warns you when battery is less than 10% (useful if you knock the power lead out without noticing).
Written purely because I've not been able to get magicbeacon to warn me when the battery is low using the built-in 'batterylow' notifications, but will also work on systems without magicbeacon installed (defaults to CON: if magicbeacon is not found).
No configuration necessary.
Save the following as a script with a project icon in wbstartup (set default tool to c:iconx):
---------------------------------
; kludge script to send alerts when battery is low
; will use magicbeacon if installed, output to con: window if not
; to shut down the script, delete env:battbuttloop and wait for next iteration
; START initial setup
; runs once on script startup
;
; sets loop iteration times - can be easily adjusted here
set loopA "3 mins" ; period between checks when battery >10%
set loopB "2 mins" ; period between checks when battery <10%, but AC connected
set loopC "90" ; period (seconds) between checks when battery <10% and AC not connected.
;
; checks if magicbeacon is installed and sets notify system
if exists SYS:MorphOS/Data/MagicBeacon/MagicBeacon
set Notify "sendbeacon"
else
set Notify "echo >CON:200/200/480/300/BattButt/AUTO/WAIT/CLOSE"
endif
; sanity check to prevent multiple instances. If loop times are changed, this may fail. No biggie though.
; also ensures user has not foolishly copied battbuttloop variable to envarc: at some point
if exists env:battbuttloop
if exists envarc:battbuttloop
delete >NIL: envarc:battbuttloop NOREQ
$Notify "battbuttloop variable found in envarc: and deleted."
endif
$Notify "battbuttloop may already be running.. restarting in $loopA. No intervention required."
delete >NIL: env:battbuttloop NOREQ
wait $loopA
endif
; sets 'running' variable
setenv battbuttloop ""
;
; END initial setup
;main loop
lab BattLoop
if NOT exists env:battbuttloop
skip endlab
endif
run >NIL: c:battery >env:battbutt0
search >NIL: env:battbutt0 PATTERN " (0|1|2|3|4|5|6|7|8|9|10|12|13|14|15) '%"
if WARN
wait $loopA
skip BattLoop BACK
else
search >NIL: env:battbutt0 PATTERN "charging"
if WARN
$Notify "Battery Low! Currently running on battery power. Connect to AC and save work."
wait $loopC
skip BattLoop BACK
endif
$Notify "Battery Low! Charging: Do not disconnect from AC."
wait $loopB
skip BattLoop BACK
endif
; cleanup and notify on exit
lab endlab
$Notify "BattButt exiting - warnings switched off."
if exists env:battbutt0
delete >NIL: env:battbutt0
endif
--------------------------------------------------
[ Edited by boot_wb 09.04.2014 - 18:08 ]www.hullchimneyservices.co.uk
UI: Powerbook 5,6 (1.67GHz, 128MB VRam): OS3.1, OSX 10.5.8
HTPC: Mac Mini G4 (1,5GHz, 64MB VRam): OS3.1 (ZVNC)
Audiophile: Efika 5200b (SB Audigy): OS3.1 (VNC + Virtual Monitor)
Windows free since 2011!