diff --git a/bin/batperc b/bin/batperc index a14090f..d1aa0b7 100755 --- a/bin/batperc +++ b/bin/batperc @@ -7,13 +7,12 @@ Yellow='\033[1;33m' batteries=$(ls /sys/class/power_supply/ | grep BAT) -if [[ "$batteries" == "" ]]; then - printf "$Yellow**$Red error:$Color_off no battery found\n" - exit 1; -fi - case "$1" in "-c") + if [[ "$batteries" == "" ]]; then + printf "$Yellow**$Red error:$Color_off no battery found\n" + exit 1; + fi for i in $batteries; do batfull=$(cat /sys/class/power_supply/$i/energy_full) batnow=$(cat /sys/class/power_supply/$i/energy_now) @@ -33,6 +32,10 @@ case "$1" in done ;; "-j") + if [[ "$batteries" == "" ]]; then + echo no + exit 1; + fi for i in $batteries; do batfull=$(cat /sys/class/power_supply/$i/energy_full) batnow=$(cat /sys/class/power_supply/$i/energy_now) diff --git a/bin/batpercd b/bin/batpercd index 2f4cc41..1d90705 100755 --- a/bin/batpercd +++ b/bin/batpercd @@ -4,12 +4,13 @@ batperc=$(~/dotfiles/bin/batperc -j) echo $batperc -while true; do - for i in $batperc; do - if [[ "$i" -le "20" ]]; then - notify-send "Battery low: $i%" -u critical - sleep 60 - fi +if [[ "$batperc" != "no" ]]; then + while true; do + for i in $batperc; do + if [[ "$i" -le "20" ]]; then + notify-send "Battery low: $i%" -u critical + sleep 60 + fi + done done -done - +fi