

hasapm accepts the following options:
Operation  Description 

!expr  true if expr is not true 
expr1 & expr2  true if both expr1 and expr2 are true 
expr1  expr2  true if either or both of expr1 and expr2 are true 
expr1 ^ expr2  true if exactly one of expr1 and expr2 is true 
+++ Operation  Description  +++ !expr  true if expr is not true  +++ expr1 & expr2  true if both expr1 and expr2 are    true  +++ expr1  expr2  true if either or both of expr1    and expr2 are true  +++ expr1 ^ expr2  true if exactly one of expr1 and    expr2 is true  +++
Primitive  Description 

(expr)  true if expr is true 
always  true 
never  false (equivalent to !always) 
ac.online  true if using A/C mains power 
ac.unknown  true if the status of the A/C mains power is unknown 
battery.online  true if using batteries rather than A/C mains power 
battery.unknown  true if the status of the batteries is unknown 
charge.unknown  true if the remaining battery charge is unknown 
charge.high  true if the remaining battery charge is high 
charge.low  true if the remaining battery charge is low 
charge.critical  true if the remaining battery charge is critically low 
charge.charging  true if the battery is recharging 
% < percent  true if the percentage of battery charge remaining (if known) is less than percent 
% <= percent  true if the percentage of battery charge remaining (if known) is less than or equal to percent 
% = percent  true if the percentage of battery charge remaining (if known) is equal to percent 
% >= percent  true if the percentage of battery charge remaining (if known) is greater than or equal to percent 
% > percent  true if the percentage of battery charge remaining (if known) is greater than percent 
% != percent  true if the percentage of battery charge remaining (if known) is not equal to percent 
+++ Primitive  Description  +++ (expr)  true if expr is true  +++ always  true  +++ never  false (equivalent to !always)  +++ ac.online  true if using A/C mains power  +++ ac.unknown  true if the status of the A/C    mains power is unknown  +++ battery.online  true if using batteries rather    than A/C mains power  +++ battery.unknown  true if the status of the    batteries is unknown  +++ charge.unknown  true if the remaining battery    charge is unknown  +++ charge.high  true if the remaining battery    charge is high  +++ charge.low  true if the remaining battery    charge is low  +++ charge.critical  true if the remaining battery    charge is critically low  +++ charge.charging  true if the battery is recharging  +++ % < percent  true if the percentage of battery    charge remaining (if known) is    less than percent  +++ % <= percent  true if the percentage of battery    charge remaining (if known) is    less than or equal to percent  +++ % = percent  true if the percentage of battery    charge remaining (if known) is    equal to percent  +++ % >= percent  true if the percentage of battery    charge remaining (if known) is    greater than or equal to percent  +++ % > percent  true if the percentage of battery    charge remaining (if known) is    greater than percent  +++ % != percent  true if the percentage of battery    charge remaining (if known) is    not equal to percent  +++percent can take the values 0 though 100.
If the charge of the battery is unknown (charge.unknown is true) then none of the six relational comparisons evaluates as true.
At most, one of ac.online, battery.online, and ac.unknown is true.
At most, one of battery.unknown, charge.high, charge.low, charge.critical, and charge.charging is true.
Different manufacturers' firmware interprets different percentages of charge remaining as being ``high'', ``low'', or ``critical''.
Typically, an installed battery is considered to be recharging whenever A/C mains power is supplied. However, some machines report a fullycharged battery as having a ``high'' charge.
The example below discusses some other unusual power conditions some BIOSAPM firmware is known to report.
The test condition should be quoted to prevent interpretation by the shell.
The test condition has the same syntax as that understood by the status command of pwrsh(ADM), and the apm.warn and apm.boot checks of boot .
If no options or test are supplied, hasapm behaves as though the options P and V were specified.
If the u option was specified, the machine's BIOSAPM may be usable by the operating system.
If the c option was specified, boot connected to the firmware successfully.
test was true when the system was booted.
powertest="!ac.online & (charge.critical  (!charge.unknown & % < 10))" nopowermsg="No power  the system should not have been booted"The test in this example could be simplified to:/etc/pwr/bin/hasapm s $powertest && echo $nopowermsg
powertest="!ac.online & (charge.critical  % < 10)"This is because any check on the percentage of charge remaining will evaluate as false if the battery's charge is unknown.
On some machines, the BIOSAPM firmware does not know the condition of the battery; it will report no charge remaining (% = 0 is true) rather than admitting that the charge is unknown (charge.unknown is true). Consequently, either of the above test conditions will always be true when such machines are using batteries rather than A/C mains power.
To try to overcome this problem, the test could be changed to:
powertest="!ac.online & !battery.unknown & (charge.critical  % < 10)"However, this will not work on all such machines; some systems can deduce the approximate status of the battery without knowing the percentage charge remaining.
Different manufacturers interpret different percentages of remaining charge or approximate battery status as being ``high'', ``low'', or ``critical''. These interpretations may have been designed to be used with proprietary software, and so may be misleading. They may not produce satisfactory results if they are used as indicators of the battery's charge state. Checking the percentage of remaining charge should be more satisfactory, but is not possible on all machines.