Howto: faster suspend and better power management (update)

Discussion in 'Linux' started by annafil, Sep 3, 2008.

  1. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    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:
    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:
    sudo mousepad /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux
    Replace the entire contents of the file with:

    Code:
    #!/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:
    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:
    Step 2 - Install gnome-power-manager

    Then from a terminal, run

    Code:
    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:
    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:
    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:
    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:
    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:
    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:
    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.
     
    annafil, Sep 3, 2008
    #1
  2. annafil

    philippeC

    Joined:
    Sep 3, 2008
    Messages:
    7
    Likes Received:
    0
    Re: Howto: faster suspend and better power management

    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, Sep 3, 2008
    #2
  3. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    Re: Howto: faster suspend and better power management

    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, Sep 3, 2008
    #3
  4. annafil

    Deoki

    Joined:
    Jul 22, 2008
    Messages:
    39
    Likes Received:
    0
    Location:
    Cascais > Lisbon > Portugal > Europe
    Re: Howto: faster suspend and better power management

    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?
     
    Deoki, Sep 4, 2008
    #4
  5. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    Re: Howto: faster suspend and better power management

    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, Sep 4, 2008
    #5
  6. annafil

    Deoki

    Joined:
    Jul 22, 2008
    Messages:
    39
    Likes Received:
    0
    Location:
    Cascais > Lisbon > Portugal > Europe
    Re: Howto: faster suspend and better power management

    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.
     
    Deoki, Sep 4, 2008
    #6
  7. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    Re: Howto: faster suspend and better power management

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

    My next project is multi touch on the touchpad ;)
     
    annafil, Sep 4, 2008
    #7
  8. annafil

    suki22

    Joined:
    Aug 9, 2008
    Messages:
    24
    Likes Received:
    0
    Location:
    Germany
    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 ;)
     
    suki22, Sep 4, 2008
    #8
  9. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    suki22: technically, I'm the woman but thank you :)
     
    annafil, Sep 4, 2008
    #9
  10. annafil

    DiSK

    Joined:
    Aug 11, 2008
    Messages:
    176
    Likes Received:
    0
    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. :)
     
    DiSK, Sep 5, 2008
    #10
  11. annafil

    Deoki

    Joined:
    Jul 22, 2008
    Messages:
    39
    Likes Received:
    0
    Location:
    Cascais > Lisbon > Portugal > Europe
    Re: Howto: faster suspend and better power management

    I tried to update the system in "Live Update", but it says I already have the "latest software", whatever that means. I have been getting updates very rarely, so I take the opportunity to ask how often have anyone been getting them.

    My system has been working like a charm (aside the noisy fan) but I think I am starting to understand a little more about Linux with the One.

    I tried to work the synaptic multitouch how-to by IBM, but I am still learning the basics, and I know that for the time being, my current limitation is lack of knowledge.

    I will keep an eye on your posts to learn more.

    Thank you again for the great work annafil! :)
     
    Deoki, Sep 5, 2008
    #11
  12. annafil

    rmsoldato

    Joined:
    Jul 29, 2008
    Messages:
    12
    Likes Received:
    0
    Location:
    Hong Kong
    I got the Sept. 4 update, and suspend/resume is just as slow as it normally was.

    I tried making your changes after the Sept. 4 update, and now suspend doesn't work at all.

    Will re-install Linpus tonight.

    Good luck adapting this "how-to" to the Sept. 4 update!
     
    rmsoldato, Sep 5, 2008
    #12
  13. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    na, not really as far as I can see this hack is pretty safe.

    Just be careful of system updates ovveriding the changes
     
    annafil, Sep 5, 2008
    #13
  14. annafil

    suki22

    Joined:
    Aug 9, 2008
    Messages:
    24
    Likes Received:
    0
    Location:
    Germany
    Is it normal that in the mouse-over tool tip on the gnome power safe icon says "battery unloading time unknown" when in battery mode?
    The Kpowersafe app used to show an estimated remaining time in the tooltip...

    Edit:
    Ah okay, it just took a while...
    Hm about 2 hours runtime. I never really looked at a watch to see how long it really lasts but i think the tweaking did something ;)
    At least the suspend time is good now.
     
    suki22, Sep 5, 2008
    #14
  15. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    I have the update, and I managed to get my changes back working the same way with the same commands that I posted. Sure you've done all of it correctly?
     
    annafil, Sep 5, 2008
    #15
  16. annafil

    SuzuKube

    Joined:
    Aug 20, 2008
    Messages:
    53
    Likes Received:
    0
    I try your tuto on my updated to the 5th Septembre aspire one... it seem to work :)

    Edit : Confirmed. All work very well :) I haven't tried the Hibern but Suspend work good :)
     
    SuzuKube, Sep 5, 2008
    #16
  17. annafil

    annafil

    Joined:
    Aug 12, 2008
    Messages:
    327
    Likes Received:
    0
    Location:
    Malaysia
    SuzuKube - I wouldn't use hibernate if i were you. There's a whole thread somewhere on this forum about how that's not a good idea for a SSD :(
     
    annafil, Sep 5, 2008
    #17
  18. annafil

    DiSK

    Joined:
    Aug 11, 2008
    Messages:
    176
    Likes Received:
    0
    There's a September 4th update? You mean from Settings -> Live Update? Why does it keep telling me my computer is up to date? I haven't updated since the day I got it..
     
    DiSK, Sep 6, 2008
    #18
  19. annafil

    rmsoldato

    Joined:
    Jul 29, 2008
    Messages:
    12
    Likes Received:
    0
    Location:
    Hong Kong
    I followed it exactly. No worries, though. I probably didn't dot an 'i' or cross a 't' properly. I'll try again some other time.

    Good work!
     
    rmsoldato, Sep 6, 2008
    #19
  20. annafil

    Happy

    Joined:
    Aug 26, 2008
    Messages:
    3
    Likes Received:
    0
    Ahh, this guide really looks nice. And according to the replies it seems like it works. I really would like to do this on my aao. But what will happen when an update from acer target these areas? It could be messy. Anna, maybe you should send this to Acer and we'll receive it the official way.... :)
     
    Happy, Sep 8, 2008
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.