LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 10-06-2008, 07:17 AM   #1
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Rep: Reputation: 32
Stop processes when on battery to save power


Hi!

Does anyone know if it is possible to stop certain processes from being loaded (by a short start-up script) when one boots the laptop? I have several processes that should be loaded when starting with my laptop plugged in, but when I am working on my battery I don't want them to start (e.g. trackerd, network manager, update notifier, etc.), since they slow my laptop down or are not needed, as I don't have internet access.

Any help appreciated!
 
Old 10-06-2008, 08:08 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
You should be able to use ivman. It uses hal to detect changes in the system, such as when the device is on battery power, and will run whatever command or script you want on selected events. Not just for start-up, but for any change in status, so you can have it start and stop processes any time you switch power supplies.

Last edited by David the H.; 10-06-2008 at 08:10 AM.
 
Old 10-06-2008, 03:50 PM   #3
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Original Poster
Rep: Reputation: 32
I have solved it rather easily by creating a startup script that checks whether the battery or the AC power is used (with grep) and depending on that outcome loads the minimal processes or all, respectively. I then added that script to the start up (preferences>sessions) and deselected the previously selected items (as they are now incorporated in the script).

It does not work with the HAL daemon and does not reactive or deactivate while running if one plugs or pulls out the power cable, but it works for me.

I would be interested to know how to do it with the lvman method, just for good order.
 
Old 10-06-2008, 05:23 PM   #4
BallsOfSteel
Member
 
Registered: Mar 2008
Location: Florida
Distribution: Fedora mainly, but I am open to others.
Posts: 273

Rep: Reputation: 34
If you have an Intel based laptop, there is a program called Powertop and when run from a terminal, it will tell you which processes are using the most power.
 
Old 10-06-2008, 06:10 PM   #5
Kingtiger01
Member
 
Registered: Nov 2006
Distribution: ArchLinux
Posts: 59

Rep: Reputation: 16
unihiekka, being said that you fixed youre own problem. Would you please Post you're script. for if some one else has a Similar issue, they may use you're solution.
 
Old 10-07-2008, 02:54 AM   #6
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Original Poster
Rep: Reputation: 32
You absolutely right, your majesty!

Here's my script:

Code:
#!/bin/bash
#Start with minimum processes on battery power
if grep -q off-line /proc/acpi/ac_adapter/ACAD/state
 then
 #Here come the programmes you wish to start after login (on battery power)
 #For example:
 gnome-power-manager
 #If they are in your $PATH you can just give their binary names, otherwise you have to write the full paths to the applications
elif grep -q on-line /proc/acpi/ac_adapter/ACAD/state
 then
 #Here come the programmes you wish to start after login (on AC power)
 #Examples: 
 gnome-power-manager
 nm-applet --sm-disable &
 restricted-manager --check &
 trackerd &
 update-notifier &
 gnome-volume-manager --sm-disable &
 #etc.  
fi
Go to System > Preferences > Sessions and add it to your startup programmes (first tab). If you always login in English (or some other languague that actually never changes), then you can deselect/remove "User folders update", which is only useful when you change languages and would like your folders to have localized names. If you don't use magnifiers and the like, you can rest assured when you deselect/remove "Visual". This might help the startup process to be slightly quicker.

Actually, for this script to be useful, you have to deselect all startup programmes and add their respective binary names to the script. You can find those names if you click on the items in the list and then click on edit. Just copy-paste the "command" to the correct section of the script (with battery or AC powered). I have added gnome-power-manager to both parts, since I want to know how much battery time there is left (on battery) or how much longer it will take to fully charge my battery (on AC). But you are free to edit the script as much as you like. Just make sure that it is the only selected item in the Sessions list (the others don't have to be removed, merely deselected) and that all programmes that you wish to start are in the script [if this script is selected and the ones that the script should start, then the script restarts these programmes, which in itself is not terrible, but slow and not wise, because the intention of my script is to remove unnecessary programmes at startup]. Then it should do what you hope it to do.

I hope that helps!
 
Old 10-07-2008, 03:21 PM   #7
Kingtiger01
Member
 
Registered: Nov 2006
Distribution: ArchLinux
Posts: 59

Rep: Reputation: 16
thank you for taking the time to share youre solutions with us. im sure it will help some one very much!
 
Old 10-12-2008, 04:18 PM   #8
pinballwizard66
Member
 
Registered: Oct 2008
Posts: 42

Rep: Reputation: 15
yea this thing is very nice, i might even use it when i have classes and no way to plug in the power cord. thanks a lot

Debian Development

Last edited by pinballwizard66; 10-22-2008 at 12:38 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
battery power navarre9 Linux - Laptop and Netbook 5 04-10-2006 06:17 PM
Hang on Battery Power karunesh Linux - Laptop and Netbook 1 10-18-2005 09:45 PM
Enabling power save/power management/cpu freq scaling features for a Debian system zero79 Debian 0 12-19-2004 01:17 PM
Laptop Battery power Ryan450 Linux - Laptop and Netbook 5 06-06-2004 07:31 PM
how to get battery power management wendallsan Linux - Laptop and Netbook 7 10-16-2003 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration