move battery fetching/polling of info to its own sub process, pipe of stdout

to read like tempget. this means e cant hang hen polling - much better for
the mainloop. also clean up the code a lot. all battery specific "driver"
code is now in batget - this means it much nicer to later add hal battery
info fetching as that is also a remote service (and just not execute batget).
i also fixed up (in theory) the new 2.6.24+ /sys/class/power_supply parsing
to i think work better in more situations. i'm testing on a device i have
that does it - let me know if its wrong...


SVN revision: 33903
This commit is contained in:
Carsten Haitzler 2008-03-03 09:48:37 +00:00
parent b5260fd925
commit 16b851a43c
4 changed files with 1607 additions and 1515 deletions

View File

@ -26,5 +26,18 @@ module_la_LIBADD = @e_libs@ @cf_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
batgetdir = $(pkgdir)
batget_DATA = \
batget$(EXEEXT)
x_mode = a=rx,u+x
install-data-hook:
@chmod $(x_mode) $(DESTDIR)$(batgetdir)/batget$(EXEEXT) || true
noinst_PROGRAMS = batget
batget_SOURCES = batget.c
batget_LDFLAGS = @BATTERY_LIBS@
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

1433
src/modules/battery/batget.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -25,40 +25,13 @@ struct _Config
Evas_List *instances;
E_Menu *menu;
int alarm_triggered;
int battery_check_mode;
Ecore_Poller *battery_check_poller;
int battery_prev_drain;
int battery_prev_ac;
int battery_prev_battery;
int battery_prev_level;
};
#ifdef __FreeBSD__
#define BATTERY_STATE_NONE 0
#define BATTERY_STATE_DISCHARGING 1
#define BATTERY_STATE_CHARGING 2
#define BATTERY_STATE_REMOVED 7
#else
#define BATTERY_STATE_NONE 0
#define BATTERY_STATE_CHARGING 1
#define BATTERY_STATE_DISCHARGING 2
#endif
struct _Status
{
/* Low battery */
unsigned char alarm;
/* Is there a battery? */
unsigned char has_battery;
/* charging, discharging, none */
unsigned char state;
/* Battery level */
double level;
/* Text */
/* reading == % left */
char *reading;
/* time == time left to empty / full */
char *time;
Ecore_Exe *batget_exe;
Ecore_Event_Handler *batget_data_handler;
Ecore_Event_Handler *batget_del_handler;
int full;
int time_left;
int have_battery;
int have_power;
};
EAPI extern E_Module_Api e_modapi;