Fix time in battery script

This commit is contained in:
Alexander Bantyev 2021-09-27 14:17:26 +03:00
parent c7cafeba6b
commit 24b4c9e6c2
Signed by: balsoft
GPG Key ID: E081FF12ADCB4AD5

View File

@ -9,9 +9,9 @@
INFO="$(${upower}/bin/upower -i "$dev")" INFO="$(${upower}/bin/upower -i "$dev")"
PERCENTAGE="$(echo "$INFO" | grep 'percentage:' | grep -o '[[:digit:]]*')" PERCENTAGE="$(echo "$INFO" | grep 'percentage:' | grep -o '[[:digit:]]*')"
if [ -n "$PERCENTAGE" ]; then if [ -n "$PERCENTAGE" ]; then
TIME="$(echo "$INFO" | grep 'time to' | tr -s ' ' | cut -d' ' -f5-6)"
STATE="$(echo "$INFO" | grep 'state:' | tr -s ' ' | cut -d' ' -f3)" STATE="$(echo "$INFO" | grep 'state:' | tr -s ' ' | cut -d' ' -f3)"
if [[ "x$STATE" == "xfully-charged" ]] || [[ "x$STATE" == "xcharging" ]]; then if [[ "x$STATE" == "xfully-charged" ]] || [[ "x$STATE" == "xcharging" ]]; then
TIME="$(echo "$INFO" | grep 'time to empty:' | tr -s ' ' | cut -d' ' -f5-6)"
case $PERCENTAGE in case $PERCENTAGE in
[2-3]*) icon=;; [2-3]*) icon=;;
[4-5]*) icon=;; [4-5]*) icon=;;
@ -24,7 +24,6 @@
if [[ "$PERCENTAGE" -lt ${toString low_threshold} ]]; then if [[ "$PERCENTAGE" -lt ${toString low_threshold} ]]; then
STATUS=33 STATUS=33
fi fi
TIME="$(echo "$INFO" | grep 'time to full:' | tr -s ' ' | cut -d' ' -f5-6)"
case $PERCENTAGE in case $PERCENTAGE in
1?) icon=;; 1?) icon=;;
2?) icon=;; 2?) icon=;;