#include "taskbar.h"
#include "battery.h"
#include "clock.h"
+#include "timer.h"
PangoFontDescription *bat1_font_desc=0;
PangoFontDescription *bat2_font_desc=0;
struct batstate battery_state;
int battery_enabled;
+static const struct timeout* battery_timeout=0;
static char buf_bat_percentage[10];
static char buf_bat_time[20];
int8_t battery_low_status;
char *battery_low_cmd=0;
+unsigned char battery_low_cmd_send=0;
char *path_energy_now=0;
char *path_energy_full=0;
char *path_current_now=0;
char *path_status=0;
+void update_batterys()
+{
+ int i;
+ update_battery();
+ for (i=0 ; i < nb_panel ; i++)
+ panel1[i].battery.area.resize = 1;
+}
+
void init_battery()
{
g_free(path1);
g_free(battery_dir);
+
+ if (battery_enabled && battery_timeout==0)
+ battery_timeout = add_timeout(10, 5000, update_batterys);
}
{
Panel *panel = (Panel*)p;
Battery *battery = &panel->battery;
- FILE *fp;
int bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink;
if (!battery_enabled)
FILE *fp;
char tmp[25];
int64_t energy_now = 0, energy_full = 0, current_now = 0;
- int i, seconds = 0;
+ int seconds = 0;
int8_t new_percentage = 0;
fp = fopen(path_status, "r");
if(energy_full > 0)
new_percentage = (energy_now*100)/energy_full;
- if(battery_low_status != 0 && battery_low_status == new_percentage && battery_state.percentage > new_percentage) {
- //printf("battery low, executing: %s\n", battery_low_cmd);
- if (battery_low_cmd) system(battery_low_cmd);
+ if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
+ printf("battery low, executing: %s\n", battery_low_cmd);
+ if (battery_low_cmd)
+ system(battery_low_cmd);
+ battery_low_cmd_send = 1;
}
+ if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
+ battery_low_cmd_send = 0;
+ }
battery_state.percentage = new_percentage;