1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 20:11:11 +00:00

freebsd battery patch

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@613 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2006-03-26 01:47:55 +00:00
parent e8c9f49594
commit c4bf55b542
3 changed files with 32 additions and 6 deletions

View File

@ -128,6 +128,7 @@ Pascal Eberhard <pascal dor eberhard at gmail dot com>
Petr Holub <hopet@users.sourceforge.net>
fix autotools on FreeBSD in autogen.sh
Improved battery readout on FreeBSD
Philip Kovacs <pkovacs at users dot sourceforge dot net>
tcp port monitor with hashing functionality

View File

@ -2,6 +2,7 @@
2006-03-25
* Added XMMS2 patch 1456203 from Lassi Selander
* Added FreeBSD battery patch 1456008 from Petr Holub
2006-03-21
* Fixed ${top(_mem)} related code on FreeBSD (with help of Petr

View File

@ -347,17 +347,41 @@ get_acpi_temperature(int fd)
void
get_battery_stuff(char *buf, unsigned int n, const char *bat)
{
int battime;
int battime, batcapacity, batstate, ac;
if (GETSYSCTL("hw.acpi.battery.time", battime))
(void) fprintf(stderr,
"Cannot read sysctl \"hw.acpi.battery.time\"\n");
if (GETSYSCTL("hw.acpi.battery.life", batcapacity))
(void) fprintf(stderr,
"Cannot read sysctl \"hw.acpi.battery.life\"\n");
if (GETSYSCTL("hw.acpi.battery.state", batstate))
(void) fprintf(stderr,
"Cannot read sysctl \"hw.acpi.battery.state\"\n");
if (GETSYSCTL("hw.acpi.acline", ac))
(void) fprintf(stderr,
"Cannot read sysctl \"hw.acpi.acline\"\n");
if (batstate == 1) {
if (battime != -1)
snprintf(buf, n, "Discharging, remaining %d:%2.2d",
battime / 60, battime % 60);
snprintf(buf, n, "remaining %d%% (%d:%2.2d)",
batcapacity, battime / 60, battime % 60);
else
snprintf(buf, n, "Battery is charging");
/* no time estimate available yet */
snprintf(buf, n, "remaining %d%%",
batcapacity);
if (ac == 1)
(void) fprintf(stderr, "Discharging while on AC!\n");
} else {
snprintf(buf, n, batstate == 2 ? "charging (%d%%)" : "charged (%d%%)", batcapacity);
if (batstate != 2 && batstate != 0)
(void) fprintf(stderr, "Unknow battery state %d!\n", batstate);
if (ac == 0)
(void) fprintf(stderr, "Charging while not on AC!\n");
}
}
int