You are not logged in.
Pages: 1
Topic closed
----------
Hello!
I would like to get a warning, like a window popping up, saying that my battery power is running low. How can this be done?
Is it possible to make my machine hibernate if I don't connect it to power if I don't react to the warning?
I'm using a Lenovo Thinkpad T400, with an updated Arch installation, running Fluxbox.
Last edited by WorMzy (2015-07-20 12:54:15)
Ørjan Pettersen
Offline
You may take a look at noteo (AUR).
IIRC you can also give a command to hibernate.
laptop-mode-tools for sure give the possibility to say that the laptop has to hibernate when a critical battery status is reached.
Barghest
Offline
Noteo did't work for me. I never got any warning. I think it is correctly configured.
Ørjan Pettersen
Offline
I use this script to alert me when battery is low
#!/bin/bash
#
#low battery in %
LOW_BATTERY="10"
#critical battery in % (execute action)
CRITICAL_BATTERY="5"
#sleep time 4 script
SLEEP="60"
#acpi battery name
BAT="BAT0"
#action
ACTION="/sbin/poweroff"
#display icon
ICON="/usr/share/icons/oxygen/48x48/devices/battery.png"
#notify sound
PLAY="aplay /usr/local/bin/bears01.wav"
MAX_BATTERY=$(cat /proc/acpi/battery/BAT0/info | grep 'last full' | awk '{print$4}')
LOW_BATTERY=$(($LOW_BATTERY*$MAX_BATTERY/100))
CRITICAL_BATTERY=$(($CRITICAL_BATTERY*$MAX_BATTERY/100))
while [ true ]; do
if [ -e "/proc/acpi/battery/$BAT/state" ]; then
PRESENT=$(grep "present:" /proc/acpi/battery/$BAT/state | awk '{print $2}')
if [ "$PRESENT" = "yes" ]; then
STATE=$(grep "charging state" /proc/acpi/battery/$BAT/state | awk '{print $3}')
CAPACITY=$(grep "remaining capacity" /proc/acpi/battery/$BAT/state | awk '{print $3}')
if [ "$CAPACITY" -lt "$LOW_BATTERY" ] && [ "$STATE" = "discharging" ]; then
$($PLAY)
DISPLAY=:0.0 notify-send -u critical -t 5000 -i "$ICON" "Battery IS low. Plug or Pray." "remaining $CAPACITY mah, shutdown @ $CRITICAL_BATTERY mah"
fi
if [ "$CAPACITY" -lt "$CRITICAL_BATTERY" ] && [ "$STATE" = "discharging" ]; then
$($ACTION)
fi
fi
fi
sleep $SLEEP
done
You have to install notification-daemon or you can look here http://bbs.archlinux.org/viewtopic.php?id=67565
Last edited by atasmrk (2009-04-16 08:09:22)
Offline
Try batterymonitor.
http://code.google.com/p/batterymon
The code in batterymon-hal branch issues low battery notifications (via libnotify) and lets you specify a command to run on critical battery level (eg. sudo pm-hibernate). It's not officially released yet, but give it a try.
Offline
Thanks.
Decided to use the script provided by atasmrk for now. Just made some modifications(removed the while loop) and ran it as a cronjob.
Ørjan Pettersen
Offline
I don't know if flux can load gnome applets, but you might have a look at it:
Arch i686 on Phenom X4 | GTX760
Offline
Little optimization and mod to atasmrk script that works for me:
#!/bin/bash
# low battery in %
LOW_BATTERY="15"
# critical battery in % (execute action)
CRITICAL_BATTERY="10"
# action
ACTION="/sbin/poweroff"
# display icon
ICON="/opt/icons/battery-low-icon.png"
# path to battery /sys
BATTERY_PATH="/sys/class/power_supply/BAT1/"
if [ -e "$BATTERY_PATH" ]; then
BATTERY_ON=$(cat $BATTERY_PATH/status)
if [ "$BATTERY_ON" == "Discharging" ]; then
CURRENT_BATTERY=$(cat $BATTERY_PATH/capacity)
if [ "$CURRENT_BATTERY" -lt "$CRITICAL_BATTERY" ]; then
$($ACTION)
elif [ "$CURRENT_BATTERY" -lt "$LOW_BATTERY" ]; then
notify-send -i "$ICON" "Battery IS low - $CURRENT_BATTERY %."
fi
fi
fi
Laptop Samsung 900X4C-A03
Laptop Samsung RF711, Cpu: Quad core Intel Core i7-2630QM, Kernel: Current x86_64, RAM: 8GB
Drives: SAMSUNG_470_Seri 64.0GB, WDC_WD5000BEVT 500.1GB
Graphics: Intel Integrated Graphics Controller, NVIDIA Corporation GF108 [GeForce GT 540M] (Optimus)
Offline
If you are using #!/bin/bash, you can use the bash `[[` test and you can save some cats:
BATTERY_ON=$(<$BATTERY_PATH/status)
Offline
Pages: 1
Topic closed