2009-05-15 20:48:55 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* Copyright (C) 2009 Sebastian Reichel <elektranox@gmail.com>
|
|
|
|
*
|
|
|
|
* Battery with functional data (percentage, time to life) and drawing data
|
|
|
|
* (area, font, ...). Each panel use his own drawing data.
|
2009-05-31 12:40:40 +00:00
|
|
|
* Need kernel > 2.6.23.
|
2009-05-15 20:48:55 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef BATTERY_H
|
|
|
|
#define BATTERY_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "area.h"
|
|
|
|
|
2009-10-18 17:54:09 +00:00
|
|
|
|
2009-10-28 23:01:32 +00:00
|
|
|
// battery drawing parameter (per panel)
|
2009-05-15 20:48:55 +00:00
|
|
|
typedef struct Battery {
|
2009-09-20 20:48:00 +00:00
|
|
|
// always start with area
|
|
|
|
Area area;
|
2009-05-15 20:48:55 +00:00
|
|
|
|
2010-01-09 00:11:01 +00:00
|
|
|
Color font;
|
2009-09-20 20:48:00 +00:00
|
|
|
int bat1_posy;
|
|
|
|
int bat2_posy;
|
2009-05-15 20:48:55 +00:00
|
|
|
} Battery;
|
|
|
|
|
|
|
|
enum chargestate {
|
|
|
|
BATTERY_UNKNOWN,
|
|
|
|
BATTERY_CHARGING,
|
2009-10-28 10:58:12 +00:00
|
|
|
BATTERY_DISCHARGING,
|
|
|
|
BATTERY_FULL
|
2009-05-15 20:48:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct battime {
|
|
|
|
int16_t hours;
|
|
|
|
int8_t minutes;
|
|
|
|
int8_t seconds;
|
|
|
|
} battime;
|
|
|
|
|
|
|
|
typedef struct batstate {
|
|
|
|
int percentage;
|
|
|
|
struct battime time;
|
|
|
|
enum chargestate state;
|
|
|
|
} batstate;
|
|
|
|
|
|
|
|
extern struct batstate battery_state;
|
|
|
|
extern PangoFontDescription *bat1_font_desc;
|
|
|
|
extern PangoFontDescription *bat2_font_desc;
|
2009-10-28 23:01:32 +00:00
|
|
|
extern int battery_enabled;
|
2015-08-05 00:15:06 +00:00
|
|
|
extern int battery_tooltip_enabled;
|
2010-01-19 19:29:28 +00:00
|
|
|
extern int percentage_hide;
|
2009-05-15 20:48:55 +00:00
|
|
|
|
|
|
|
extern int8_t battery_low_status;
|
2009-05-31 12:40:40 +00:00
|
|
|
extern char *battery_low_cmd;
|
|
|
|
|
2015-07-13 03:16:02 +00:00
|
|
|
extern char *battery_lclick_command;
|
|
|
|
extern char *battery_mclick_command;
|
|
|
|
extern char *battery_rclick_command;
|
|
|
|
extern char *battery_uwheel_command;
|
|
|
|
extern char *battery_dwheel_command;
|
|
|
|
|
2015-08-05 00:15:06 +00:00
|
|
|
static inline gchar* chargestate2str(enum chargestate state) {
|
|
|
|
switch(state) {
|
|
|
|
case BATTERY_CHARGING:
|
|
|
|
return "Charging";
|
|
|
|
case BATTERY_DISCHARGING:
|
|
|
|
return "Discharging";
|
|
|
|
case BATTERY_FULL:
|
|
|
|
return "Full";
|
|
|
|
case BATTERY_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-04-18 14:28:45 +00:00
|
|
|
// default global data
|
2010-04-18 12:07:36 +00:00
|
|
|
void default_battery();
|
2010-04-18 14:28:45 +00:00
|
|
|
|
2010-04-18 12:07:36 +00:00
|
|
|
// freed memory
|
|
|
|
void cleanup_battery();
|
2009-05-15 20:48:55 +00:00
|
|
|
|
2015-03-28 18:08:44 +00:00
|
|
|
int update_battery();
|
2009-05-15 20:48:55 +00:00
|
|
|
|
|
|
|
void init_battery();
|
2009-10-18 17:54:09 +00:00
|
|
|
void init_battery_panel(void *panel);
|
2010-04-16 18:50:03 +00:00
|
|
|
|
2010-01-09 00:11:01 +00:00
|
|
|
void draw_battery(void *obj, cairo_t *c);
|
2009-05-15 20:48:55 +00:00
|
|
|
|
2010-09-16 23:24:25 +00:00
|
|
|
int resize_battery(void *obj);
|
2009-05-15 20:48:55 +00:00
|
|
|
|
2015-07-13 03:16:02 +00:00
|
|
|
void battery_action(int button);
|
|
|
|
|
2015-08-04 22:17:32 +00:00
|
|
|
#ifdef __linux
|
|
|
|
gboolean init_linux_batteries();
|
|
|
|
void free_linux_batteries();
|
|
|
|
void update_linux_batteries(enum chargestate *state, gint64 *energy_now, gint64 *energy_full, int *seconds);
|
2015-08-05 00:15:06 +00:00
|
|
|
const char* linux_batteries_get_tooltip();
|
2015-08-04 22:17:32 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-15 20:48:55 +00:00
|
|
|
#endif
|