diff options
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/battery.c | 16 | ||||
| -rw-r--r-- | src/modules/battery.h | 2 |
2 files changed, 4 insertions, 14 deletions
diff --git a/src/modules/battery.c b/src/modules/battery.c index 6c656fe..18a68de 100644 --- a/src/modules/battery.c +++ b/src/modules/battery.c @@ -7,8 +7,6 @@ #include <fcntl.h> #include <unistd.h> -#define UPDATE_FREQUENCY 20 - static int open_battery_file(const char * name) { @@ -39,7 +37,6 @@ battery_new() b->full = battery_value(file); b->file_current = open_battery_file("charge_now"); - b->last_update = 0; close(file); @@ -58,16 +55,11 @@ void battery_update(struct battery * b) int now; float percentf; int percent; - time_t now_time = time(NULL); - - if((now_time - b->last_update) >= UPDATE_FREQUENCY) { - b->last_update = now_time; - now = battery_value(b->file_current); + now = battery_value(b->file_current); - percentf = (100.0f / b->full) * now; - percent = round(percentf); + percentf = (100.0f / b->full) * now; + percent = round(percentf); - snprintf(b->value, BATTERY_VALUE_SIZE, "%d%%", percent); - } + snprintf(b->value, BATTERY_VALUE_SIZE, "%d%%", percent); } diff --git a/src/modules/battery.h b/src/modules/battery.h index 92489b5..f358e46 100644 --- a/src/modules/battery.h +++ b/src/modules/battery.h @@ -2,14 +2,12 @@ #define _DWXINFO_MODULES_BATTERY_H_ #include <stdio.h> -#include <time.h> #define BATTERY_VALUE_SIZE 5 struct battery { int full; int file_current; - time_t last_update; char value[BATTERY_VALUE_SIZE]; }; |
