#!/bin/bash # BEGIN configuration RUNLEVEL_AC="default" RUNLEVEL_BATTERY="battery" if [ -x /usr/bin/logger ]; then LOGGER="/usr/bin/logger -s -p daemon.info -t /etc/acpi/actions/pmg_switch_runleve.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." exit 1 fi if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] then ${LOGGER} "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." exit 1 fi if ${on_ac_power} then if [[ "$(rc-status --runlevel)" != "${RUNLEVEL_AC}" ]] then ${LOGGER} "Switching to ${RUNLEVEL_AC} runlevel" /sbin/rc ${RUNLEVEL_AC} fi elif [[ "$(rc-status --runlevel)" != "${RUNLEVEL_BATTERY}" ]] then ${LOGGER} "Switching to ${RUNLEVEL_BATTERY} runlevel" /sbin/rc ${RUNLEVEL_BATTERY} fi