summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2025-09-10 19:37:28 +0100
committerSam Light <sam@lightscale.co.uk>2025-09-10 19:37:28 +0100
commit8101b1aa507795224054a752dd603ec3426c40ee (patch)
tree79c593f1d2a8c54f380f1d373a79f21cc5fc4a06 /src/modules
parentd9b456d738e5013d48f41f5e6315ef7c22d6acf0 (diff)
Created better management of updates + update on SIGUSR1
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/battery.c16
-rw-r--r--src/modules/battery.h2
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];
};