I put the following script in /usr/local/bin/e17_switch_profile.sh :
This has the usage `e17_switch_profile.sh profile_name`, with 'default' being used when no profile name is provided.#!/usr/bin/env bash
# Switch e17 profile based on arg1
# 1. Check if E17 is running
if [ `ps ax | grep enlightenment | grep -v 'grep' | wc -l` -eq 0 ]
then
# no enlightenment running
exit 0
fi
# 2. Make sure E_IPC_SOCKET is set
if [ -z "$E_IPC_SOCKET" ]
then
# we are called from outside of e17
E_IPC_SOCKET=`ls -a /tmp/enlightenment-*/disp-*`
if [ -z "$E_IPC_SOCKET" ]
then
# something wrong with enlightenment!
echo "Cannot set E_IPC_SOCKET!" >> /dev/stderr
exit 0
fi
E_IPC_SOCKET=${E_IPC_SOCKET%|*}
fi
# 3. Get username to switch to
if [ $# -gt 0 ]
then
profile="$1"
else
# switch to default
profile="default"
fi
# 4. Switch enlightenment user!
E_IPC_SOCKET="$E_IPC_SOCKET" enlightenment_remote -default-profile-set $profile
I then modified /etc/acpi/power.sh as follows:
There are three changes from the Ubuntu default:function laptop_mode_enable {
# Local Changes ---------------------------
/usr/local/bin/e17_profile_switch.sh battery
telinit 4
# -----------------------------------------
$LAPTOP_MODE start
# <...DETAILS OMITTED...>
}
function laptop_mode_disable {
# <...DETAILS OMITTED...>
$LAPTOP_MODE stop
# Local Changes ---------------------------
telinit 2
/usr/local/bin/e17_profile_switch.sh ac
# -----------------------------------------
}
- LAPTOP_MODE is enabled (see /etc/laptop_mode/laptop_mode.conf )
- The battery runlevel is 4, while the A/C runlevel is 2 (the default)
- The e17_profile_switch is called to set the profile to either 'battery' or 'ac'
The runlevel trick is one I've been using for awhile: I modify one of the existing runlevels to kill off unnecessary daemons, and optionally to run shell scripts (placed in init.d of course) to do things like change the hard drive spin-down time or the CPU frequency governor. Note that laptop-mode-tools provides this latter capability, so my current battery runlevel just kills off services that aren't that important:
bash# ls -1 /etc/rc4.dSome of these may seem strange choices, but I tend to not use the net when on battery (usually I'm holed up at a coffee shop coding), and likewise I avoid resource-intensive applications (Open Office, KDE, multimedia, etc). If I really want to stretch the battery life I'll kill X, but Acroread and Firefox are a bit useful for consulting documentation.
K19cupsys
K20apport
K20dirmngr
K20hplip
K20ntop
K20privoxy
K20pulseaudio
K20rsync
K20ssh
K20stunnel4
K20tor
K20udftools
K25bluetooth
K30mpd
K89anacron
K89atd
K89cron
K99avahi
K99dbus
K99networking
No comments:
Post a Comment