Howto: faster suspend and better power management (update)

How to Guides for Linux, Linpus etc..

Moderator: Davidcowling

Howto: faster suspend and better power management (update)

Postby annafil » Wed Sep 03, 2008 5:23 pm

Update: Sept 4th system update breaks this and reverts most of these changes. If anyone has this update, can you please post if the update actually fixes suspend problems?

Alrighty folks, I got fed up with the limited functionality of kpowersave and how very slow suspend was, so I went and hacked my own solution. This is a fairly long process requiring quite a few hacks because there isn't one good system as of yet. What this howto will hopefully achieve:

- suspend in under 5 seconds
- resume in under 6 seconds
- fix NetworkManager issues with not starting properly during suspend
- allow control over cpu frequency scaling (for instance, having it run performance mode when AC is plugged in, and drop to dynamic if running on battery)
- allow control over default brightness levels on ac/battery
- provide detailed information on battery life and (over time) battery health and performance statistics

If you just want to improve your suspend times, then you only need Part 1 of this guide.

Shall we, then? :)

Part 1 - Fixing Suspend

Run

Code: Select all
sudo cp /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux
/usr/lib/hal/scripts/linux/hal-system-power-suspend-linux.backup


This will backup your existing suspend sequence in case you want to go back to it.

Then to open the file we need for editing:

Code: Select all
sudo mousepad /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux


Replace the entire contents of the file with:

Code: Select all
#!/bin/sh

if [ -x "/usr/sbin/pm-suspend" ] ; then

/bin/sync

/sbin/modprobe -r ath_pci
/sbin/modprobe -r wlan_scan_sta
/sbin/modprobe -r wlan_acl
/sbin/modprobe -r wlan_wep
/sbin/modprobe -r wlan_xauth
/sbin/modprobe -r wlan_ccmp
/sbin/modprobe -r wlan_tkip
/sbin/modprobe -r uvcvideo
/sbin/modprobe -r uhci_hcd

/usr/bin/pm-suspend


/sbin/modprobe ath_pci
/sbin/modprobe wlan_scan_sta
/sbin/modprobe wlan_acl
/sbin/modprobe wlan_wep
/sbin/modprobe wlan_xauth
/sbin/modprobe wlan_ccmp
/sbin/modprobe wlan_tkip
/sbin/modprobe uvcvideo
/sbin/modprobe uhci_hcd

/usr/local/bin/wlanconfig ath0 create wlandev wifi0 wlanmode sta
/sbin/ifconfig ath0 up
/sbin/modprobe coretemp

   RET=$?
else
   # TODO: add support
   unsupported
fi

exit $RET


Step 2

To speed things up even more we need to get rid of some duplicate stuff. Run

