| 1 | <?xml version='1.0' encoding="UTF-8"?> |
1 | <?xml version='1.0' encoding="UTF-8"?> |
| 2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
| 3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.47 2011/08/17 07:10:12 swift Exp $ --> |
3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.48 2011/08/17 07:19:29 swift Exp $ --> |
| 4 | |
4 | |
| 5 | <guide> |
5 | <guide> |
| 6 | <title>Power Management Guide</title> |
6 | <title>Power Management Guide</title> |
| 7 | |
7 | |
| 8 | <author title="Author"> |
8 | <author title="Author"> |
| … | |
… | |
| 22 | |
22 | |
| 23 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
23 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
| 24 | <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
24 | <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
| 25 | <license/> |
25 | <license/> |
| 26 | |
26 | |
| 27 | <version>3</version> |
27 | <version>4</version> |
| 28 | <date>2011-08-17</date> |
28 | <date>2011-08-17</date> |
| 29 | |
29 | |
| 30 | <chapter> |
30 | <chapter> |
| 31 | <title>Introduction</title> |
31 | <title>Introduction</title> |
| 32 | <section> |
32 | <section> |
| 33 | <body> |
33 | <body> |
|
|
34 | |
|
|
35 | <!-- |
|
|
36 | Remove this note after 6 months - ETA 01/02/2012 |
|
|
37 | By then, we can assume that OpenRC migrations are not that frequent |
|
|
38 | anymore and this note can be dropped. |
|
|
39 | ~ Sven Vermeulen |
|
|
40 | --> |
|
|
41 | <impo> |
|
|
42 | Since the introduction of OpenRC, the <c>pmg_switch_runlevel.sh</c> script |
|
|
43 | needs to be updated. If you have issues after the OpenRC upgrade, please update |
|
|
44 | this script according to this guide. |
|
|
45 | </impo> |
| 34 | |
46 | |
| 35 | <p> |
47 | <p> |
| 36 | Capacity and lifetime of laptop batteries have improved much in the last years. |
48 | Capacity and lifetime of laptop batteries have improved much in the last years. |
| 37 | Nevertheless modern processors consume much more energy than older ones and |
49 | Nevertheless modern processors consume much more energy than older ones and |
| 38 | each laptop generation introduces more devices hungry for energy. That's why |
50 | each laptop generation introduces more devices hungry for energy. That's why |
| … | |
… | |
| 289 | </p> |
301 | </p> |
| 290 | |
302 | |
| 291 | <pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> |
303 | <pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> |
| 292 | #!/bin/bash |
304 | #!/bin/bash |
| 293 | |
305 | |
| 294 | <comment># BEGIN configuration</comment> |
306 | # BEGIN configuration |
| 295 | RUNLEVEL_AC="default" |
307 | RUNLEVEL_AC="default" |
| 296 | RUNLEVEL_BATTERY="battery" |
308 | RUNLEVEL_BATTERY="battery" |
| 297 | <comment># END configuration</comment> |
309 | |
|
|
310 | if [ -x /usr/bin/logger ]; then |
|
|
311 | LOGGER="/usr/bin/logger -s -p daemon.info -t /etc/acpi/actions/pmg_switch_runlevel.sh" |
|
|
312 | else |
|
|
313 | LOGGER="/bin/echo" |
|
|
314 | fi |
|
|
315 | |
|
|
316 | ON_AC_POWER=/usr/bin/on_ac_power |
|
|
317 | # END configuration |
| 298 | |
318 | |
| 299 | |
319 | |
| 300 | if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] |
320 | if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] |
| 301 | then |
321 | then |
| 302 | logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." |
322 | ${LOGGER} "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." |
| 303 | exit 1 |
323 | exit 1 |
| 304 | fi |
324 | fi |
| 305 | |
325 | |
| 306 | if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] |
326 | if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] |
| 307 | then |
327 | then |
| 308 | logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." |
328 | ${LOGGER} "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." |
| 309 | exit 1 |
329 | exit 1 |
| 310 | fi |
330 | fi |
| 311 | |
331 | |
| 312 | if on_ac_power |
332 | if ${on_ac_power} |
| 313 | then |
333 | then |
| 314 | if [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] |
334 | if [[ "$(rc-status --runlevel)" != "${RUNLEVEL_AC}" ]] |
| 315 | then |
335 | then |
| 316 | logger "Switching to ${RUNLEVEL_AC} runlevel" |
336 | ${LOGGER} "Switching to ${RUNLEVEL_AC} runlevel" |
| 317 | /sbin/rc ${RUNLEVEL_AC} |
337 | /sbin/rc ${RUNLEVEL_AC} |
| 318 | fi |
338 | fi |
| 319 | elif [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] |
339 | elif [[ "$(rc-status --runlevel)" != "${RUNLEVEL_BATTERY}" ]] |
| 320 | then |
340 | then |
| 321 | logger "Switching to ${RUNLEVEL_BATTERY} runlevel" |
341 | ${LOGGER} "Switching to ${RUNLEVEL_BATTERY} runlevel" |
| 322 | /sbin/rc ${RUNLEVEL_BATTERY} |
342 | /sbin/rc ${RUNLEVEL_BATTERY} |
| 323 | fi |
343 | fi |
| 324 | </pre> |
344 | </pre> |
| 325 | |
345 | |
| 326 | <p> |
346 | <p> |