Package Details: batterylife 1-1

Git Clone URL: https://aur.archlinux.org/batterylife.git (read-only)
Package Base: batterylife
Description: Help user keep battery between 40 and 80%
Upstream URL: https://bbs.archlinux.org/viewtopic.php?pid=1431917
Licenses: GPL
Submitter: parchd
Maintainer: parchd
Last Packager: parchd
Votes: 4
Popularity: 0.000866
First Submitted: 2014-07-01 18:00
Last Updated: 2015-06-13 06:55

Latest Comments

nTia89 commented on 2019-01-26 11:09

Hi guys, I want to share with you my version of this script! I hope someone can further improve and adopt it.

! /bin/bash

MIN=40 MAX=80 STATUS=cat /sys/class/power_supply/BAT0/status BAT=cat /sys/class/power_supply/BAT0/capacity

if [ $BAT -le $MIN ] && [ "$STATUS" == 'Discharging' ]; then notify-send --icon=battery --urgency=critical "Battery below $MIN%. Plug it in to preserve battery lifespan!" elif [ $BAT -ge $MAX ] && [ "$STATUS" == 'Charging' ]; then notify-send --icon=battery --urgency=critical "Battery above $MAX%. Unplug it to preserve battery lifespan!" fi

sasank commented on 2017-03-13 13:22

The package as of 03-13-2017 is not working in arch. So I have used your idea and kokoko3k's idea in "https://bbs.archlinux.org/viewtopic.php?pid=1431917" and created a new bash script. The new bash script is as follows
[code]
#! /bin/bash
MIN=40
MAX=80



while true ; do

unplugged=$(cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT?/status|grep -i discharging)
acpiout=$(acpi)
if [ "$(echo $acpiout|grep -Po "[0-9]+(?=%)")" -le $MIN ]; then #Battery under low limit

if [ ! "$unplugged" == "" ]; then #unplugged

notify-send "Battery under $MIN percent. Please plug in the adapter"

fi
elif [ "$(echo $acpiout|grep -Po "[0-9]+(?=%)")" -ge $MAX ]; then #Battery over high limit

if [ "$unplugged" == "" ]; then #plugged

notify-send "Battery above $MAX percent. Please remove the adapter"


fi
fi
sleep 10 #Repeat every 10 seconds

done
[/code]
Can you please incorporate the changes and update the package. Thank You.

parchd commented on 2015-06-03 07:35

Thanks for letting me know, and your welcome - I hope you're finding it useful. I'll fix it when I upload to AUR4.

aaron235 commented on 2015-05-21 07:49

Hi! First time poster to the AUR here. Just thought I'd let you know that your PKGBUILD has a stray comma in the `arch` line, line 15. Thanks for packaging it!