bapm is an APM meter for Blackbox, which shows the battery status of your laptop in a decorated window, simulating the look of the Blackbox toolbar. bbapm is based on bbsload. This package is based on the FreeBSD port and the OpenBSD patches posted to http://bbtools.windsofstorm.net written by Michael Henson (mike at axl dot net). Various changes by yours truly.
119 lines
3.4 KiB
Text
119 lines
3.4 KiB
Text
$NetBSD: patch-af,v 1.1.1.1 2002/09/07 20:22:53 jschauma Exp $
|
|
|
|
--- bbapm.cc.orig Sat Sep 7 13:50:55 2002
|
|
+++ bbapm.cc Sat Sep 7 14:04:14 2002
|
|
@@ -28,6 +28,9 @@
|
|
ToolWindow::ToolWindow(int argc, char **argv):
|
|
Basewindow(argc, argv)
|
|
{
|
|
+ resource = NULL;
|
|
+ load = NULL;
|
|
+
|
|
close_app = False;
|
|
broken = False;
|
|
|
|
@@ -308,13 +311,14 @@
|
|
|
|
if (!broken) {
|
|
|
|
+#if !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__))
|
|
if (apm_exists() < 0)
|
|
broken = True;
|
|
- else {
|
|
+ else
|
|
+#endif
|
|
if ((apm_read(&apm))<0)
|
|
broken = True;
|
|
}
|
|
- }
|
|
|
|
if (redraw)
|
|
Redraw();
|
|
@@ -336,7 +340,11 @@
|
|
// loadbar to show that the battery is loading. A bit like GSM. But
|
|
// in this case the label will show how far the loading is done.
|
|
if ((resource->show.loading) &&
|
|
+#if !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__))
|
|
(apm.ac_line_status==1) &&
|
|
+#else
|
|
+ (apm.ac_state==1) &&
|
|
+#endif
|
|
(resource->show.percentage)) {
|
|
for (i=0; i < resource->loadbar.number_of_bars; i++) {
|
|
if (noLoadBarFilled>=i) {
|
|
@@ -357,11 +365,23 @@
|
|
if (resource->show.percentage) {
|
|
#ifdef DEBUG
|
|
cerr << "Toolwindow::Redraw: drawing percentage " <<
|
|
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
+ apm.battery_life << " " <<
|
|
+#elif defined(__FreeBSD__)
|
|
+ apm.ai_batt_life << " " <<
|
|
+#else
|
|
apm.battery_percentage << " " <<
|
|
+#endif
|
|
resource->loadbar.number_of_bars << endl;
|
|
#endif
|
|
for (i = 0; i < resource->loadbar.number_of_bars; i++) {
|
|
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
+ if (apm.battery_life >= load[i].level)
|
|
+#elif defined(__FreeBSD__)
|
|
+ if (apm.ai_batt_life >= load[i].level)
|
|
+#else
|
|
if (apm.battery_percentage >= load[i].level)
|
|
+#endif
|
|
XCopyArea(dpy, pixmap.loadbar_active, framewin, frameGC,
|
|
2, load[i].y - 1,
|
|
load[i].width, load[i].height, load[i].x,
|
|
@@ -389,7 +409,13 @@
|
|
XSetForeground(dpy, frameGC,
|
|
resource->label.percentage_textColor.pixel);
|
|
|
|
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
+ sprintf(t, "%03d%%", apm.battery_life);
|
|
+#elif defined(__FreeBSD__)
|
|
+ sprintf(t, "%03d%%", apm.ai_batt_life);
|
|
+#else
|
|
sprintf(t, "%03d%%", apm.battery_percentage);
|
|
+#endif
|
|
XDrawString(dpy, labelwin, frameGC, label.space_width,
|
|
(label.height + resource->label.font->ascent -
|
|
resource->label.font->descent) / 2,
|
|
@@ -413,7 +439,13 @@
|
|
XSetForeground(dpy, frameGC,
|
|
resource->label.time_textColor.pixel);
|
|
|
|
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
+ sprintf(t, "%02d:%02d", apm.minutes_left/60, apm.minutes_left%60);
|
|
+#elif defined(__FreeBSD__)
|
|
+ sprintf(t, "%02d:%02d", apm.ai_batt_time/60, apm.ai_batt_time%60);
|
|
+#else
|
|
sprintf(t, "%02d:%02d", apm.battery_time/60, apm.battery_time%60);
|
|
+#endif
|
|
XDrawString(dpy, labelwin, frameGC, xposition,
|
|
(label.height + resource->label.font->ascent -
|
|
resource->label.font->descent) / 2, t, strlen(t));
|
|
@@ -519,7 +551,11 @@
|
|
}
|
|
}
|
|
|
|
+#if !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__))
|
|
if (apm.ac_line_status==1) {
|
|
+#else
|
|
+ if (apm.ac_state==1) {
|
|
+#endif
|
|
if (time(NULL) - lastLoadingTime > resource->show.loadingTime) {
|
|
ReadAPM();
|
|
lastLoadingTime = time(NULL);
|
|
@@ -565,6 +601,11 @@
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
+#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
+ apm_init();
|
|
+#elif defined(__FreeBSD__)
|
|
+ apm_exists();
|
|
+#endif
|
|
ToolWindow *
|
|
AppWindow = new ToolWindow(argc, argv);
|
|
|