swift 11/08/17 07:19:29 Modified: power-management-guide.xml Log: Bug #367145 - Update pmg_switch_runlevel.sh script and add a note in the beginning of the document that this script has been updated
Revision Changes Path 1.48 xml/htdocs/doc/en/power-management-guide.xml file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/power-management-guide.xml?rev=1.48&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/power-management-guide.xml?rev=1.48&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/power-management-guide.xml?r1=1.47&r2=1.48 Index: power-management-guide.xml =================================================================== RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- power-management-guide.xml 17 Aug 2011 07:10:12 -0000 1.47 +++ power-management-guide.xml 17 Aug 2011 07:19:29 -0000 1.48 @@ -1,6 +1,6 @@ <?xml version='1.0' encoding="UTF-8"?> <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.47 2011/08/17 07:10:12 swift Exp $ --> +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.48 2011/08/17 07:19:29 swift Exp $ --> <guide> <title>Power Management Guide</title> @@ -24,7 +24,7 @@ <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> <license/> -<version>3</version> +<version>4</version> <date>2011-08-17</date> <chapter> @@ -32,6 +32,18 @@ <section> <body> +<!-- + Remove this note after 6 months - ETA 01/02/2012 + By then, we can assume that OpenRC migrations are not that frequent + anymore and this note can be dropped. + ~ Sven Vermeulen +--> +<impo> +Since the introduction of OpenRC, the <c>pmg_switch_runlevel.sh</c> script +needs to be updated. If you have issues after the OpenRC upgrade, please update +this script according to this guide. +</impo> + <p> Capacity and lifetime of laptop batteries have improved much in the last years. Nevertheless modern processors consume much more energy than older ones and @@ -291,34 +303,42 @@ <pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> #!/bin/bash -<comment># BEGIN configuration</comment> +# BEGIN configuration RUNLEVEL_AC="default" RUNLEVEL_BATTERY="battery" -<comment># END configuration</comment> + +if [ -x /usr/bin/logger ]; then + LOGGER="/usr/bin/logger -s -p daemon.info -t /etc/acpi/actions/pmg_switch_runlevel.sh" +else + LOGGER="/bin/echo" +fi + +ON_AC_POWER=/usr/bin/on_ac_power +# END configuration if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] then - logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." + ${LOGGER} "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." exit 1 fi if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] then - logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." + ${LOGGER} "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." exit 1 fi -if on_ac_power +if ${on_ac_power} then - if [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] + if [[ "$(rc-status --runlevel)" != "${RUNLEVEL_AC}" ]] then - logger "Switching to ${RUNLEVEL_AC} runlevel" - /sbin/rc ${RUNLEVEL_AC} + ${LOGGER} "Switching to ${RUNLEVEL_AC} runlevel" + /sbin/rc ${RUNLEVEL_AC} fi -elif [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] +elif [[ "$(rc-status --runlevel)" != "${RUNLEVEL_BATTERY}" ]] then - logger "Switching to ${RUNLEVEL_BATTERY} runlevel" + ${LOGGER} "Switching to ${RUNLEVEL_BATTERY} runlevel" /sbin/rc ${RUNLEVEL_BATTERY} fi </pre>