Code: Select all
sudo cp -r /usr/lib/pm-utils/sleep.d /usr/lib/pm-utils/sleep.d.backup
rm -rf /usr/lib/pm-utils/sleep.d/*


There, you should have poweroff in about under 5 seconds and about the same to resume. But depending on what other stuff you have on your system, mileage may vary!

Part 2 - Gnome Power Manager

Step 1 - Dependencies

Fix the gnome-menus dependency issue #3 as described by macles in this post: http://macles.blogspot.com/2008/08/depe ... e-one.html

Quote from the blog:
#3 gnome-menus
This depedency problem is triggered via f-spot or evolution, displaying the following error message.

file /usr/share/desktop-directories/Internet.directory from install of gnome-menus-2.20.3-1.fc8 conflicts with file from package xfdesktop-acer-lp-1522.no_spot.mcs_patched
file /usr/share/desktop-directories/Settings.directory from install of gnome-menus-2.20.3-1.fc8 conflicts with file from package xfdesktop-acer-lp-1522.no_spot.mcs_patched

It's fairly easy to fix. Just download gnome-menus and redhat-menus and force their installation. Then restore the original content of the conflicting files.

sudo yum install yum-utils
sudo yumdownloader gnome-menus redhat-menus
sudo rpm -U --force gnome*rpm redhat*rpm

cd /usr/share/desktop-directories
sudo sed -i.1 "s:applications-games:games.png:" Games.directory
sudo sed -i.1 "s:applications-internet:internet.png:" Internet.directory
sudo sed -i.1 "s:gnome-settings:setting-logo.png:" Settings.directory


Step 2 - Install gnome-power-manager

Then from a terminal, run

Code: Select all
sudo yum install gnome-power-manager


It should download a bunch of gnome dependencies, like "gnome-panel" etc. let it.

Step 3 - Remove kpowersave and autostart gnome-power-manager

From a terminal, run

Code: Select all
sudo cp /etc/rc.d/slim/nowait.sh /etc/rc.d/slim/nowait.sh.backup
sudo mousepad /etc/rc.d/slim/nowait.sh


The first line backs up the original file, the second line opens a window allowing us to edit the script.

Look for the following lines:

Code: Select all
while true
do
  kpid=
  kpid=`pidof kpowersave`
  if [ "X${kpid}" == "X" ];then
     /usr/bin/kpowersave &
  fi
  if [ "X${kpid}" != "X" ];then
     break   
  fi
  sleep 3
done


Change all instances of "kpowersave" to "gnome-power-manager", like so:

Code: Select all
while true
do
  kpid=
  kpid=`pidof gnome-power-manager`
  if [ "X${kpid}" == "X" ];then
     /usr/bin/gnome-power-manager &
  fi
  if [ "X${kpid}" != "X" ];then
     break   
  fi
  sleep 3
done


Save and close the file.

Step 4 - Configuration

You don't have to reboot for gnome-power-manager to take effect, simply run

Code: Select all
sudo killall kpowersave
gnome-power-manager


And you should see a battery icon pop up next to your wifi in the taskbar.

Right clicking on the icon gives you a preferences window, they're all pretty self explanatory. But there are a lot more preferences that we can use that aren't available in that menu.

If we want to control cpu frequency scaling depending on if there is ac power or if we're running on battery there is one more step we need to do.

Again in a terminal,

Code: Select all
sudo yum install gconf-editor


This app is a little like the windows registry editor, but for (mostly) gnome apps and not quite so complicated.

Once it's isntalled, you can run it from a terminal using

Code: Select all
gconf-editor


Or press Alt+F2 and type in the above command. Find apps->gnome-power-manager->ui, find "cpufreq_show" and check the box. This will enable the option to configure cpu frequency settings in the right click, preferences menu of gnome-power manager.

There you're done!

You can read up about the other hidden power manager settings by clicking on the name of the setting and reading its long description at the bottom. If you left click on the icon you will get a menu to "suspend" and a clickable battery menu. Clicking on the battery gives you some statistics, the most useful being "battery health" as a percentage of the original capacity.

Right clicking and selecting power history gives you a power history.
Last edited by annafil on Thu Sep 04, 2008 2:24 pm, edited 1 time in total.
annafil
 
Posts: 327
Joined: Tue Aug 12, 2008 6:41 pm
Location: Malaysia

Re: Howto: faster suspend and better power management

Postby philippeC » Wed Sep 03, 2008 7:55 pm

I tried step1: it does suspend and resume faster, (about 10 seconds here), thanks! But the screen freezes with weird colors for one or two seconds, I was wondering if that was something to be worried about?
philippeC
 
Posts: 7
Joined: Wed Sep 03, 2008 7:43 pm

Re: Howto: faster suspend and better power management

Postby annafil » Wed Sep 03, 2008 8:36 pm

philippeC: yeah that's perfectly normal, that's just the graphics driver. it happens a lot (especially on intel graphics) on other distributions when you suspend or hibernate. I've got an ubuntu box that pulls the same psychedelic colours when I suspend - different each time too ;)
annafil
 
Posts: 327
Joined: Tue Aug 12, 2008 6:41 pm
Location: Malaysia

Re: Howto: faster suspend and better power management

Postby Deoki » Thu Sep 04, 2008 12:17 am

Yay!
It works like a charm!

Great tutorial. Thankyou very much annafil.

Oh, and by the way, is there a way to remove the "Hibernate" option from the left-click menu, since the hibernation feature is not enabled?
Still using my girlfriend's White AAO 110 - 8Gb / 512mb Linpus
Sorry for my English errors.
User avatar
Deoki
 
Posts: 39
Joined: Tue Jul 22, 2008 7:04 pm
Location: Cascais > Lisbon > Portugal > Europe

Re: Howto: faster suspend and better power management

Postby annafil » Thu Sep 04, 2008 6:29 am

deoki: it shouldn't be enabled at all.. check the gconf-editor in case you accidentally ticked something there :) there's an option for apps->gnome-power-manager->general
annafil
 
Posts: 327
Joined: Tue Aug 12, 2008 6:41 pm
Location: Malaysia

Re: Howto: faster suspend and better power management

Postby Deoki » Thu Sep 04, 2008 12:11 pm

annafil wrote:deoki: it shouldn't be enabled at all.. check the gconf-editor in case you accidentally ticked something there :) there's an option for apps->gnome-power-manager->general


You are right. "Can_hibernate" was enabled.
I ticked it and "puff" no more useless option on the left-click.

This configurator is trully amazing!

I wonder how many tweak apps are for linux.
Still using my girlfriend's White AAO 110 - 8Gb / 512mb Linpus
Sorry for my English errors.
User avatar
Deoki
 
Posts: 39
Joined: Tue Jul 22, 2008 7:04 pm
Location: Cascais > Lisbon > Portugal > Europe

Re: Howto: faster suspend and better power management

Postby annafil » Thu Sep 04, 2008 12:34 pm

Deoki wrote:I wonder how many tweak apps are for linux.


Linux is endlessly tweakable :) you just need to know how

My next project is multi touch on the touchpad ;)
annafil
 
Posts: 327
Joined: Tue Aug 12, 2008 6:41 pm
Location: Malaysia

Re: Howto: faster suspend and better power management (update)

Postby suki22 » Thu Sep 04, 2008 4:14 pm

Annafil, youre the man!!!

Thx for this tutorial, works 100%.
Im really looking forward to the multitouch tweak, would be awesome!

edit:
I do not have the 4. september update.
Im going to make an image of my system configuration, and than ill give it a try ;)
---- Linpus ----
Aspire One 512MB Ram - Blue
16GB A-Data SDHC Card
40GB external 2,5" Western Digital HD
User avatar
suki22
 
Posts: 24
Joined: Sat Aug 09, 2008 1:23 pm
Location: Germany

Re: Howto: faster suspend and better power management (update)

Postby annafil » Thu Sep 04, 2008 4:27 pm

suki22: technically, I'm the woman but thank you :)
annafil
 
Posts: 327
Joined: Tue Aug 12, 2008 6:41 pm
Location: Malaysia

Re: Howto: faster suspend and better power management (update)

Postby DiSK » Thu Sep 04, 2008 11:37 pm

Lol, owned. :D

So, any bad side effects to this? Annafil, thanks for all your work for us Linux noobs. I know I speak for us all when I say:

YOU'RE AWESOME!! :mrgreen: :mrgreen: :D :D

Thanks again. :)
Netbook: Blue AspireOne AOA150-1249/ZG5 - 120GB
Desktop: Pentium D 950 @ 3.4 GHz, Gigabyte EP35-DS3R, 250GB HDD, 2GB RAM, Quadro NVS 290
DiSK
 
Posts: 180
Joined: Mon Aug 11, 2008 4:53 pm

Next

Return to How to Guides - Linux

Who is online

Users browsing this forum: No registered users and 1 guest