|
Lines 102-120
Link Here
|
| 102 |
|
102 |
|
| 103 |
static volatile sig_atomic_t exit_requested; |
103 |
static volatile sig_atomic_t exit_requested; |
| 104 |
static power_src_t acline_status; |
104 |
static power_src_t acline_status; |
| 105 |
static enum { |
105 |
typedef enum { |
| 106 |
ac_none, |
106 |
ac_none, |
| 107 |
ac_acpi_sysctl, |
107 |
ac_acpi_sysctl, |
| 108 |
ac_acpi_devd, |
108 |
ac_acpi_devd, |
| 109 |
#ifdef USE_APM |
109 |
#ifdef USE_APM |
| 110 |
ac_apm, |
110 |
ac_apm, |
| 111 |
#endif |
111 |
#endif |
| 112 |
} acline_mode; |
112 |
} t_acline_mode; |
|
|
113 |
static t_acline_mode acline_mode; |
| 114 |
static t_acline_mode force_acline_mode = ac_none; |
| 113 |
#ifdef USE_APM |
115 |
#ifdef USE_APM |
| 114 |
static int apm_fd = -1; |
116 |
static int apm_fd = -1; |
| 115 |
#endif |
117 |
#endif |
| 116 |
static int devd_pipe = -1; |
118 |
static int devd_pipe = -1; |
| 117 |
|
|
|
| 118 |
#define DEVD_RETRY_INTERVAL 60 /* seconds */ |
119 |
#define DEVD_RETRY_INTERVAL 60 /* seconds */ |
| 119 |
static struct timeval tried_devd; |
120 |
static struct timeval tried_devd; |
| 120 |
|
121 |
|
|
Lines 230-235
Link Here
|
| 230 |
static void |
231 |
static void |
| 231 |
acline_read(void) |
232 |
acline_read(void) |
| 232 |
{ |
233 |
{ |
|
|
234 |
if (force_acline_mode != ac_none) acline_mode = force_acline_mode; |
| 233 |
if (acline_mode == ac_acpi_devd) { |
235 |
if (acline_mode == ac_acpi_devd) { |
| 234 |
char buf[DEVCTL_MAXBUF], *ptr; |
236 |
char buf[DEVCTL_MAXBUF], *ptr; |
| 235 |
ssize_t rlen; |
237 |
ssize_t rlen; |
|
Lines 275-281
Link Here
|
| 275 |
} |
277 |
} |
| 276 |
#endif |
278 |
#endif |
| 277 |
/* try to (re)connect to devd */ |
279 |
/* try to (re)connect to devd */ |
| 278 |
if (acline_mode == ac_acpi_sysctl) { |
280 |
if (acline_mode == ac_acpi_sysctl && |
|
|
281 |
(force_acline_mode == ac_none |
| 282 |
|| force_acline_mode == ac_acpi_devd)) { |
| 283 |
|
| 279 |
struct timeval now; |
284 |
struct timeval now; |
| 280 |
|
285 |
|
| 281 |
gettimeofday(&now, NULL); |
286 |
gettimeofday(&now, NULL); |
|
Lines 357-363
Link Here
|
| 357 |
{ |
362 |
{ |
| 358 |
|
363 |
|
| 359 |
fprintf(stderr, |
364 |
fprintf(stderr, |
| 360 |
"usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-n mode] [-p ival] [-r %%] [-P pidfile]\n"); |
365 |
"usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-n mode] [-f method] [-p ival] [-r %%] [-P pidfile]\n"); |
| 361 |
exit(1); |
366 |
exit(1); |
| 362 |
} |
367 |
} |
| 363 |
|
368 |
|
|
Lines 387-394
Link Here
|
| 387 |
if (geteuid() != 0) |
392 |
if (geteuid() != 0) |
| 388 |
errx(1, "must be root to run"); |
393 |
errx(1, "must be root to run"); |
| 389 |
|
394 |
|
| 390 |
while ((ch = getopt(argc, argv, "a:b:i:n:p:P:r:v")) != EOF) |
395 |
while ((ch = getopt(argc, argv, "f:a:b:i:n:p:P:r:v")) != EOF) |
| 391 |
switch (ch) { |
396 |
switch (ch) { |
|
|
397 |
case 'f': |
| 398 |
if (strcmp(optarg, "sysctl") == 0) |
| 399 |
{ |
| 400 |
force_acline_mode = ac_acpi_sysctl; |
| 401 |
} |
| 402 |
else if (strcmp(optarg, "devd") == 0) |
| 403 |
{ |
| 404 |
force_acline_mode = ac_acpi_devd; |
| 405 |
} |
| 406 |
#if USE_APM |
| 407 |
else if (strcmp(optarg, "apm") == 0) { |
| 408 |
force_acline_mode = ac_apm; |
| 409 |
} |
| 410 |
#endif |
| 411 |
break; |
| 392 |
case 'a': |
412 |
case 'a': |
| 393 |
parse_mode(optarg, &mode_ac, ch); |
413 |
parse_mode(optarg, &mode_ac, ch); |
| 394 |
break; |
414 |
break; |