summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apmd/apmd.h
diff options
context:
space:
mode:
authornsayer <nsayer@FreeBSD.org>2001-05-15 05:13:45 +0000
committernsayer <nsayer@FreeBSD.org>2001-05-15 05:13:45 +0000
commitb5081db59bef2818c352f77a726f2d105b638847 (patch)
tree6a2076a6d6331e348a9a0f5a870a063402e0babd /usr.sbin/apmd/apmd.h
parent2bdf180df8cc9444b255a01377516bec3cd373bd (diff)
downloadFreeBSD-src-b5081db59bef2818c352f77a726f2d105b638847.zip
FreeBSD-src-b5081db59bef2818c352f77a726f2d105b638847.tar.gz
Add battery state monitoring to apmd.
The new syntax available in the config file is: apm_battery [0-9]+(%|[Mm) (dis|)charging { ... } The stuff in the braces is the same as the existing case. nn% checks for a certain percentage of life remaining and nnM checks for a cerain number of minutes remaining. Specifying "discharge" means that you're interested in knowing when the battery reaches a certain level while AC power is off, "charging" the opposite. The man page needs to be updated. The code can be fooled. If you SIGHUP the daemon and the battery level matches a rule it will be performed once per SIGHUP. If the battery level matches a rule and you repeatedly apply and take away AC power, the rule will be run once per occurance. This, however, is a feature. :-) The code also only runs when select() times out, so getting APM events more often than the timeout interval will result in the rules not being run. These are things that remain to be overcome.
Diffstat (limited to 'usr.sbin/apmd/apmd.h')
-rw-r--r--usr.sbin/apmd/apmd.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/usr.sbin/apmd/apmd.h b/usr.sbin/apmd/apmd.h
index e45b84a..b716d0d 100644
--- a/usr.sbin/apmd/apmd.h
+++ b/usr.sbin/apmd/apmd.h
@@ -31,6 +31,7 @@
#define APMD_CONFIGFILE "/etc/apmd.conf"
#define APM_CTL_DEVICEFILE "/dev/apmctl"
+#define APM_NORM_DEVICEFILE "/dev/apm"
#define APMD_PIDFILE "/var/run/apmd.pid"
#define NICE_INCR -20
@@ -77,10 +78,30 @@ struct event_config {
int rejectable;
};
+struct battery_watch_event {
+ struct battery_watch_event *next;
+ int level;
+ enum {
+ BATTERY_CHARGING,
+ BATTERY_DISCHARGING
+ } direction;
+ enum {
+ BATTERY_MINUTES,
+ BATTERY_PERCENT
+ } type;
+ int done;
+ struct event_cmd *cmdlist;
+};
+
+
extern struct event_cmd_op event_cmd_exec_ops;
extern struct event_cmd_op event_cmd_reject_ops;
extern struct event_config events[EVENT_MAX];
+extern struct battery_watch_event *battery_watch_list;
+extern int register_battery_handlers(
+ int level, int direction,
+ struct event_cmd *cmdlist);
extern int register_apm_event_handlers(
bitstr_t bit_decl(evlist, EVENT_MAX),
struct event_cmd *cmdlist);
OpenPOWER on IntegriCloud