View previous topic :: View next topic |
Author |
Message |
pYrania Retired Dev
Joined: 27 Oct 2002 Posts: 650 Location: Cologne - Germany
|
Posted: Sat Mar 01, 2003 11:10 am Post subject: Running Setiathome on Notebook |
|
|
well, that's not a problem of course
my idea was to run seti only while my notebook DOES NOT run on battery.
so is there a way to see whether it is or not? then it would be possible to add a cronjob calling a script every now and then, asking if battery or not and starting / stopping the cpu heating client.
and yes: I AM to lazy to manually do the job _________________ Markus Nigbur |
|
Back to top |
|
|
FuzzeX Tux's lil' helper
Joined: 08 Jan 2003 Posts: 96
|
Posted: Sun Mar 02, 2003 11:14 pm Post subject: |
|
|
I saw your post and was intrigued. I run a notebook, but mostly as a desktop. I poked around in the /proc file system and lo and behold there is an apm entry. I cat-ed it running on AC and the battery and it's contents change depending on if you're plugged into the wall or not. I don't know if there is something similar for acpi.
It should be pretty easy to cook up a script to check that file's contents.
I'm by no means an expert, so there might be a "better" way of doing this. |
|
Back to top |
|
|
FuzzeX Tux's lil' helper
Joined: 08 Jan 2003 Posts: 96
|
Posted: Thu Mar 06, 2003 5:49 am Post subject: |
|
|
Okay, so I got some time to sit down and bash this out.
Code: |
#!/bin/bash
#This script checks if the notebook is running on battery or AC.
#If it is on AC it turns seti on, if on battery it turns seti off.
#
check="1.16 1.2 0x03 0x01 0x0* 0x0* *"
if grep "1" /var/tmp/seti > /dev/null
then
if grep "$check" /proc/apm > /dev/null
then
/etc/init.d/setiathome start > /dev/null 2> /dev/null
else
/etc/init.d/setiathome stop > /dev/null 2> /dev/null
fi
else
/etc/init.d/setiathome stop > /dev/null 2> /dev/null
fi
|
The bulk of this script checks the file /proc/apm to see it the computer is running on battery. The key part of the check variable, for my computer at least, is the 0x01. 0x01 indicates AC power, 0x00 inidicates battery.
The extra bit at the front and end of the script is there so I can set up cron jobs to control what times I want seti to run (run at night, but not while I'm likely to be home and using the computer for instance).
I don't script much so the syntax is likely to be a bit messy, but it works. Hope it's useful. |
|
Back to top |
|
|
pYrania Retired Dev
Joined: 27 Oct 2002 Posts: 650 Location: Cologne - Germany
|
Posted: Sun Mar 09, 2003 1:10 pm Post subject: |
|
|
this would be a nice solution
... but:
whether on AC or not, cat /proc/apm always returns
Quote: | 1.16 1.2 0x03 0x01 0xff 0x80 -1% -1 ? |
going to read some docs about /proc/apm
maybe i'll get it.. _________________ Markus Nigbur |
|
Back to top |
|
|
pYrania Retired Dev
Joined: 27 Oct 2002 Posts: 650 Location: Cologne - Germany
|
Posted: Sun Mar 09, 2003 1:19 pm Post subject: |
|
|
ok, still no changes to my /proc/apm, but i found another way to do the task:
emerge apmd
from manpage:
apmd is an APM monitoring daemon, and works in conjunction with the APM BIOS driver in the OS kernel. It can execute a command (normally a shell script) when certain events are reported by the driver, and will log, via syslogd( , certain changes in system power status. When the avail- able battery power becomes very low, it can alert all users on the system using several methods.
http://fchabaud.free.fr/English/Tricks/Laptop/Apmd/apmd.html _________________ Markus Nigbur |
|
Back to top |
|
|
FuzzeX Tux's lil' helper
Joined: 08 Jan 2003 Posts: 96
|
Posted: Sun Mar 09, 2003 8:19 pm Post subject: |
|
|
I knew there had to be a better way.
This looks much cleaner than my little script. Thanks for the info. |
|
Back to top |
|
|
pYrania Retired Dev
Joined: 27 Oct 2002 Posts: 650 Location: Cologne - Germany
|
Posted: Mon Mar 10, 2003 8:48 pm Post subject: |
|
|
seems like my apm is totaly unusable
/usr/bin/apm always returns 'AC on-line, no system battery'
I'll give up for now _________________ Markus Nigbur |
|
Back to top |
|
|
FuzzeX Tux's lil' helper
Joined: 08 Jan 2003 Posts: 96
|
Posted: Mon Mar 10, 2003 11:10 pm Post subject: apm problem? |
|
|
I had an odd suspicion that something was odd with your apm when your /proc/apm read a battery power of -1%. Perhaps a kernel setting? Or maybe something bios related?
Anyway, here is my new script that is used by apmd. I put it in /etc/apm/event.d
Code: |
#!/bin/bash
#
check="1.16 1.2 0x03 0x01 0x0* 0x0* *"
if [ "$1" = "change" -a "$2" = "power" ];
then
if grep "1" /tmp/seti > /dev/null && grep "$check" /proc/apm > /dev/null
then
/etc/init.d/setiathome start > /dev/null 2> /dev/null
else
/etc/init.d/setiathome stop > /dev/null 2> /dev/null
fi
fi
|
I also cleaned up the script from my ealier post to provide control over when seti is running. I now have a line like: 0 9,23 * * 1-4 root echo "1" >/tmp/seti && cd /usr/sbin/; ./setibatt in my crontab.
Code: |
#!/bin/bash
#This script checks if the notebook is running on battery or AC.
#If it is on AC it turns seti on, if on battery it turns seti off.
#
check="1.16 1.2 0x03 0x01 0x0* 0x0* *"
if grep "1" /tmp/seti > /dev/null && grep "$check" /proc/apm > /dev/null
then
/etc/init.d/setiathome start > /dev/null 2> /dev/null
else
/etc/init.d/setiathome stop > /dev/null 2> /dev/null
fi
|
Hope you get it sorted. |
|
Back to top |
|
|
|