You are not logged in.
Pages: 1
I'm wondering if there's any daemon or anything of the kind that will perform a user defined action after a certain idle time has passed. Particularly, I would like to have my laptop go into sleep/suspend after a certain time of inactivity. Also, related to this, I would like my laptop to hibernate when there's X% battery life left.
Any ideas of how to do any of this?
(btw, I'd prefer not using klaptop).
Offline
hmmm hibernating based on power would be an acpi event...
as for the idle time... maybe you could implement this through xscreensaver somehow... I don't really know any other app that measures X usage...
Offline
Thanks for the tip with xscreensaver, I'll check it out.
With acpi event, do you mean something that I can configure with acpid, then? i.e. define an event tied to, say, the result of "cat /proc/acpi/battery/CMB1/state | grep mAh"...
Offline
With acpi event, do you mean something that I can configure with acpid, then? i.e. define an event tied to, say, the result of "cat /proc/acpi/battery/CMB1/state | grep mAh"...
well, I did some looking around... acpid doesn't expose battery levels through events, however, the gentoo wiki has the following script to poll battery status:
LIMIT="200" ## Suspend if battery level drops below this (in mAh/mWh)
SLEEP="60" ## Seconds between each battery level check
BAT="BAT1" ## Part of path: /proc/acpi/battery/BAT/
HIBERNATE="/usr/local/sbin/hibernate" ## command used to suspend
#HIBERNATE="echo 4 > /proc/acpi/sleep"
while [ true ]; do
if [ -e "/proc/acpi/battery/$BAT/state" ]; then
PRESENT=$(/bin/sed -ne
"/present:/{s/^present:[ ]*([a-z]*)$/1/p;q}"
/proc/acpi/battery/$BAT/state)
#echo $PRESENT
if [ "$PRESENT" = "yes" ]; then
STATE=$(/bin/sed -ne
"/charging state:/{s/^charging state:[ ]*([a-zA-Z]*)$/1/p;q}"
/proc/acpi/battery/$BAT/state)
BATTERY=$(/bin/sed -ne
"/remaining capacity:/{s/^remaining capacity:[ ]*([0-9]*) m[WA]h$/1/p;q}"
/proc/acpi/battery/$BAT/state)
#echo $BATTERY
#echo $STATE
if [ "$BATTERY" -lt "$LIMIT" ] && [ "$STATE" = "discharging" ]; then
## Comment out the following line if you don't
## want to log the event to system log:
logger "Battery at ${BATTERY} mWh. Suspending to disk."
#echo "Battery at ${BATTERY} mWh. Suspending to disk."
## Suspend:
exec "$HIBERNATE"
fi
fi
fi
sleep ${SLEEP}s
done
Offline
Cheers! I'm gonna try that script out. It seems like what I've been looking for.
Offline
The only thing I don't like about it is you won't have any warning... you'll just be typing and BAM, hibernate...
I'd think it'd be better if it's interactive... which would require something more than a bash script... any pythin gurus want to bust something out?
Offline
Sure, when you mention it that would be nice... However, this simple script serves my purposes. I mainly want something to save me those odd moments when I've run off to do something, and completely forgotten my laptop is on battery. Instead of having my unsaved work lost, a hibernate would save my day...
Offline
Offline
Pages: 1