X-Git-Url: http://git.scottworley.com/batteryviewer/blobdiff_plain/0f9e308a287e1e6d8cfd73a074d31f06c3e4c937..7281755a19f8bbeb03e11ef0ff5407df6bf59e1b:/batteryviewer.c diff --git a/batteryviewer.c b/batteryviewer.c index 1c38b3c..540db8e 100644 --- a/batteryviewer.c +++ b/batteryviewer.c @@ -6,10 +6,9 @@ #include #include -const char voltage_filename[] = "/sys/class/power_supply/BAT0/voltage_now"; -const char current_filename[] = "/sys/class/power_supply/BAT0/current_now"; - struct State { + char *voltage_filename; + char *current_filename; BVChart *voltage; BVChart *current; }; @@ -42,9 +41,9 @@ static float fatof(const char *filename) { return val; } -static gboolean collect_data(struct State *state __attribute__((unused))) { - fprintf(stderr, "Voltage: %f, current: %f\n", fatof(voltage_filename), - fatof(current_filename)); +static gboolean collect_data(struct State *state) { + fprintf(stderr, "Voltage: %f, current: %f\n", fatof(state->voltage_filename), + fatof(state->current_filename)); return TRUE; } @@ -80,7 +79,10 @@ static void activate(GtkApplication *app, gpointer user_data) { } int main(int argc, char **argv) { - struct State state; + struct State state = { + .voltage_filename = "/sys/class/power_supply/BAT0/voltage_now", + .current_filename = "/sys/class/power_supply/BAT0/current_now", + }; GtkApplication *app = gtk_application_new("com.scottworley.batteryviewer", G_APPLICATION_DEFAULT_FLAGS);