How to Always Be in Powersaving Mode (for laptops)

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

How to Always Be in Powersaving Mode (for laptops)

Postby NarcT on Tue Apr 17, 2012 9:50 pm

Hey everyone so I've been a Linux user for years and one thing that always bothered me was bad power managment for laptops whether that may be hot harddrives or the laptop going into performace mode when plugged into ac power. Well this script will alleviate some of those problems if you have a laptop. So here is what we will do.

**Note this tutorial assumes you are using PM-Utils as compared to laptop-mode-tools. If you haven't installed laptop-mode-tools manually then your fine.

1. Copy the power saving scripts from '/usr/lib/pm-utils/power.d/' to '/etc/pm/power.d/'
2. Run my script to change all of the 'false' values to 'disabled' and all of the 'true' values to 'true|false' thus disabling the system to go to performance mode and always staying in power save mode.
3. Enjoy a cooler laptop!


Step 1
To copy the power saving scripts you type:
Code: Select all
sudo cp -r /usr/lib/pm-utils/power.d/* /etc/pm/power.d/


The reason we do this is because the directory /etc/pm/power.d is for us as users to add scripts or modify them to our liking. The original directory is used for a backup in case the system cannot use our modified scripts.

Step 2
You could change these scripts manually but why not use a script to do it instead? All my script does is look for "false)" and change is to "disabled)" and then change the "true)" to "true|false)". The reason behind this is each script is run with the parameter 'script true' or 'script false' when the system goes from power saving mode or to performance mode. We don't want the system to go to performance mode so we can disable the 'script false' statement by replacing 'disabled' into the statement.
Code: Select all
#!/bin/bash
#--- Purpose is to modify pm-utils scripts to never go into
#--- performance mode and always stay in powersave mode

# if [find 'false']
#    change to 'disabled'
# if [find 'true']
#    change to 'true|false'

folder=/etc/pm/power.d/

for file in $(find $folder -name "*")
do
   sed -i s/"[^|]false)"/" disabled)"/g $file
   sed -i s/"true)"/"true|false)"/g $file
done


Step 3
Enjoy a cooler laptop! Also if you use KDE I've noticed a significant difference in performance with KDE 4.8.
NarcT
Level 1
Level 1
 
Posts: 4
Joined: Tue Apr 17, 2012 9:37 pm

Linux Mint is funded by ads and donations.
 

Re: How to Always Be in Powersaving Mode (for laptops)

Postby bLackJack on Mon Apr 23, 2012 11:08 am

thanks for the script!
A little something to avoid some errors (sorry for my english, i'm french)

Code: Select all
#!/bin/bash
#--- Purpose is to modify pm-utils scripts to never go into
#--- performance mode and always stay in powersave mode

# if [find 'false']
#    change to 'disabled'
# if [find 'true']
#    change to 'true|false'

folder=/etc/pm/power.d/

for file in $(find "$folder" -name "*")
do
   if [ -d "$file" ]; then
       echo Dossier
       continue
   fi
   sed -i s/"[^|]false)"/" disabled)"/g $file
   sed -i s/"true)"/"true|false)"/g $file
done

bLackJack
Level 1
Level 1
 
Posts: 1
Joined: Mon Apr 23, 2012 11:05 am


Return to Tutorials / Howtos

Who is online

Users browsing this forum: Jim Hauser and 6 guests