Adding support for ASUS Z71v laptop batteries to xfce4-battery
Alan Hicks <[email protected]>
| Newsgroups | gmane.comp.desktop.xfce.goodies.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I just joined his mailing list in hopes that you can help me solve a
problem I'm having with the xfce-battery-plugin. I have an ASUS Z71v
which has two batteries in it. Status for neither battery is reported
by the applet and seems to default to saying the battery is dead, but
on AC charge.
I have attempted to compile the software with --enable-debug=3D"yes|full"
and in either case it fails to compile, stating that some variables are
defined but not used. I am unsure if that error message is important
or not, but as the software compiles successfully without that message,
I have elected not to include it.
The information regarding battery state can be found in the files:
/proc/acpi/battery/BAT0/state
/proc/acpi/battery/BAT1/state
IIUC, the norm is for this information to be stored in the files:
/proc/acpi/battery/[0-9]/state
/proc/acpi/battery/[0-9]/status
I can only assume that the "BAT" prefix is causing the plugin to fail
to find the state file from what I've gathered from the code I've
looked over.
I have absolutely no real programming skill (some bash scripting,
trying to teach myself some C) and would like to add support for my
batteries to this applet. From what I've gathered with my meager
code-reading skills, the following lines in libacpi.c try to get an
integer count of the batteries under /proc/acpi/battery and then use
that integer value to locate the state file.
<snip>
1 /* now enumerate batteries */
2 batt_count =3D 0;
3 battdir =3D opendir ("/proc/acpi/battery");
4 if (battdir =3D=3D 0)
5 {
6 #ifdef DEBUG
7 printf("DBG:No battery. /proc/acpi/battery not found!\n");
8 #endif
9 return 2;
10 }
11 while ((batt =3D readdir (battdir)))
12 {
13 name =3D batt->d_name;
14=20
15 /* skip . and .. */
16 if (!strncmp (".", name, 1) || !strncmp ("..", name, 2)) continue;
17 =20
18 sprintf (batteries[batt_count], "/proc/acpi/battery/%s/state", name);
19 if (!(acpi =3D fopen (batteries[batt_count], "r"))) {
20 sprintf (batteries[batt_count], "/proc/acpi/battery/%s/status", n=
ame);
21 }
22 else fclose (acpi);
23 =20
24 #if 0 =20
25 if (!(acpi =3D fopen ("/proc/acpi/battery/1/status", "r")))
26 sprintf (batteries[batt_count], "/proc/acpi/battery/%s/state", name=
);
27 else
28 sprintf (batteries[batt_count], "/proc/acpi/battery/%s/status", nam=
e);
29 #endif =20
</snip>
Thanks for your time and attention. I'd really like to help to get
this working, both to have proper battery monitoring in everyone's
favorite cholestorel free DE, and to maybe learn a thing or two about
C. I regret that I am not able to write a patch myself for submission.
--
It is better to hear the rebuke of the wise,
Than for a man to hear the song of fools.
Ecclesiastes 7:5
signature.asc
(application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFDp564z8zcalmVmBkRArWEAJ90gU1ybF0K+nDFwTIjpLAT9S8CqACff/5v Az/k8+A2u4IDPBOljRv7gDc= =qutw -----END PGP SIGNATURE-----