@@ -30,25 +30,131 @@ battery() {
3030
3131 if [[ -f $PREFIX /bin/termux-battery-status ]]; then
3232
33- percentage=` termux-battery-status | grep percentage | awk ' {print $2}' | tr , ' %' `
33+
34+ perc=` termux-battery-status | grep percentage | awk ' {print $2}' | tr , ' %' `
35+ # debug perc
36+ # perc=9
3437 status=` termux-battery-status | grep status | awk ' {print $2}' `
35- lyw=' \e[93m'
36- lgn=' \e[92m'
37- df=' \e[39m'
38+ lrd=" \e[91m"
39+ lyw=" \e[93m"
40+ lgn=" \e[92m"
41+ df=" \e[39m"
3842
39- if [[ $status == ' "CHARGING", ' ]] ; then
43+ old () {
4044
41- echo -e $lgn " $df : Charging, ( ${percentage} ) "
45+ if [[ $status == ' "CHARGING", ' ]] ; then
4246
43- elif [[ $status == ' "DISCHARGING", ' ]] ; then
47+ echo -e $lgn " $df : Charging, ( ${perc} ) "
4448
45- echo -e $lyw " $df : Discharging, ( ${percentage} ) "
49+ elif [[ $status == ' "DISCHARGING", ' ]] ; then
4650
47- elif [[ $status == ' "FULL" ' ]] ; then
51+ echo -e $lyw " $df : Discharging, ( ${perc} ) "
4852
49- echo -e $lgn " $df : Full, ( ${percentage} ) "
53+ elif [[ $status == ' "FULL" ' ]] ; then
5054
51- fi
55+ echo -e $lgn " $df : Full, (${perc} )"
56+
57+ fi
58+
59+ }
60+
61+
62+ new () {
63+
64+ # Known bug :
65+ # - Icon : 100% Battery on Discharging
66+ # 3-9% Battery on Discharging
67+
68+ # Discharging
69+
70+ if [[ $perc < 21 && $status == ' "DISCHARGING",' ]]; then
71+
72+ echo -e $lrd " $df : Discharging, (${perc} )"
73+
74+ elif [[ $perc < 30, && $perc > 20 && $status == ' "DISCHARGING",' ]]; then
75+
76+ echo -e $lyw " $df : Discharging, (${perc} )"
77+
78+ elif [[ $perc < 40 && $perc > 29 && $status == ' "DISCHARGING",' ]]; then
79+
80+ echo -e $lyw " $df : Discharging, (${perc} )"
81+
82+ elif [[ $perc < 50 && $perc > 39 && $status == ' "DISCHARGING",' ]]; then
83+
84+ echo -e $lyw " $df : Discharging, (${perc} )"
85+
86+ elif [[ $perc < 60 && $perc > 49 && $status == ' "DISCHARGING",' ]]; then
87+
88+ echo -e $lyw " $df : Discharging, (${perc} )"
89+
90+ elif [[ $perc < 70 && $perc > 59 && $status == ' "DISCHARGING",' ]]; then
91+
92+ echo -e $lyw " $df : Discharging, (${perc} )"
93+
94+ elif [[ $perc < 80 && $perc > 69 && $status == ' "DISCHARGING",' ]]; then
95+
96+ echo -e $lyw " $df : Discharging, (${perc} )"
97+
98+ elif [[ $perc < 90 && $perc > 79 && $status == ' "DISCHARGING",' ]]; then
99+
100+ echo -e $lyw " $df : Discharging, (${perc} )"
101+
102+ elif [[ $perc < 99, && $perc > 89 && $status == ' "DISCHARGING",' ]]; then
103+
104+ echo -e $lyw " $df : Discharging, (${perc} )"
105+
106+ elif [[ $perc == 100 && $status == ' "DISCHARGING",' ]]; then
107+
108+ echo -e $lgn " $df : Discharging, (${perc} )"
109+
110+
111+ # Charging
112+
113+ elif [[ $perc < 21 && $perc > 2 && $status == ' "CHARGING",' ]]; then
114+
115+ echo -e $lgn " $df : Charging, (${perc} )"
116+
117+ elif [[ $perc < 30 && $perc > 20 && $status == ' "CHARGING",' ]]; then
118+
119+ echo -e $lgn " $df : Charging, (${perc} )"
120+
121+ elif [[ $perc < 40 && $perc > 29 && $status == ' "CHARGING",' ]]; then
122+
123+ echo -e $lgn " $df : Charging, (${perc} )"
124+
125+ elif [[ $perc < 50 && $perc > 39 && $status == ' "CHARGING",' ]]; then
126+
127+ echo -e $lgn " $df : Charging, (${perc} )"
128+
129+ elif [[ $perc < 60 && $perc > 49 && $status == ' "CHARGING",' ]]; then
130+
131+ echo -e $lgn " $df : Charging, (${perc} )"
132+
133+ elif [[ $perc < 70 && $perc > 59 && $status == ' "CHARGING",' ]]; then
134+
135+ echo -e $lgn " $df : Charging, (${perc} )"
136+
137+ elif [[ $perc < 80 && $perc > 69 && $status == ' "CHARGING",' ]]; then
138+
139+ echo -e $lgn " $df : Charging, (${perc} )"
140+
141+ elif [[ $perc < 90 && $perc > 79 && $status == ' "CHARGING",' ]]; then
142+
143+ echo -e $lgn " $df : Charging, (${perc} )"
144+
145+ elif [[ $perc < 99,5 && $perc > 89 && $status == ' "CHARGING",' ]]; then
146+
147+ echo -e $lgn " $df : Charging, (${perc} )"
148+
149+ elif [[ $perc == 100 && $status == ' "CHARGING",' ]]; then
150+
151+ echo -e $lgn " $df : Charging, (${perc} )"
152+
153+ fi
154+
155+ }
156+
157+ new
52158
53159 else
54160
@@ -60,7 +166,7 @@ battery() {
60166
61167version () {
62168
63- echo -e " neofetch output v.0.3.0"
169+ echo -e " neofetch output v.0.3.0 pre "
64170
65171}
66172
0 commit comments