You are not logged in.

#1 2009-05-07 12:23:24

lynix
Member
From: Karlsruhe, Germany
Registered: 2008-04-23
Posts: 230

Tweaking rc.multi for laptop-mode

Hi, there!

I recently noticed that my notebook (when run on battery) first starts all daemons listed in rc.conf and then (when laptop-mode-daemon is loaded) just terminates them (at least those in /etc/laptop-mode/batt-stop), which is quite useless.

My idea then was to filter the DAEMONS-array before it gets read by rc.multi. This way, the services that are not needed on battery won't even start, which makes my bootup ~3-4s faster.

Here's my peace of work; maybe someone finds it useful:

/etc/rc.multi:

(...)
# Load sysctl variables if sysctl.conf is present
[ -r /etc/sysctl.conf ] && /sbin/sysctl -q -p &>/dev/null

# Check for battery state, filter DAEMONS if on battery power
[ -r /proc/acpi/ac_adapter/ACAD/state ] && grep on-line /proc/acpi/ac_adapter/ACAD/state &>/dev/null
if [ $? -gt 0 ]; then
    for n in $(seq 0 $((${#DAEMONS[@]} - 1))); do
        [ -e /etc/laptop-mode/batt-stop/${DAEMONS[$n]} ] && unset DAEMONS[$n]
    done
fi

# Start daemons
(...)

lynix

Offline

Board footer

Powered by FluxBB