Chidambar 'ilLogict' Zinnoury wrote:
Hello!
Dans son message intitulé « Re: [E-devel] Battery module patch. »
du Wed, 03 Sep 2008 08:58:23 +0300, Bauland Stephane
<[EMAIL PROTECTED]> nous a donné l'occasion de lire :
Nick Hughart wrote:
Stéphane BAULAND wrote:
Hi,
This patch is just a simple patch. I had problem using the battery
module, it wasn't working for me. I was bored and i look to
sources of badget... The problem comes from the name of the device.
For me the battery path is : /sys/class/power_supply/C1FD/ and the
module was looking to a name that begin by "bat" i just removed
this check.
You can't just remove this check. The reason this check exists is
because there can be AC data in the power_supply directory as
well. We'll have to come up with a better way to determine if the
supply is a battery or not.
Ok, i will patch it back this evening. I found the way :
$ cat /sys/class/power_supply/C1FD/type
Battery
$ cat /sys/class/power_supply/C1FB/type
Mains
I will add a check to find entry with a battery type.
I'm currently working on it, + support for new battery detection. Hope
to send a patch soon.
Cheers!
Chidambar
I finish this patch to check battery type.
See you
--
Bauland 'rookmoot' Stephane | Epitech lille
Assistant Epitech Roux | [EMAIL PROTECTED]
~ "eh tizot, ti quere el'pitech ? hein ?" - "bah ouai t'inquiete !" ~
Index: batget.c
===================================================================
--- batget.c (revision 35795)
+++ batget.c (working copy)
@@ -603,6 +603,24 @@
}
}
+static int
+linux_sys_class_power_supply_is_battery(char *name)
+{
+ int fd;
+ char buf[255];
+ char tmp[255];
+
+ memset(tmp, 0, 255);
+ snprintf(buf, 255, "/sys/class/power_supply/%s/type", name);
+ if (!(fd = open(buf, O_RDONLY)))
+ return 0;
+ if (read(fd, tmp, 255) < 1)
+ return 0;
+ if (!strncmp(tmp, "Battery", 7))
+ return 1;
+ return 0;
+}
+
static void
linux_sys_class_power_supply_init(void)
{
@@ -627,8 +645,9 @@
while ((name = ecore_list_next(bats)))
{
Sys_Class_Power_Supply_Uevent *sysev;
-
- if (strncasecmp("bat", name, 3)) continue;
+
+ if (!(linux_sys_class_power_supply_is_battery(name)))
+ continue;
sysev = E_NEW(Sys_Class_Power_Supply_Uevent, 1);
sysev->name = strdup(name);
snprintf(buf, sizeof(buf), "/sys/class/power_supply/%s/uevent", name);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel