133 |
133 |
134 snprintf(filename,PATH_MAX,"/sys/class/power_supply/%s/status",argv[1]); |
134 snprintf(filename,PATH_MAX,"/sys/class/power_supply/%s/status",argv[1]); |
135 char *status = catfile(filename); |
135 char *status = catfile(filename); |
136 |
136 |
137 int remtime = 0; |
137 int remtime = 0; |
138 char *arrow; |
138 char *arrow = "—"; |
139 |
139 |
140 remtimes_color = color_none; |
140 arrow_color = color_none; |
|
141 remtimes_color = color_green; |
|
142 |
141 if (!strcmp(status,"Charging")) { |
143 if (!strcmp(status,"Charging")) { |
142 if (current_now != 0) |
144 if (current_now != 0) { |
143 remtime = (charge_full-charge_now) / (current_now/60); |
145 remtime = (charge_full-charge_now) / (current_now/60); |
144 arrow = "↑"; |
146 arrow = "↑"; |
145 arrow_color = color_orange; |
147 arrow_color = color_orange; |
|
148 } |
146 } |
149 } |
147 else if (!strcmp(status,"Discharging")) { |
150 else if (!strcmp(status,"Discharging")) { |
148 if (current_now != 0) |
151 if (current_now != 0) { |
149 remtime = charge_now / (current_now/60); |
152 remtime = charge_now / (current_now/60); |
150 arrow = down_arrow; |
153 arrow = down_arrow; |
151 arrow_color = color_none; |
154 arrow_color = color_none; |
152 remtimes_color = color(20,120,0,remtime); |
155 remtimes_color = color(20,120,0,remtime); |
153 } else { |
156 } |
154 arrow = "—"; |
|
155 arrow_color = color_green; |
|
156 } |
157 } |
157 free(status); |
158 free(status); |
158 |
159 |
159 int percent = charge_now/(charge_full/100); |
160 int percent = charge_now/(charge_full/100); |
160 eights_color = percent_color = color(15,40,0,percent); |
161 eights_color = percent_color = color(15,40,0,percent); |