|
|
As an alternative to configuring the pwrd daemon, you can use the pwrsh(ADM) command to configure, control, or query the power management facilities of your system after it has booted. Typically, you would run pwrsh regularly as a crontab(C) entry for root to check the charge status of the batteries and take appropriate action if necessary. To prevent interaction with pwrd, change the command (cmd) associated with the appropriate event's action to ``exit 0''. See ``Checking battery status regularly'' for an example of how to do this.
pwrsh can read commands from the command line (using
the -c option) from a specified file, from the
standard input, or interactively. If you run pwrsh
interactively, use the ? or help command
for information about other commands. Enter
quit or <Ctrl>D to leave
pwrsh.
You can use the status command to
obtain the boot-time, previous, or current power status of the
machine's AC supply and batteries:
/etc/pwr/bin/pwrsh -c "status -b -AB # print boot-time power status"
/etc/pwr/bin/pwrsh -c "status -n -AB # print previous power status"
/etc/pwr/bin/pwrsh -c "status -AB # print current power status"
You can also specify a power test condition to the
status command in the style of
hasapm(ADM)
-- see also the description for the apm.boot
and apm.warn in
``Advanced Power Management bootstrings''.
pwrsh exits with a value determined by the last command
executed. When a test is used with the status command,
this is the result of the test:
[ /etc/pwr/bin/pwrsh -c "status -s \
!ac.online & (!charge.low | !charge.critical | \
(!charge.unknown & % <= 25))" ] \
&& echo "No AC power and battery charge is low!"
You can use the state command to turn the system or peripheral devices on (Ready) or Off, make them Idle but automatically ready for use, or Freeze them to conserve data.
For example, the following command idles the entire system if
battery power is low and the AC supply is not being used:
[ /etc/pwr/bin/pwrsh -c "status -s \
!ac.online & ( charge.low | charge.critical )" ] \
&& /etc/pwr/bin/pwrsh -c "state -i all"
The following command freezes the video screen and keyboard and
idles the hard and floppy disks:
/etc/pwr/bin/pwrsh -c "state -f display \
state -i storage"
The following crontab entry for root calls the executable file /usr/local/bin/check_batts every 15 minutes:
15 /usr/local/bin/check_batts 2>&1 | mail rootThe check_batts script checks the charge status of the batteries. If the batteries are low, it warns all users and shuts down the system:
: [ /etc/pwr/bin/pwrsh -c "status -s !ac.online & ( charge.low | charge.critical )" ] /etc/shutdown -y -i0 -g00:05 -f "No AC power and battery charge is low! System will shut down in 5 minutes - log off now!"You should also disable pwrd's handling of low battery charge. To do this, edit the entry for the ``apm/batteries-are-low'' (classname/event) entry in /etc/pwr/sys/actions. Change the entry to read:
system/lowbattery-1:apm/batteries-are-low::exit 0then shut down and reboot the system.