You are not logged in.
Pages: 1
Hi eveyone I'm new to Arch and I would like it to suspend or maybe shutdown when the battery gets low. I looked around and I got confused by all the options. Right now I have acpid installed. I start hal in my rc.conf DEAMONS, which starts acpid. I put two files in /etc/acpi/events that shutdown the computer if I hit the power button and suspend if I close the lid on my laptop. It seems that I should be able to add an additional file that will suspend when the battery gets low, but I don't know what I should put in it.
Any help would be appreciated.
Also I did search and someone suggested using laptop-tools to do this, but it seemed much more complicated to set up, but if it is worth it let me know.
Oh and I have and aspire one, and am trying to avoid installing gnome/gnome power manager.
Offline
You could make a script that checks your battery level and, if its less than a certain level, suspend the computer. Put that script in a 5 minute cron job and that could work.
Last edited by djnm (2009-01-03 19:37:47)
br0tat0chip in #archlinux and on freenode
Offline
Personally I use laptop-mode-tools for this, since I use it anyways, but if you want a standalone script you can try this: http://en.gentoo-wiki.zugaina.org/index … ery_is_Low
Offline
Not all batteries report events and have alarm support (while some report back but very rarely (or only on AC events) so it's not good enough for laptop-mode-tools hibernate module). First check your acpid logs and see if you have regular BAT reports... if not, the script from Gentoo wiki is good enough (btw the author of laptop-mode-tools said that in the future such script could be included in the package, for less fortunate folks).
You need to install an RTFM interface.
Offline
$ cat /var/log/acpid.log |grep -i bat
returns nothing
and
$ cat /proc/acpi/battery/BAT1/alarm
returns
alarm: unsupported
I think this means I need to try the gentoo scripts/ write my own.
Oh and does laptop-mode-tools used acpid or does it replace acpid? I have and SSD but it seems like it might still have some power saving features. I will look into it.
Offline
Oh and does laptop-mode-tools used acpid or does it replace acpid?
Laptop-mode-tools is just a shell script that performs a bunch of actions when called. It comes with it's own scripts to use as acpid event handlers, but you can discard those and call laptop-mode-tools from your own handler(s) on AC/ADP events (/usr/sbin/laptop_mode auto), if you choose so.
Edit: Just to be clear, it should also be called on BAT events for auto-hibernate module (apparently useless on your system)
Last edited by anrxc (2009-01-04 03:44:01)
You need to install an RTFM interface.
Offline
Here is the script I have cron'd, running every five minutes:
$ crontab -l |grep suspend
*/5 * * * * $HOME/bin/suspend.sh
$ cat suspend.sh
#!/bin/bash
battery='-';
bat_dir="/proc/acpi/battery/BAT0";
if [ -d "$bat_dir" ]; then
remaining="$(awk '/remaining capacity/ {print $3}' <${bat_dir}/state)"
total="$(awk '/last full capacity/ {print $4}' <${bat_dir}/info)"
battery_level="$((remaining *100 /total))"
battery="${battery_level}"
fi
if (( "${battery}" <= 5 )); then
/usr/sbin/pm-suspend
fi
echo "${battery}"
Offline
Thanks eveyone I got it working. I decided on using a shell script. I do have one more question. Since I don't have a hard disk is there any power saving benefits from laptop-mode-tools? I do have frequency scaling being handled (by hal I think). I don't see how it would help, but anything to impove battery life is good.
Oh and I really like arch!
Offline
See for yourself if it makes any difference -- just use powertop to monitor power use with and without laptop-mode-tools enabled.
Offline
I tried steve's suspend.sh script but when i try to execute it i get the following error:
/bin/suspend.sh: line 13: ((: - <= 5 : syntax error: operand expected (error token is "<= 5 ")
Anyone can help me to understand the reason?
I must add that I'm not using Arch linux, I'm using Salix 13.1 (based on Slackware 13.1)...
Offline
/bin/suspend.sh: line 13: ((: - <= 5 : syntax error: operand expected (error token is "<= 5 ")
The battery variable is not being set to anything other than a dash (-) and it's erroring on the comparison between the - and a number.
If I were you, I'd write my own script.
Offline
OK, i found the problem, my mistake!
In my case i had to change from /proc/acpi/battery/BAT0 to /proc/acpi/battery/BAT1.
the script seems to work excellent now!
Offline
Pages: 1