add a battery meter epplet :) - okj someoen else did already but min looks
sexy and i wrote it on the plane flight back from ALS :) SVN revision: 835
|
@ -14,6 +14,6 @@ brighter the flame. when your focus is ont he epplet it will display close,
|
|||
help and configure butotns - click the configure button (the tool) to bring
|
||||
up a button that will select one of several color schemes for the flame.
|
||||
<p>
|
||||
If you have multpile CPU's the flame will flare in sections at the bottom
|
||||
If you have multiple CPU's the flame will flare in sections at the bottom
|
||||
depending on which CPU is active - so if you have a dual CPU machine the left
|
||||
half is for the first CPU, the right is for the 2nd and so on.
|
||||
|
|
After Width: | Height: | Size: 618 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,17 @@
|
|||
<page columns=1 padding=16 name=front background=bg.png linkcolor=#88dddd>
|
||||
<font face=aircut3/32 color=#ffffff>
|
||||
<p align=50%>
|
||||
E-Power
|
||||
<font face=aircut3/18 color=#88eeff>
|
||||
<p align=50%>
|
||||
A Laptop Battery Status Display Epplet
|
||||
<font face=aircut3/12 color=#ffffff>
|
||||
<p align=50%>
|
||||
By The Rasterman - 1999
|
||||
<p>
|
||||
This epplet shows your batery's current status for your laptop, including
|
||||
a numeric percentage of the batery left and a time estimae as to how many
|
||||
hours & minutes of battery tme are left.
|
||||
<p>
|
||||
If you are recharging you will get an estimated recharge time too in brackets
|
||||
after the battery percentage value.
|
After Width: | Height: | Size: 130 KiB |
|
@ -0,0 +1,123 @@
|
|||
#include "epplet.h"
|
||||
|
||||
int prev_bat_val = 110;
|
||||
int bat_val = 0;
|
||||
int time_val = 0;
|
||||
int prev_up[16] =
|
||||
{0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int prev_count = 0;
|
||||
Epplet_gadget b_close, b_help, image, label;
|
||||
|
||||
static void cb_timer(void *data);
|
||||
static void cb_close(void *data);
|
||||
static void cb_in(void *data, Window w);
|
||||
static void cb_out(void *data, Window w);
|
||||
static void cb_help(void *data);
|
||||
|
||||
static void
|
||||
cb_timer(void *data)
|
||||
{
|
||||
static FILE *f;
|
||||
|
||||
f = fopen("/proc/apm", "r");
|
||||
if (f)
|
||||
{
|
||||
char s[256], s1[32], s2[32], s3[32];
|
||||
int i, hours, minutes, up, up2;
|
||||
|
||||
fgets(s, 255, f);
|
||||
sscanf(s, "%*s %*s %*s %*s %*s %*s %s %s %s", s1, s2, s3);
|
||||
s1[strlen(s1) - 1] = 0;
|
||||
bat_val=atoi(s1);
|
||||
if (!strcmp(s3, "sec"))
|
||||
time_val = atoi(s2);
|
||||
else if (!strcmp(s3, "min"))
|
||||
time_val = atoi(s2) * 60;
|
||||
fclose(f);
|
||||
|
||||
up = bat_val - prev_bat_val;
|
||||
up2 = up;
|
||||
for (i = 0; i < 16; i++)
|
||||
up2 = + prev_up[i];
|
||||
up2 = (up2 * 60) / 17;
|
||||
|
||||
prev_up[prev_count] = up;
|
||||
|
||||
prev_count++;
|
||||
if (prev_count >= 16)
|
||||
prev_count = 0;
|
||||
|
||||
hours = time_val / 3600;
|
||||
minutes = (time_val / 60) % 60;
|
||||
if (up2 > 0)
|
||||
sprintf(s, "%i%% (%i:%02i)\n%i:%02i", bat_val,
|
||||
(((100 - bat_val) * 2 * 60) / up2) / 60,
|
||||
(((100 - bat_val) * 2 * 60) / up2) % 60,
|
||||
hours, minutes);
|
||||
else
|
||||
sprintf(s, "%i%%\n%i:%02i", bat_val, hours, minutes);
|
||||
Epplet_change_label(label, s);
|
||||
sprintf(s, EROOT"/epplet_icons/E-Power-Bat-%i.png",
|
||||
((bat_val + 5) / 10) * 10);
|
||||
Epplet_change_image(image, 44, 24, s);
|
||||
Epplet_timer(cb_timer, NULL, 30.0, "TIMER");
|
||||
prev_bat_val = bat_val;
|
||||
}
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
cb_close(void *data)
|
||||
{
|
||||
Epplet_unremember();
|
||||
Esync();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
cb_in(void *data, Window w)
|
||||
{
|
||||
Epplet_gadget_show(b_close);
|
||||
Epplet_gadget_show(b_help);
|
||||
}
|
||||
|
||||
static void
|
||||
cb_out(void *data, Window w)
|
||||
{
|
||||
Epplet_gadget_hide(b_close);
|
||||
Epplet_gadget_hide(b_help);
|
||||
}
|
||||
|
||||
static void
|
||||
cb_help(void *data)
|
||||
{
|
||||
Epplet_show_about("E-Power");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Epplet_Init("E-Power", "0.1", "Enlightenment Laptop Power Epplet",
|
||||
3, 3, argc, argv, 0);
|
||||
Epplet_timer(cb_timer, NULL, 30.0, "TIMER");
|
||||
b_close = Epplet_create_button(NULL, NULL,
|
||||
2, 2, 0, 0, "CLOSE", 0, NULL,
|
||||
cb_close, NULL);
|
||||
b_help = Epplet_create_button(NULL, NULL,
|
||||
34, 2, 0, 0, "HELP", 0, NULL,
|
||||
cb_help, NULL);
|
||||
Epplet_gadget_show(image =
|
||||
Epplet_create_image
|
||||
(2, 2, 44, 24,
|
||||
EROOT"/epplet_icons/E-Power-Bat-100.png"));
|
||||
Epplet_gadget_show(label =
|
||||
Epplet_create_label
|
||||
(2, 28, "99%\n8:88", 1));
|
||||
Epplet_register_focus_in_handler(cb_in, NULL);
|
||||
Epplet_register_focus_out_handler(cb_out, NULL);
|
||||
cb_timer(NULL);
|
||||
Epplet_show();
|
||||
Epplet_Loop();
|
||||
return 0;
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
bindir = $(EBIN)
|
||||
|
||||
bin_PROGRAMS = E-Load.epplet E-Clock.epplet E-Time.epplet E-Net.epplet E-Cpu.epplet EppletTest.epplet E-Biff.epplet
|
||||
bin_PROGRAMS = E-Load.epplet E-Clock.epplet E-Time.epplet E-Net.epplet E-Cpu.epplet EppletTest.epplet E-Biff.epplet E-Power.epplet
|
||||
|
||||
E_Load_epplet_SOURCES = E-Load.c
|
||||
E_Load_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la
|
||||
|
@ -24,6 +24,10 @@ E_Cpu_epplet_SOURCES = E-Cpu.c
|
|||
E_Cpu_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la
|
||||
E_Cpu_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
||||
|
||||
E_Power_epplet_SOURCES = E-Power.c
|
||||
E_Power_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la
|
||||
E_Power_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
||||
|
||||
EppletTest_epplet_SOURCES = TestEpplet.c
|
||||
EppletTest_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la
|
||||
EppletTest_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
||||
|
@ -35,14 +39,21 @@ E_Biff_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
|||
INCLUDES = -I. -I$(top_srcdir)/api -I$(top_srcdir) -I.. -I$(includedir) -I$(prefix)/include $(X_CFLAGS)
|
||||
LDADD = $(top_builddir)/api/libepplet.la -L$(libdir) -L$(prefix)/lib $(LIBS) $(X_LIBS)
|
||||
|
||||
ABOUT_DOCS = E-Cpu.ABOUT/MAIN E-Cpu.ABOUT/bg.png E-Cpu.ABOUT/aircut3.ttf \
|
||||
E-Clock.ABOUT/MAIN E-Clock.ABOUT/bg.png E-Clock.ABOUT/aircut3.ttf
|
||||
ICONS = E-Load.icon E-Clock.icon E-Net.icon E-Cpu.icon E-Biff.icon
|
||||
IMAGES = E-Clock-Image.png nomail.png newmail.png
|
||||
ABOUT_DOCS = \
|
||||
E-Cpu.ABOUT/MAIN E-Cpu.ABOUT/bg.png E-Cpu.ABOUT/aircut3.ttf \
|
||||
E-Clock.ABOUT/MAIN E-Clock.ABOUT/bg.png E-Clock.ABOUT/aircut3.ttf \
|
||||
E-Power.ABOUT/MAIN E-Power.ABOUT/bg.png E-Power.ABOUT/aircut3.ttf
|
||||
|
||||
EXTRA_DIST = ${ICONS} ${ABOUT_DOCS} ${IMAGES}
|
||||
ICONS = \
|
||||
E-Load.icon E-Clock.icon E-Net.icon E-Cpu.icon E-Power.icon E-Biff.icon
|
||||
|
||||
DATA =\
|
||||
E-Clock-Image.png E-Power-Bat-0.png E-Power-Bat-10.png E-Power-Bat-20.png \
|
||||
E-Power-Bat-30.png E-Power-Bat-40.png E-Power-Bat-50.png E-Power-Bat-60.png \
|
||||
E-Power-Bat-70.png E-Power-Bat-80.png E-Power-Bat-90.png E-Power-Bat-100.png \
|
||||
nomail.png newmail.png
|
||||
|
||||
EXTRA_DIST = ${ICONS} ${ABOUT_DOCS} ${DATA}
|
||||
|
||||
install-data-hook:
|
||||
$(mkinstalldirs) $(EROOT)/epplet_icons
|
||||
|
|