From: <bre...@us...> - 2006-03-26 01:48:00
|
Revision: 613 Author: brenden1 Date: 2006-03-25 17:47:55 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/conky/?rev=613&view=rev Log Message: ----------- freebsd battery patch Modified Paths: -------------- trunk/conky1/AUTHORS trunk/conky1/ChangeLog trunk/conky1/src/freebsd.c Modified: trunk/conky1/AUTHORS =================================================================== --- trunk/conky1/AUTHORS 2006-03-25 21:21:07 UTC (rev 612) +++ trunk/conky1/AUTHORS 2006-03-26 01:47:55 UTC (rev 613) @@ -128,6 +128,7 @@ Petr Holub <ho...@us...> 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 Modified: trunk/conky1/ChangeLog =================================================================== --- trunk/conky1/ChangeLog 2006-03-25 21:21:07 UTC (rev 612) +++ trunk/conky1/ChangeLog 2006-03-26 01:47:55 UTC (rev 613) @@ -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 Modified: trunk/conky1/src/freebsd.c =================================================================== --- trunk/conky1/src/freebsd.c 2006-03-25 21:21:07 UTC (rev 612) +++ trunk/conky1/src/freebsd.c 2006-03-26 01:47:55 UTC (rev 613) @@ -347,17 +347,41 @@ 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 (battime != -1) - snprintf(buf, n, "Discharging, remaining %d:%2.2d", - battime / 60, battime % 60); - else - snprintf(buf, n, "Battery is charging"); + 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, "remaining %d%% (%d:%2.2d)", + batcapacity, battime / 60, battime % 60); + else + /* 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |