[Pkg-wmaker-commits] [wmbatppc] 02/35: Imported Upstream version 2.5
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Sat Aug 22 02:23:47 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbatppc.
commit e6041a8c8a81a8e48767d5db29c5abfcf5ddf94e
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Wed Dec 31 07:25:52 2014 -0600
Imported Upstream version 2.5
---
Makefile | 32 +-
README | 5 +
wmbatppc.1 | 73 ++-
wmbatppc.c | 1524 +++++++++++++++++++++++++++++++++++++++++-------------------
wmbatppc.h | 232 +++++----
5 files changed, 1277 insertions(+), 589 deletions(-)
diff --git a/Makefile b/Makefile
index c84eeac..6644932 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,24 @@
-#
+DESTDIR=
+
+PREFIX= $(DESTDIR)/usr
+CC = /usr/bin/gcc
+INSTALL = /usr/bin/install
LIBDIR = -L/usr/X11R6/lib
-LIBS = -lXpm -lXext -lX11 -lm
-FLAGS = -O6
-OBJS = \
- wmgeneral.o \
+LIBS = -lXpm -lXext -lX11 -lm $(shell /usr/bin/xosd-config --libs)
+FLAGS = -O2 -DENABLE_XOSD $(shell /usr/bin/xosd-config --cflags)
+OBJS = wmgeneral.o
default:all
.c.o:
- cc -I/usr/X11R6/share/include $(FLAGS) -c -Wall $< -o $*.o
+ $(CC) -I/usr/X11R6/share/include $(FLAGS) -c -Wall $< -o $*.o
wmbatppc.o: wmbatppc.c wmbatppc-master.xpm
- cc -I/usr/X11R6/share/include $(FLAGS) -c -Wall wmbatppc.c -o $*.o
+ $(CC) -I/usr/X11R6/share/include $(FLAGS) -c -Wall wmbatppc.c -o $*.o
wmbatppc: $(OBJS) wmbatppc.o
- cc $(FLAGS) -o wmbatppc $(OBJS) -lXext $(LIBDIR) $(LIBS) wmbatppc.o
+ $(CC) $(FLAGS) -o wmbatppc $(OBJS) -lXext $(LIBDIR) $(LIBS) wmbatppc.o
all:: wmbatppc
@@ -25,11 +28,10 @@ clean::
rm -f *~
install:: wmbatppc
- strip wmbatppc
- cp -f wmbatppc /usr/local/bin/
- chmod 755 /usr/local/bin/wmbatppc
- chown root:root /usr/local/bin/wmbatppc
- cp -f wmbatppc.1 /usr/local/man/man1
- chmod 644 /usr/local/man/man1/wmbatppc.1
- chown root:root /usr/local/man/man1/wmbatppc.1
+ $(INSTALL) -d $(PREFIX)/bin
+ $(INSTALL) -s -m 755 wmbatppc $(PREFIX)/bin
+ ln -s $(PREFIX)/bin/wmbatppc $(PREFIX)/bin/batppc
+ $(INSTALL) -d $(PREFIX)/share/man/man1
+ $(INSTALL) -m 644 wmbatppc.1 $(PREFIX)/share/man/man1
+ ln -s $(PREFIX)/share/man/man1/wmbatppc.1 $(PREFIX)/share/man/man1/batppc.1
@echo "wmbatppc Installation finished..."
diff --git a/README b/README
index 33b822c..cf07e1b 100644
--- a/README
+++ b/README
@@ -4,6 +4,11 @@ Homepage: http://titelou.free.fr/wmbatppc
Installation:
=============
+If you want On-Screen Display when using wmbatppc, you'll need a working
+installation of xosd (>= 2.0.1). If you do not want to use OSD, edit the
+Makefile and comment out the -DENABLE_OSD in the CFLAGS variable.
+
+
Unzip the source tarball:
tar xvfz wmbatppc-1.0.tgz
diff --git a/wmbatppc.1 b/wmbatppc.1
index fe8f8ce..9b0cec2 100644
--- a/wmbatppc.1
+++ b/wmbatppc.1
@@ -1,16 +1,35 @@
.\" Man Page for WMBATPPC
.\" groff -man -Tascii wmbatppc.1
.\"
-.TH WMBATPPC 1 "NOVEMBER 2000" Linux "User Manuals"
+.TH WMBATPPC 1 "February 2004" Linux "User Manuals"
.SH NAME
-wmbatppc
+wmbatppc, batppc \- Battery monitor for Apple laptops using PMU
.SH SYNOPSIS
.B wmbatppc
-[\-c command]
.SH DESCRIPTION
.B wmbatppc
displays, as a WindowMaker dockapp, power management information
on new PowerBooks (aka Pismo) and iBook.
+
+.B batppc
+prints power management information on the console.
+
+Both
+.B wmbatppc
+and
+.B batppc
+retrieve the power management information either from
+.I pmud
+(using a TCP/IP connection on the localhost or a UNIX domain socket)
+or from
+.I /proc/pmu.
+
+By default, both
+.B wmbatppc
+and
+.B batppc
+will use
+.I /proc/pmu.
.SH OPTIONS
.TP
@@ -19,13 +38,57 @@ Sets the update interval (in milliseconds), default: 100
.TP
.I \-display display
This option specifies the X server to contact; see X(1).
+.TP
+.I \-w
+This option enables the WindowMaker/AfterStep GUI (64*64 pixmap)
+.TP
+.I \-o
+This option disables the On-Screen Display (only available if wmbatppc
+was built with XOSD support).
+.TP
+.I \-x
+This option enables the swallowed application GUI (24*176 pixmap)
+intended for use with the GNOME Panel.
+.TP
+.I \-t
+This option indicates wmbatppc to connect to pmud via the TCP port
+879 on localhost.
+.TP
+.I \-u [PATH]
+This option indicates wmbatppc to connect to pmud via a UNIX domain
+socket. The optional
+.I PATH
+argument can be used to specify the path to the UNIX domain socket
+to use.
+
+.SH OUTPUT
+.B batppc
+outputs a line similar to the following :
+.TP
+PC 100% 80% 01:20
+.br
+P = AC plugged in (\- when not plugged)
+.br
+C = charging (\- when not charging)
+.br
+100% = left battery state (\-\-% when no battery)
+.br
+80% = right battery state
+.br
+01:20 = time left
+Percentages for each battery are coloured in green, yellow or red depending
+on the battery state.
.SH BUGS
Please report any bugs you may find to:
.TP
-.B titelou at free.fr
+.B jb at jblache.org
+
.SH AUTHOR
-Lou <titelou at free.fr>
+.B wmbatppc
+was originally written by Lou <titelou at free.fr>; it is now maintained
+by Julien BLACHE <jb at jblache.org>.
+
.SH Homepage
http://titelou.free.fr/
diff --git a/wmbatppc.c b/wmbatppc.c
index c2bdcc1..68af451 100644
--- a/wmbatppc.c
+++ b/wmbatppc.c
@@ -1,428 +1,856 @@
/*
- * code file for wmbatppc
- * by Lou
+ * $Id: wmbatppc.c 32 2004-10-13 17:43:38Z julien $
+ *
+ * wmbatppc, originally written by Lou <titelou at free.fr>
+ *
+ * ChangeLog :
+ *
+ * * 20021016 v1.2 Julien BLACHE <jb at jblache.org>
+ * + do not segfault when the pmud stops or crashes
+ * + added unix socket support
+ * + added /proc/pmu support
+ * * 20021105 v1.3 Julien BLACHE <jb at jblache.org>
+ * + added xosd support
+ * * 20021127 v2.0 Julien BLACHE <jb at jblache.org>
+ * + added tty output support
+ * * 20030122 v2.1 Julien BLACHE <jb at jblache.org>
+ * + display OSD in case curtime - last_osd < 0
+ * * 20030410 v2.2 Julien BLACHE <jb at jblache.org>
+ * + /proc/pmu parsing rewritten
+ * * 20030723 v2.3 Julien BLACHE <jb at jblache.org>
+ * + /proc/pmu/battery_X has changed the meaning of its flags: member,
+ * now the second byte indicates the battery type.
+ * + when parsing /proc, we get the time in seconds, we want minutes !
+ * + removed SIGINT/SIGTERM handler. (caused wmbatppc to hang when receiving
+ * these signals and built with xosd ; works fine without the handlers too)
+ * * 20040211 v2.4 Julien BLACHE <jb at jblache.org>
+ * + patch from Sebastian Henschel to fix a segfault when using OSD and a
+ * locale not supported by XLib (can't find an appropriate font).
+ * + you can now specify the path to the UNIX domain socket with the -u switch.
+ * + some code cleanup at last, eliminating most of the global variables.
+ * + changed the way OSD display works.
+ * * 20041013 v2.5 Julien BLACHE <jb at jblache.org>
+ * + fixed compilation without ENABLE_XOSD
+ * + added runtime switch to disable OSD
*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <dirent.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <math.h>
+#include <limits.h>
+#include <errno.h>
+#include <signal.h>
-#include "wmbatppc.h"
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/socket.h>
-#include "wmgeneral.h"
+#include <netinet/in.h> /* INET sockets */
+#include <sys/un.h> /* UNIX domain sockets */
+#include <netdb.h>
-#include "wmbatppc-master.xpm"
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+
+#ifdef ENABLE_XOSD
+# include <xosd.h>
+#endif /* ENABLE_XOSD */
+
+#include "wmbatppc.h"
+#include "wmgeneral.h"
+#include "wmbatppc-master.xpm"
#include "xgbatppc-master.xpm"
-pmud_info sys_pmu ;
-
-unsigned int wm = WMAKER ;
-
-char wmbatppc_mask_bits[64*64];
-char xgbatppc_mask_bits[24*176];
-int wmbatppc_mask_width = 64;
-int xgbatppc_mask_width= 176;
-int wmbatppc_mask_height = 64;
-int xgbatppc_mask_height = 24;
-
-coords jukeBoxImg[12] ;
-coords plugImg[2];
-coords chargImg[2];
-coords battImg[8];
-coords plugSize ;
-coords chargSize ;
-coords battSize ;
-coords voltIndSize ;
-coords voltIndImg ;
-coords timeleftIndSize ;
-coords timeleftIndImg ;
-coords jukeBoxSize[2] ;
-int jukeBoxParts ;
-int XOFFSET = 0;
-int YOFFSET = 0;
-interface gui ;
-
-int update_rate=100000;
-
-char *ProgName;
-
-time_t curtime;
-time_t prevtime;
-
-int mode = 0 ; // default: no info
-int screen = 0; // default: Quality screen is displayed
-
-void showGUIelement(coords img, coords size, coords dest){
- copyXPMArea(img.x,img.y,size.x,size.y,dest.x,dest.y) ;
+pmud_info sys_pmu;
+
+gui_info gui;
+gui_xpm xpm;
+
+void showGUIelement (coords img, coords size, coords dest)
+{
+ copyXPMArea(img.x, img.y, size.x, size.y, dest.x, dest.y);
}
-void updatePlug (int state){
- showGUIelement(plugImg[state],plugSize,gui.plug);
+void updatePlug (int state)
+{
+ showGUIelement(xpm.plugImg[state], xpm.plugSize, gui.plug);
}
-void updateCharg (int state){
- showGUIelement(chargImg[state],chargSize,gui.charg);
+void updateCharg (int state)
+{
+ showGUIelement(xpm.chargImg[state], xpm.chargSize, gui.charg);
}
-void drawBatteryState(int bat_side, int bat_state){
- showGUIelement(battImg[bat_side*4+bat_state],battSize,gui.batt[bat_side]);
+void drawBatteryState (int bat_side, int bat_state)
+{
+ showGUIelement(xpm.battImg[bat_side*4+bat_state], xpm.battSize, gui.batt[bat_side]);
}
-void initXIMGUIelements (){
- int i = 0;
- gui.voltage[V].x = 20 ;
- gui.voltage[V].y = 6 ;
- gui.voltage[MV].x = 34 ;
- gui.voltage[MV].y = 6 ;
- gui.symbols[COMMA].x = 32 ;
- gui.symbols[COMMA].y = 11 ;
- gui.percent[LEFT_BATTERY].x = 65 ;
- gui.percent[LEFT_BATTERY].y = 6 ;
- gui.percent[RIGHT_BATTERY].x = 91 ;
- gui.percent[RIGHT_BATTERY].y = 6 ;
- gui.timeleft[HOURS].x = 119 ;
- gui.timeleft[HOURS].y = 6 ;
- gui.timeleft[MINUTES].x = 137 ;
- gui.timeleft[MINUTES].y = 6 ;
- gui.jukeBox[0].x = 23 ;
- gui.jukeBox[0].y = 1 ;
- gui.jukeBox[1].x = 122 ;
- gui.jukeBox[1].y = 1 ;
- gui.batt[LEFT_BATTERY].x = 60 ;
- gui.batt[LEFT_BATTERY].y = 4 ;
- gui.batt[RIGHT_BATTERY].x = 87 ;
- gui.batt[RIGHT_BATTERY].y = 4 ;
- gui.plug.x = 3 ;
- gui.plug.y = 2 ;
- gui.charg.x = 158 ;
- gui.charg.y = 2 ;
- jukeBoxParts = 2 ;
- jukeBoxSize[0].x = 28 ;
- jukeBoxSize[0].y = 4 ;
- jukeBoxSize[1].x = 28 ;
- jukeBoxSize[1].y = 4 ;
- for (i=0; i < 10;i++){
- jukeBoxImg[i].x += 14 ;
- }
+void initXIMGUIelements (void)
+{
+ int i = 0;
+
+ gui.voltage[V].x = 20;
+ gui.voltage[V].y = 6;
+ gui.voltage[MV].x = 34;
+ gui.voltage[MV].y = 6;
+ gui.symbols[COMMA].x = 32;
+ gui.symbols[COMMA].y = 11;
+ gui.percent[LEFT_BATTERY].x = 65;
+ gui.percent[LEFT_BATTERY].y = 6;
+ gui.percent[RIGHT_BATTERY].x = 91;
+ gui.percent[RIGHT_BATTERY].y = 6;
+ gui.timeleft[HOURS].x = 119;
+ gui.timeleft[HOURS].y = 6;
+ gui.timeleft[MINUTES].x = 137;
+ gui.timeleft[MINUTES].y = 6;
+ gui.jukeBox[0].x = 23;
+ gui.jukeBox[0].y = 1;
+ gui.jukeBox[1].x = 122;
+ gui.jukeBox[1].y = 1;
+ gui.batt[LEFT_BATTERY].x = 60;
+ gui.batt[LEFT_BATTERY].y = 4;
+ gui.batt[RIGHT_BATTERY].x = 87;
+ gui.batt[RIGHT_BATTERY].y = 4;
+ gui.plug.x = 3;
+ gui.plug.y = 2;
+ gui.charg.x = 158;
+ gui.charg.y = 2;
+ gui.jukeBoxParts = 2;
+ gui.jukeBoxSize[0].x = 28;
+ gui.jukeBoxSize[0].y = 4;
+ gui.jukeBoxSize[1].x = 28;
+ gui.jukeBoxSize[1].y = 4;
+
+ for (i=0; i < 10; i++)
+ xpm.jukeBoxImg[i].x += 14;
}
-void initWMGUIelements (){
- gui.voltage[V].x = 15 ;
- gui.voltage[V].y = 2 ;
- gui.voltage[MV].x = 29 ;
- gui.voltage[MV].y = 2 ;
- gui.symbols[COMMA].x = 27 ;
- gui.symbols[COMMA].y = 7 ;
- gui.percent[LEFT_BATTERY].x = 11 ;
- gui.percent[LEFT_BATTERY].y = 49 ;
- gui.percent[RIGHT_BATTERY].x = 36 ;
- gui.percent[RIGHT_BATTERY].y = 49 ;
- gui.timeleft[HOURS].x = 15 ;
- gui.timeleft[HOURS].y = 31 ;
- gui.timeleft[MINUTES].x = 33 ;
- gui.timeleft[MINUTES].y = 31 ;
- gui.jukeBox[0].x = 4 ;
- gui.jukeBox[0].y = 13 ;
- gui.jukeBox[1].x = 0 ;
- gui.jukeBox[1].y = 0 ;
- gui.batt[LEFT_BATTERY].x = 6 ;
- gui.batt[LEFT_BATTERY].y = 47 ;
- gui.batt[RIGHT_BATTERY].x = 33 ;
- gui.batt[RIGHT_BATTERY].y = 47 ;
- gui.plug.x = 2 ;
- gui.plug.y = 2 ;
- gui.charg.x = 50 ;
- gui.charg.y = 2 ;
- jukeBoxParts = 1 ;
- jukeBoxSize[0].x = 56 ;
- jukeBoxSize[0].y = 30 ;
- jukeBoxSize[1].x = 0 ;
- jukeBoxSize[1].y = 0 ;
+void initWMGUIelements (void)
+{
+ gui.voltage[V].x = 15;
+ gui.voltage[V].y = 2;
+ gui.voltage[MV].x = 29;
+ gui.voltage[MV].y = 2;
+ gui.symbols[COMMA].x = 27;
+ gui.symbols[COMMA].y = 7;
+ gui.percent[LEFT_BATTERY].x = 11;
+ gui.percent[LEFT_BATTERY].y = 49;
+ gui.percent[RIGHT_BATTERY].x = 36;
+ gui.percent[RIGHT_BATTERY].y = 49;
+ gui.timeleft[HOURS].x = 15;
+ gui.timeleft[HOURS].y = 31;
+ gui.timeleft[MINUTES].x = 33;
+ gui.timeleft[MINUTES].y = 31;
+ gui.jukeBox[0].x = 4;
+ gui.jukeBox[0].y = 13;
+ gui.jukeBox[1].x = 0;
+ gui.jukeBox[1].y = 0;
+ gui.batt[LEFT_BATTERY].x = 6;
+ gui.batt[LEFT_BATTERY].y = 47;
+ gui.batt[RIGHT_BATTERY].x = 33;
+ gui.batt[RIGHT_BATTERY].y = 47;
+ gui.plug.x = 2;
+ gui.plug.y = 2;
+ gui.charg.x = 50;
+ gui.charg.y = 2;
+ gui.jukeBoxParts = 1;
+ gui.jukeBoxSize[0].x = 56;
+ gui.jukeBoxSize[0].y = 30;
+ gui.jukeBoxSize[1].x = 0;
+ gui.jukeBoxSize[1].y = 0;
}
-void initXPMelements(){
- timeleftIndSize.x = 36 ;
- timeleftIndSize.y = 13 ;
- timeleftIndImg.x = 15;
- timeleftIndImg.y = 29 + YOFFSET ;
- voltIndSize.x = 34 ;
- voltIndSize.y = 10 ;
- voltIndImg.x = 2;
- voltIndImg.y = 84 + YOFFSET;
- battImg[LEFT_BATTERY*4+HIGH_BATT].x = 146 ;
- battImg[LEFT_BATTERY*4+HIGH_BATT].y = 6 + YOFFSET ;
- battImg[LEFT_BATTERY*4+LOW_BATT].x = 173 ;
- battImg[LEFT_BATTERY*4+LOW_BATT].y = 6 + YOFFSET ;
- battImg[LEFT_BATTERY*4+MED_BATT].x = 200 ;
- battImg[LEFT_BATTERY*4+MED_BATT].y = 6 + YOFFSET ;
- battImg[LEFT_BATTERY*4+NO_BATT].x = 108 ;
- battImg[LEFT_BATTERY*4+NO_BATT].y = 85 + YOFFSET ;
- battImg[RIGHT_BATTERY*4+HIGH_BATT].x = 146 ;
- battImg[RIGHT_BATTERY*4+HIGH_BATT].y = 21 + YOFFSET ;
- battImg[RIGHT_BATTERY*4+LOW_BATT].x = 173 ;
- battImg[RIGHT_BATTERY*4+LOW_BATT].y = 21 + YOFFSET ;
- battImg[RIGHT_BATTERY*4+MED_BATT].x = 200 ;
- battImg[RIGHT_BATTERY*4+MED_BATT].y = 21 + YOFFSET ;
- battImg[RIGHT_BATTERY*4+NO_BATT].x = 135 ;
- battImg[RIGHT_BATTERY*4+NO_BATT].y = 85 + YOFFSET ;
- battSize.x = 25 ;
- battSize.y = 13 ;
- plugSize.x = 12 ;
- plugSize.y = 16 ;
- chargSize.x = 12 ;
- chargSize.y = 16 ;
- plugImg[0].x = 158 ;
- plugImg[0].y = 53 + YOFFSET ;
- plugImg[1].x = 158 ;
- plugImg[1].y = 36 + YOFFSET ;
- chargImg[0].x = 134 ;
- chargImg[0].y = 53 + YOFFSET ;
- chargImg[1].x = 134 ;
- chargImg[1].y = 36 + YOFFSET ;
- jukeBoxImg[0].x = 173 ;
- jukeBoxImg[0].y = 68 + YOFFSET ;
- jukeBoxImg[1].x = 5 ;
- jukeBoxImg[1].y = 101 + YOFFSET ;
- jukeBoxImg[2].x = 126 ;
- jukeBoxImg[2].y = 135 + YOFFSET ;
- jukeBoxImg[3].x = 4 ;
- jukeBoxImg[3].y = 168 + YOFFSET ;
- jukeBoxImg[4].x = 127 ;
- jukeBoxImg[4].y = 168 + YOFFSET ;
- jukeBoxImg[5].x = 65 ;
- jukeBoxImg[5].y = 168 + YOFFSET ;
- jukeBoxImg[6].x = 127 ;
- jukeBoxImg[6].y = 101 + YOFFSET ;
- jukeBoxImg[7].x = 4 ;
- jukeBoxImg[7].y = 135 + YOFFSET ;
- jukeBoxImg[8].x = 65 ;
- jukeBoxImg[8].y = 135 + YOFFSET ;
- jukeBoxImg[9].x = 66 ;
- jukeBoxImg[9].y = 101 + YOFFSET ;
- jukeBoxImg[10].x = 173 ;
- jukeBoxImg[10].y = 36 + YOFFSET ;
+void initXPMelements (int xoff, int yoff)
+{
+ xpm.offset.x = xoff;
+ xpm.offset.y = yoff;
+
+ xpm.timeleftIndSize.x = 36 ;
+ xpm.timeleftIndSize.y = 13 ;
+ xpm.timeleftIndImg.x = 15;
+ xpm.timeleftIndImg.y = 29 + xpm.offset.y;
+ xpm.voltIndSize.x = 34;
+ xpm.voltIndSize.y = 10;
+ xpm.voltIndImg.x = 2;
+ xpm.voltIndImg.y = 84 + xpm.offset.y;
+ xpm.battImg[LEFT_BATTERY*4+HIGH_BATT].x = 146;
+ xpm.battImg[LEFT_BATTERY*4+HIGH_BATT].y = 6 + xpm.offset.y;
+ xpm.battImg[LEFT_BATTERY*4+LOW_BATT].x = 173;
+ xpm.battImg[LEFT_BATTERY*4+LOW_BATT].y = 6 + xpm.offset.y;
+ xpm.battImg[LEFT_BATTERY*4+MED_BATT].x = 200;
+ xpm.battImg[LEFT_BATTERY*4+MED_BATT].y = 6 + xpm.offset.y;
+ xpm.battImg[LEFT_BATTERY*4+NO_BATT].x = 108;
+ xpm.battImg[LEFT_BATTERY*4+NO_BATT].y = 85 + xpm.offset.y;
+ xpm.battImg[RIGHT_BATTERY*4+HIGH_BATT].x = 146;
+ xpm.battImg[RIGHT_BATTERY*4+HIGH_BATT].y = 21 + xpm.offset.y;
+ xpm.battImg[RIGHT_BATTERY*4+LOW_BATT].x = 173;
+ xpm.battImg[RIGHT_BATTERY*4+LOW_BATT].y = 21 + xpm.offset.y;
+ xpm.battImg[RIGHT_BATTERY*4+MED_BATT].x = 200;
+ xpm.battImg[RIGHT_BATTERY*4+MED_BATT].y = 21 + xpm.offset.y;
+ xpm.battImg[RIGHT_BATTERY*4+NO_BATT].x = 135;
+ xpm.battImg[RIGHT_BATTERY*4+NO_BATT].y = 85 + xpm.offset.y;
+ xpm.battSize.x = 25;
+ xpm.battSize.y = 13;
+ xpm.plugSize.x = 12;
+ xpm.plugSize.y = 16;
+ xpm.chargSize.x = 12;
+ xpm.chargSize.y = 16;
+ xpm.plugImg[0].x = 158;
+ xpm.plugImg[0].y = 53 + xpm.offset.y;
+ xpm.plugImg[1].x = 158;
+ xpm.plugImg[1].y = 36 + xpm.offset.y;
+ xpm.chargImg[0].x = 134;
+ xpm.chargImg[0].y = 53 + xpm.offset.y;
+ xpm.chargImg[1].x = 134;
+ xpm.chargImg[1].y = 36 + xpm.offset.y;
+ xpm.jukeBoxImg[0].x = 173;
+ xpm.jukeBoxImg[0].y = 68 + xpm.offset.y;
+ xpm.jukeBoxImg[1].x = 5;
+ xpm.jukeBoxImg[1].y = 101 + xpm.offset.y;
+ xpm.jukeBoxImg[2].x = 126;
+ xpm.jukeBoxImg[2].y = 135 + xpm.offset.y;
+ xpm.jukeBoxImg[3].x = 4;
+ xpm.jukeBoxImg[3].y = 168 + xpm.offset.y;
+ xpm.jukeBoxImg[4].x = 127;
+ xpm.jukeBoxImg[4].y = 168 + xpm.offset.y;
+ xpm.jukeBoxImg[5].x = 65;
+ xpm.jukeBoxImg[5].y = 168 + xpm.offset.y;
+ xpm.jukeBoxImg[6].x = 127;
+ xpm.jukeBoxImg[6].y = 101 + xpm.offset.y;
+ xpm.jukeBoxImg[7].x = 4;
+ xpm.jukeBoxImg[7].y = 135 + xpm.offset.y;
+ xpm.jukeBoxImg[8].x = 65;
+ xpm.jukeBoxImg[8].y = 135 + xpm.offset.y;
+ xpm.jukeBoxImg[9].x = 66;
+ xpm.jukeBoxImg[9].y = 101 + xpm.offset.y;
+ xpm.jukeBoxImg[10].x = 173;
+ xpm.jukeBoxImg[10].y = 36 + xpm.offset.y;
}
-void initGUIelements(){
- if (wm == WMAKER){
- initXPMelements();
- initWMGUIelements();
- }
- else
- { YOFFSET = 30 ;
- initXPMelements();
- initXIMGUIelements();
- }
+void initGUIelements (wm_info *wm)
+{
+ if (wm->type == WMAKER)
+ {
+ initXPMelements(0, 0);
+ initWMGUIelements();
+ }
+ else
+ {
+ initXPMelements(0, 30);
+ initXIMGUIelements();
+ }
}
-void drawJukeBox (int state){
- showGUIelement (jukeBoxImg[state],jukeBoxSize[0],gui.jukeBox[0]) ;
- if (jukeBoxParts > 1)
- showGUIelement (jukeBoxImg[state],jukeBoxSize[1],gui.jukeBox[1]) ;
+void drawJukeBox (int state)
+{
+ showGUIelement (xpm.jukeBoxImg[state], gui.jukeBoxSize[0], gui.jukeBox[0]) ;
+ if (gui.jukeBoxParts > 1)
+ showGUIelement (xpm.jukeBoxImg[state], gui.jukeBoxSize[1], gui.jukeBox[1]) ;
}
-int open_pmud_socket() {
+int open_pmud_socket (void)
+{
+ int ret;
+ int sa_size;
- int ret;
- struct sockaddr_in sin ;
- sin.sin_family = PF_INET ;
- sin.sin_port = htons (PMUD_PORT) ;
- sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK) ;
+ struct sockaddr *sa;
+
+ struct sockaddr_in sin;
+ struct sockaddr_un sun;
+
+ if (sys_pmu.pmud_domain == PF_INET)
+ {
+ /* INET part */
+ sin.sin_family = PF_INET;
+ sin.sin_port = htons (PMUD_PORT);
+ sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+
+ sa = (struct sockaddr *) &sin;
+ sa_size = sizeof (struct sockaddr_in);
+ }
+ else
+ {
+ /* UNIX part */
+ sun.sun_family = PF_UNIX;
+ strcpy (sun.sun_path, sys_pmu.socket_path);
+
+ sa = (struct sockaddr *) &sun;
+ sa_size = sizeof (struct sockaddr_un);
+ }
+
+ if ((ret = socket (sys_pmu.pmud_domain, SOCK_STREAM, 0)) >= 0)
+ {
+ if (connect (ret, sa, sa_size) >= 0)
+ return ret;
+ else
+ close (ret);
+ }
- if ((ret = socket (PF_INET, SOCK_STREAM, 0)) >= 0) {
- if (connect (ret, (struct sockaddr *) &sin, sizeof (sin)) >= 0) {
- return ret;
- } else {
- close (ret);
- }
- }
- return -1;
+ return -1;
}
-enum { KL_IBOOK, KL_PISMO, KL_UNKNOWN };
+static mactype keylargo_identify (void)
+{
+ FILE *fd;
+ char buf[25];
+ if (!(fd = fopen ("/proc/device-tree/pci/mac-io/media-bay/compatible", "ro")))
+ return KL_IBOOK;
+ /*
+ * no media-bay. definately an iBook...
+ * or a Pismo running a kernel without OF-devtree support...
+ */
+ fscanf (fd, "%s", buf);
+ fclose (fd);
+ if (!strcmp ("keylargo-media-bay", buf)) // only the pismo should have one
+ return KL_PISMO; // has one, its a pismo
+ else
+ return KL_UNKNOWN;
+ /*
+ * has a media bay, IDs as a Keylargo, but not a
+ * "keylargo-media-bay"... what the...
+ */
+}
-static int keylargo_identify ()
+void read_pmu_proc (void)
{
- FILE *fd;
- char buf[25];
- if (!(fd = fopen ("/proc/device-tree/pci/mac-io/media-bay/compatible", "ro")))
- return KL_IBOOK;
- /* no media-bay. definately an iBook...
- * or a Pismo running a kernel without OF-devtree support...
- */
- fscanf (fd, "%s", buf);
- fclose (fd);
- if (!strcmp ("keylargo-media-bay", buf)) // only the pismo should have one
- return KL_PISMO; // has one, its a pismo
- else
- return KL_UNKNOWN;
- /* has a media bay, IDs as a Keylargo, but not a
- * "keylargo-media-bay.... what the...
- */
+ static int info_fd = -1;
+ static int batt_fd[2] = { -1, -1 };
+ int nb_batt, flags;
+ int charge, maxcharge;
+ int time_left[2];
+
+ int i;
+
+ char buf[128];
+ char *s;
+
+ if (info_fd < 0)
+ {
+ info_fd = open(PMU_PROC_INFO, O_RDONLY);
+
+ if (info_fd < 0)
+ {
+ sys_pmu.time_left = -2;
+ return;
+ }
+ }
+
+ if (read(info_fd, buf, 127) < 0)
+ {
+ sys_pmu.time_left = -2;
+ return;
+ }
+
+ /* Skip PMU driver version */
+ s = strchr(buf, '\n');
+
+ /* Skip PMU firmware version */
+ s = strchr(s + 1, '\n');
+
+ /* Get the AC status */
+ s = strchr(s + 1, ':');
+ sys_pmu.ac_connected = atoi(s + 2);
+
+ /* Get the number of batteries */
+ s = strchr(s + 1, ':');
+ nb_batt = atoi(s + 2);
+
+ close(info_fd);
+ info_fd = -1;
+
+ sys_pmu.b[LEFT_BATTERY].state = NO_BATT;
+ sys_pmu.b[RIGHT_BATTERY].state = NO_BATT;
+ sys_pmu.time_left = 0;
+ time_left[0] = 0;
+ time_left[1] = 0;
+
+ for (i = 0; i < 2; i++)
+ {
+ if (batt_fd[i] < 0)
+ {
+ sprintf(buf, PMU_PROC_BATTERY_BASE "%d", i);
+
+ if ((batt_fd[i] = open(buf, O_RDONLY)) < 0)
+ {
+ sys_pmu.b[i].available = NO_BATT;
+ }
+ }
+
+ if (read(batt_fd[i], buf, 127) < 0)
+ {
+ sys_pmu.b[i].available = NO_BATT;
+ flags = 0;
+ }
+ else
+ {
+ /* Get the flags */
+ s = strchr(buf, ':');
+ /*
+ * We want only the 1st digit (byte, actually)
+ * other bytes are not relevant yet (2nd byte indicates the battery type)
+ */
+ flags = atoi(s + 2 + 7);
+ }
+
+ if ((flags & PMU_PROC_PRESENT) && (i < nb_batt))
+ {
+ sys_pmu.b[i].available = IS_BATT;
+ sys_pmu.b[i].charging = flags & PMU_PROC_CHARGING;
+ /* Get the charge */
+ s = strchr(s + 1, ':');
+ charge = atoi(s + 2);
+ /* Get the max_charge */
+ s = strchr(s + 1, ':');
+ maxcharge = atoi(s + 2);
+ /* Get the current */
+ s = strchr(s + 1, ':');
+ sys_pmu.b[i].current = atoi(s + 2);
+ /* Get the voltage */
+ s = strchr(s + 1, ':');
+ sys_pmu.b[i].voltage = atoi(s + 2);
+ /* Get the time remaining */
+ s = strchr(s + 1, ':');
+ time_left[i] = atoi(s + 2) / 60; /* We get the time in seconds, we want minutes */
+ sys_pmu.b[i].percentage = charge * 100 / maxcharge;
+ sys_pmu.b[i].state = IS_BATT;
+ }
+ else
+ {
+ sys_pmu.b[i].available = NO_BATT;
+ sys_pmu.b[i].percentage = 0;
+ sys_pmu.b[i].current = 0;
+ sys_pmu.b[i].voltage = 0.0;
+ sys_pmu.b[i].charging = 0;
+ }
+
+ close(batt_fd[i]);
+ batt_fd[i] = -1;
+ }
+
+ sys_pmu.current = sys_pmu.b[LEFT_BATTERY].current + sys_pmu.b[RIGHT_BATTERY].current;
+
+ if (sys_pmu.b[0].charging && sys_pmu.b[1].charging)
+ sys_pmu.time_left = (time_left[0] > time_left[1]) ? time_left[0] : time_left[1];
+ else if (sys_pmu.b[0].charging)
+ sys_pmu.time_left = time_left[0];
+ else if (sys_pmu.b[1].charging)
+ sys_pmu.time_left = time_left[1];
+ else
+ sys_pmu.time_left = time_left[0] + time_left[1];
}
-void read_g3_pmu ()
-{ /* smart battery systems are the same */
- unsigned char par;
- int current, charge, maxcharge, ac_hold = -1;
- char *b;
- char c[150];
- static int sock = -1;
-
- if (sock < 0) {
- if ((sock = open_pmud_socket ()) < 0) {
- sys_pmu.time_left = -2;
- return;
- } else {
- read (sock, c, 150);
- }
- }
+void read_pmu_socket (void)
+{
+ /* smart battery systems are the same */
+ unsigned char par;
+ int current, charge, maxcharge, ac_hold = -1;
+ char *b;
+ char c[150];
+ static int sock = -1;
+ int i;
#ifdef PMUD_REFRESH
- read (sock, c, 150);
- shutdown (sock, SHUT_RDWR);
- close (sock);
- sock = -1;
-#else
- write (sock, "\n", 1);
- read (sock, c, 150);
+ int ret;
#endif
- b = strtok (c, PMUD_INPUT_DELIM);
- if (b[0] != 'S')
- return;
- sys_pmu.batt_state[LEFT_BATTERY] = NO_BATT ;
- sys_pmu.batt_state[RIGHT_BATTERY] = NO_BATT ;
-
- sys_pmu.time_left = 0;
- for (par = 0; par < 2; par++) {
- ac_hold = atoi (strtok (0, PMUD_INPUT_DELIM));
- if (ac_hold % 10) {
- sys_pmu.b[par].available = IS_BATT ;
- sys_pmu.b[par].charging = (((ac_hold / 10) % 10) == 1);
- charge = atoi (strtok (0, PMUD_INPUT_DELIM));
- maxcharge = atoi (strtok (0, PMUD_INPUT_DELIM)) - 2 ;
- sys_pmu.b[par].current = atoi (strtok (0, PMUD_INPUT_DELIM));
- sys_pmu.b[par].voltage = atoi (strtok (0, PMUD_INPUT_DELIM));
- sys_pmu.b[par].percentage = charge * 100 / maxcharge ;
- sys_pmu.time_left += ((ac_hold / 100) ? maxcharge - charge : charge);
- sys_pmu.batt_state[par] = IS_BATT ;
- } else {
- sys_pmu.b[par].available = NO_BATT ;
- sys_pmu.b[par].percentage = 0;
- sys_pmu.b[par].current = 0;
- sys_pmu.b[par].voltage = 0.0;
- sys_pmu.b[par].charging = 0;
- }
- }
- sys_pmu.ac_connected = ac_hold / 100;
- current = sys_pmu.b[LEFT_BATTERY].current + sys_pmu.b[RIGHT_BATTERY].current;
- if (current < 0)
- sys_pmu.time_left = sys_pmu.time_left * 3552 / (current * -60);
- else if (sys_pmu.show_charge_time && (current > 0))
- sys_pmu.time_left = sys_pmu.time_left * 3552 / (current * 60);
- else
- sys_pmu.time_left = -1;
-
- sys_pmu.current = current ;
-}
+
+ if (sock < 0)
+ if ((sock = open_pmud_socket ()) < 0)
+ {
+ sys_pmu.time_left = -2;
+ return;
+ }
-void DisplayBat(void) {
-
- int keylargo ;
- unsigned int par = 0 ;
- int hour = 0 ;
- int min = 0 ;
- int volts = 0 ;
- int millivolts = 0 ;
- int i;
- int state ;
+#ifdef PMUD_REFRESH
+ ret = read (sock, c, 150);
+ shutdown (sock, SHUT_RDWR);
+ close (sock);
+ sock = -1;
+
+ if (ret <= 0)
+ {
+ sys_pmu.time_left = 0;
- sys_pmu.show_charge_time = 1 ;
+ sys_pmu.ac_connected = 0;
+ sys_pmu.show_charge_time = 0;
+ sys_pmu.current = 0;
- keylargo = keylargo_identify() ; // TODO : use this detection
+ for (i = 0; i < 2; i++)
+ {
+ sys_pmu.b[i].available = IS_BATT;
+
+ sys_pmu.b[i].current = 0;
+ sys_pmu.b[i].percentage = 0;
+ sys_pmu.b[i].charging = 0;
+ sys_pmu.b[i].voltage = 0;
+
+ sys_pmu.b[i].state = NO_BATT;
+ }
- read_g3_pmu () ;
-
- if (sys_pmu.time_left == -1)
- drawJukeBox(0) ;
- else
- { state = (sys_pmu.current + 200) / 200 ;
- if (state < 0)
- state = state * -1 ;
- if (state > 9)
- state = 9 ;
- drawJukeBox(state);
- hour = sys_pmu.time_left / 60 ;
- min = sys_pmu.time_left % 60 ;
- // printf("%i,%d,%d\n",sys_pmu.time_left,hour,min);
- BlitNum(hour,gui.timeleft[HOURS].x,gui.timeleft[HOURS].y,BIG,1);
- BlitNum(min,gui.timeleft[MINUTES].x,gui.timeleft[MINUTES].y,BIG,1);
+ return;
+ }
+#else /* !PMUD_REFRESH */
+ if ((write(sock, "\n", 1) <= 0) || (read (sock, c, 150) <= 0))
+ {
+ shutdown (sock, SHUT_RDWR);
+ close (sock);
+ sock = -1;
+
+ sys_pmu.time_left = 0;
+
+ sys_pmu.ac_connected = 0;
+ sys_pmu.show_charge_time = 0;
+ sys_pmu.current = 0;
+
+ for (i = 0; i < 2; i++)
+ {
+ sys_pmu.b[i].available = IS_BATT;
+
+ sys_pmu.b[i].current = 0;
+ sys_pmu.b[i].percentage = 0;
+ sys_pmu.b[i].charging = 0;
+ sys_pmu.b[i].voltage = 0;
+
+ sys_pmu.b[i].state = NO_BATT;
}
- if (sys_pmu.ac_connected)
- updatePlug(PLUGGED) ;
- else
- updatePlug(UNPLUGGED) ;
-
- if (sys_pmu.b[LEFT_BATTERY].charging || sys_pmu.b[RIGHT_BATTERY].charging)
- updateCharg(CHARGE) ;
- else
- updateCharg(NOCHARGE) ;
-
- for (par=0; par<2; par++){
- if (sys_pmu.b[par].available == NO_BATT){
- drawBatteryState(par,NO_BATT) ;
- }else {
- if (sys_pmu.b[par].percentage > 70)
- drawBatteryState(par,HIGH_BATT) ;
- else if (sys_pmu.b[par].percentage > 25)
- drawBatteryState(par,MED_BATT) ;
- else if ((sys_pmu.b[par].percentage > 5) || (sys_pmu.b[par].charging) || (sys_pmu.b[1-par].percentage > 5))
- drawBatteryState(par,LOW_BATT) ;
- else
- {
- for (i=0; i<update_rate/50000; i++){
- drawBatteryState(par,NO_BATT) ;
- RedrawWindow() ;
- usleep(200000) ;
- drawBatteryState(par,LOW_BATT) ;
- RedrawWindow() ;
- }
- }
+ return;
+ }
+#endif /* PMUD_REFRESH */
+
+ b = strtok (c, PMUD_INPUT_DELIM);
+ if (b[0] != 'S')
+ return;
+
+ sys_pmu.b[LEFT_BATTERY].state = NO_BATT;
+ sys_pmu.b[RIGHT_BATTERY].state = NO_BATT;
+
+ sys_pmu.time_left = 0;
+ for (par = 0; par < 2; par++)
+ {
+ ac_hold = atoi (strtok (NULL, PMUD_INPUT_DELIM));
+ if (ac_hold % 10)
+ {
+ sys_pmu.b[par].available = IS_BATT;
+ sys_pmu.b[par].charging = (((ac_hold / 10) % 10) == 1);
+ charge = atoi (strtok (NULL, PMUD_INPUT_DELIM));
+ maxcharge = atoi (strtok (NULL, PMUD_INPUT_DELIM)) - 2 ;
+ sys_pmu.b[par].current = atoi (strtok (NULL, PMUD_INPUT_DELIM));
+ sys_pmu.b[par].voltage = atoi (strtok (NULL, PMUD_INPUT_DELIM));
+ sys_pmu.b[par].percentage = charge * 100 / maxcharge;
+ sys_pmu.time_left += ((ac_hold / 100) ? maxcharge - charge : charge);
+ sys_pmu.b[par].state = IS_BATT;
+ }
+ else
+ {
+ sys_pmu.b[par].available = NO_BATT;
+ sys_pmu.b[par].percentage = 0;
+ sys_pmu.b[par].current = 0;
+ sys_pmu.b[par].voltage = 0;
+ sys_pmu.b[par].charging = 0;
+ }
+ }
+
+ sys_pmu.ac_connected = ac_hold / 100;
+ current = sys_pmu.b[LEFT_BATTERY].current + sys_pmu.b[RIGHT_BATTERY].current;
+ if (current < 0)
+ sys_pmu.time_left = sys_pmu.time_left * 3552 / (current * -60);
+ else if (sys_pmu.show_charge_time && (current > 0))
+ sys_pmu.time_left = sys_pmu.time_left * 3552 / (current * 60);
+ else
+ sys_pmu.time_left = -1;
+
+ sys_pmu.current = current ;
+}
+
+
+void DisplayBat(void)
+{
+ int keylargo;
+ unsigned int par = 0;
+ int hour = 0;
+ int min = 0;
+ int volts = 0;
+ int millivolts = 0;
+ int i;
+ int state;
+
+ sys_pmu.show_charge_time = 1;
+
+ keylargo = keylargo_identify(); /* TODO : use this detection */
- if (sys_pmu.b[par].percentage == 100){
- BlitNum(sys_pmu.b[par].percentage,gui.percent[par].x-6,gui.percent[par].y,SMALL,2) ;
- } else {
- BlitNum(sys_pmu.b[par].percentage,gui.percent[par].x,gui.percent[par].y,SMALL,1) ;
+ sys_pmu.read_pmu();
+
+ if (sys_pmu.time_left == -1)
+ drawJukeBox(0);
+ else
+ {
+ state = (sys_pmu.current + 200) / 200 ;
+ if (state < 0)
+ state = state * -1 ;
+ if (state > 9)
+ state = 9 ;
+ drawJukeBox(state);
+ if (sys_pmu.time_left == -2)
+ {
+ hour = 0;
+ min = 0;
+ }
+ else
+ {
+ hour = sys_pmu.time_left / 60;
+ min = sys_pmu.time_left % 60;
+ }
+ //printf("%i,%d,%d\n",sys_pmu.time_left,hour,min);
+ BlitNum(hour, gui.timeleft[HOURS].x, gui.timeleft[HOURS].y, BIG, 1);
+ BlitNum(min, gui.timeleft[MINUTES].x, gui.timeleft[MINUTES].y, BIG, 1);
+ }
+
+ if (sys_pmu.ac_connected)
+ updatePlug(PLUGGED);
+ else
+ updatePlug(UNPLUGGED);
+
+ if (sys_pmu.b[LEFT_BATTERY].charging || sys_pmu.b[RIGHT_BATTERY].charging)
+ updateCharg(CHARGE);
+ else
+ updateCharg(NOCHARGE);
+
+ for (par = 0; par < 2; par++)
+ {
+ if (sys_pmu.b[par].available == NO_BATT)
+ drawBatteryState(par, NO_BATT);
+ else
+ {
+ if (sys_pmu.b[par].percentage > 70)
+ drawBatteryState(par, HIGH_BATT);
+ else if (sys_pmu.b[par].percentage > 25)
+ drawBatteryState(par, MED_BATT);
+ else if ((sys_pmu.b[par].percentage > 5) || (sys_pmu.b[par].charging) || (sys_pmu.b[1-par].percentage > 5))
+ drawBatteryState(par, LOW_BATT);
+ else
+ {
+ /*
+ * This is were we blink when the connection to pmud is lost.
+ * So, we must have :
+ * b[].percentage < 5 (0 will do)
+ * b[].available != NO_BATT (0 will do too)
+ */
+ for (i = 0; i < (sys_pmu.update_rate / 50000); i++)
+ {
+ drawBatteryState(par, NO_BATT);
+ RedrawWindow();
+ usleep(200000);
+ drawBatteryState(par, LOW_BATT);
+ RedrawWindow();
}
+ }
+
+ if (sys_pmu.b[par].percentage == 100)
+ BlitNum(sys_pmu.b[par].percentage, (gui.percent[par].x - 6), gui.percent[par].y, SMALL, 2);
+ else
+ BlitNum(sys_pmu.b[par].percentage, gui.percent[par].x, gui.percent[par].y, SMALL, 1);
- volts = sys_pmu.b[par].voltage / 1000 ;
- millivolts = sys_pmu.b[par].voltage % 1000 ;
- BlitNum(volts,gui.voltage[V].x,gui.voltage[V].y,SMALL,1) ;
- BlitNum(millivolts,gui.voltage[MV].x,gui.voltage[MV].y,SMALL,0) ;
- copyXPMArea(74,69+YOFFSET,2,3,gui.symbols[COMMA].x,gui.symbols[COMMA].y);
+ volts = sys_pmu.b[par].voltage / 1000;
+ millivolts = sys_pmu.b[par].voltage % 1000;
+ BlitNum(volts, gui.voltage[V].x, gui.voltage[V].y, SMALL, 1);
+ BlitNum(millivolts, gui.voltage[MV].x, gui.voltage[MV].y, SMALL, 0);
+ copyXPMArea(74, (69 + xpm.offset.y), 2, 3, gui.symbols[COMMA].x, gui.symbols[COMMA].y);
}
- }
+ }
- if (sys_pmu.b[LEFT_BATTERY].available == NO_BATT
- && sys_pmu.b[RIGHT_BATTERY].available == NO_BATT)
- copyXPMArea(voltIndImg.x,voltIndImg.y,voltIndSize.x,voltIndSize.y,gui.voltage[V].x,gui.voltage[V].y) ;
+ if ((sys_pmu.b[LEFT_BATTERY].available == NO_BATT) &&
+ (sys_pmu.b[RIGHT_BATTERY].available == NO_BATT))
+ copyXPMArea(xpm.voltIndImg.x, xpm.voltIndImg.y, xpm.voltIndSize.x, xpm.voltIndSize.y, gui.voltage[V].x, gui.voltage[V].y);
}
+#ifdef ENABLE_XOSD
+
+time_t DisplayOSD (void)
+{
+ int osd_freq;
+ int ref_bat; /* reference battery, ie the weakest one */
+ char buf[128];
+
+ if ((sys_pmu.time_left <= 0) ||
+ ((sys_pmu.b[LEFT_BATTERY].available == NO_BATT) && (sys_pmu.b[RIGHT_BATTERY].available == NO_BATT)))
+ return 0;
+
+ /* mandatory ? */
+ memset(buf, 0, 128);
+
+ if ((sys_pmu.b[LEFT_BATTERY].charging) && !(sys_pmu.b[RIGHT_BATTERY].charging))
+ {
+ ref_bat = LEFT_BATTERY;
+
+ sprintf(buf, "Battery level : left charging");
+ }
+ else if ((sys_pmu.b[RIGHT_BATTERY].charging) && !(sys_pmu.b[LEFT_BATTERY].charging))
+ {
+ ref_bat = RIGHT_BATTERY;
+
+ sprintf(buf, "Battery level : right charging");
+ }
+ else
+ {
+ if (sys_pmu.b[LEFT_BATTERY].percentage > sys_pmu.b[RIGHT_BATTERY].percentage)
+ ref_bat = RIGHT_BATTERY;
+ else
+ ref_bat = LEFT_BATTERY;
+
+ if (sys_pmu.b[LEFT_BATTERY].charging)
+ sprintf(buf, "Battery level : both charging");
+ else
+ sprintf(buf, "Battery level :");
+ }
+
+ if (sys_pmu.b[ref_bat].available == NO_BATT)
+ {
+ ref_bat = (ref_bat == LEFT_BATTERY) ? RIGHT_BATTERY : LEFT_BATTERY;
+ }
+
+
+ if (sys_pmu.b[ref_bat].charging)
+ {
+ xosd_set_colour(gui.osd, "Red");
+ osd_freq = 15 * 60; /* 15 minutes */
+ }
+ else
+ {
+ if (sys_pmu.b[ref_bat].percentage > 70)
+ {
+ xosd_set_colour(gui.osd, "Green");
+ osd_freq = 15 * 60;
+ }
+ else if (sys_pmu.b[ref_bat].percentage > 25)
+ {
+ xosd_set_colour(gui.osd, "Yellow");
+ osd_freq = 10 * 60;
+ }
+ else if (sys_pmu.b[ref_bat].percentage > 5)
+ {
+ xosd_set_colour(gui.osd, "Red");
+ osd_freq = 5 * 60;
+ }
+ else
+ {
+ xosd_set_colour(gui.osd, "Red");
+ osd_freq = 30;
+ }
+ }
+
+ xosd_display(gui.osd, 0, XOSD_string, buf);
+
+ if (sys_pmu.b[LEFT_BATTERY].available == IS_BATT)
+ xosd_display(gui.osd, 1, XOSD_percentage, sys_pmu.b[LEFT_BATTERY].percentage);
+
+ if (sys_pmu.b[RIGHT_BATTERY].available == IS_BATT)
+ xosd_display(gui.osd, 2, XOSD_percentage, sys_pmu.b[RIGHT_BATTERY].percentage);
+
+ /* return next osd timestamp */
+ return (time(NULL) + osd_freq);
+}
+#endif /* ENABLE_XOSD */
+
+
+/*
+ * Display battery state to a TTY, with colors
+ */
+void DisplayTTY (void)
+{
+ int i;
+
+ /* ac connected ? */
+
+ if (sys_pmu.ac_connected)
+ fprintf(stdout, "%sP", BWHITE);
+ else
+ fprintf(stdout, "%s-", BWHITE);
+
+ /* charging ? */
+
+ if (sys_pmu.b[0].charging)
+ fprintf(stdout, "C");
+ else
+ fprintf(stdout, "-");
+
+ /* verify the state of the battery, colors as required */
+
+ for (i = 0; i < 2; i++)
+ {
+ if (sys_pmu.b[i].available == NO_BATT)
+ fprintf(stdout, " %s--%%", BRED);
+ else
+ {
+ if (sys_pmu.b[i].percentage > 70)
+ fprintf(stdout, "%s", BGREEN);
+ else if (sys_pmu.b[i].percentage > 25)
+ fprintf(stdout, "%s", BYELLOW);
+ else
+ fprintf(stdout, "%s", BRED);
+
+ if (sys_pmu.b[i].percentage < 100)
+ fprintf(stdout, " %02d%%", sys_pmu.b[i].percentage);
+ else
+ fprintf(stdout, " %d%%", sys_pmu.b[i].percentage);
+ }
+ }
+
+ fprintf(stdout, "%s", BWHITE);
+
+ /* time left */
+
+ fprintf(stdout, " %02d:%02d", sys_pmu.time_left / 60, (sys_pmu.time_left % 60 < 0) ? 0 : sys_pmu.time_left % 60);
+
+ fprintf(stdout, "%s\n", BRESET);
+}
+
+
/* SIGCHLD handler */
-void sig_chld(int signo)
+void sig_chld (int signo)
{
waitpid((pid_t) -1, NULL, WNOHANG);
signal(SIGCHLD, sig_chld);
}
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
int i;
-
- /* Parse Command Line */
-
+ wm_info wm;
+ char *progname;
+#ifdef ENABLE_XOSD
+ int osd = 1; /* OSD activated by default */
+#endif /* ENABLE_XOSD */
+
+ /* init */
+ sys_pmu.pmud_domain = PF_INET;
+ strcpy(sys_pmu.socket_path, PMUD_SOCKET_PATH);
+
+ sys_pmu.update_rate = UPDATE_RATE;
+ sys_pmu.read_pmu = read_pmu_proc;
+
+ xpm.offset.x = 0;
+ xpm.offset.y = 0;
+
signal(SIGCHLD, sig_chld);
- ProgName = argv[0];
- if (strlen(ProgName) >= 5)
- ProgName += (strlen(ProgName) - 5);
+
+ /* Parse Command Line */
+
+ progname = argv[0];
+ if (strlen(progname) > 8)
+ progname += (strlen(progname) - 8);
for (i=1; i<argc; i++) {
char *arg = argv[i];
@@ -447,16 +875,42 @@ int main(int argc, char *argv[]) {
break;
case 'r':
if (argc > (i+1)) {
- update_rate = (atoi(argv[i+1]) * 1000);
+ sys_pmu.update_rate = (atoi(argv[i+1]) * 1000);
i++;
}
break;
+ case 'u':
+ sys_pmu.pmud_domain = PF_UNIX;
+ sys_pmu.read_pmu = read_pmu_socket;
+ if ((argc > (i+1)) && (argv[i+1][0] != '-'))
+ {
+ i++;
+ if (strlen(argv[i]) > UNIX_PATH_MAX)
+ {
+ fprintf(stderr, "%s: UNIX socket path too long!\n", progname);
+ exit(1);
+ }
+ else
+ {
+ strcpy(sys_pmu.socket_path, argv[i]);
+ }
+ }
+ break;
+ case 't':
+ sys_pmu.pmud_domain = PF_INET;
+ sys_pmu.read_pmu = read_pmu_socket;
+ break;
case 'w':
- wm = WMAKER ;
+ wm.type = WMAKER;
break;
case 'x':
- wm = XIMIAN ;
+ wm.type = XIMIAN;
+ break;
+#ifdef ENABLE_XOSD
+ case 'o':
+ osd = 0;
break;
+#endif /* ENABLE_XOSD */
default:
usage();
exit(0);
@@ -464,162 +918,274 @@ int main(int argc, char *argv[]) {
}
}
}
-
- wmbatppc_routine(argc, argv);
-
+
+ switch (wm.type)
+ {
+ case XIMIAN:
+ wm.width = 176;
+ wm.height = 24;
+ wm.xpm = xgbatppc_master_xpm;
+ break;
+ case WMAKER:
+ default:
+ wm.type = WMAKER;
+ wm.width = 64;
+ wm.height = 64;
+ wm.xpm = wmbatppc_master_xpm;
+ break;
+ }
+
+ /*
+ * If argv[0] is "wmbatppc", then user wants the WMaker dockapp ;
+ * if it is "batppc", then he wants TTY output
+ */
+
+ /* use 6 in case argv[0] is only "batppc" */
+ if (strncmp(progname, "wmbatppc", 6) != 0)
+ {
+ /* do tty output */
+ sys_pmu.show_charge_time = 1;
+
+ sys_pmu.read_pmu();
+
+ DisplayTTY();
+ }
+ else
+ {
+#ifdef ENABLE_XOSD
+ /*
+ * 1 line of text
+ * 1 line for the left battery
+ * 1 line for the right battery
+ */
+ if (osd)
+ {
+ gui.osd = xosd_create(3);
+ }
+
+ if ((osd) && (gui.osd == NULL))
+ {
+ fprintf(stderr, "%s: OSD disabled after error (%s)\n", progname, xosd_error);
+ }
+ else
+ {
+ xosd_set_font(gui.osd, "-adobe-helvetica-bold-r-*-*-14-*"); /* "-misc-fixed-medium-r-semicondensed-*-14-*-*-*-c-*-*-*"); */
+ xosd_set_timeout(gui.osd, 5);
+ xosd_set_shadow_offset(gui.osd, 2);
+ xosd_set_vertical_offset(gui.osd, 10);
+ xosd_set_horizontal_offset(gui.osd, 10);
+ }
+#endif /* ENABLE_XOSD */
+
+ wmbatppc_routine(argc, argv, &wm);
+
+#ifdef ENABLE_XOSD
+ if (gui.osd != NULL)
+ {
+ xosd_destroy(gui.osd);
+ gui.osd = NULL;
+ }
+#endif /* ENABLE_XOSD */
+ }
+
return 0;
}
/*
* Main loop
*/
-void wmbatppc_routine(int argc, char **argv) {
+void wmbatppc_routine (int argc, char **argv, wm_info *wm)
+{
+#ifdef ENABLE_XOSD
+ time_t curtime;
+ time_t next_osd = 0;
+#endif /* ENABLE_XOSD */
XEvent Event;
- struct timeval tv={0,0};
- struct timeval last={0,0};
+ char *mask_bits;
int i ;
-
- if (wm == WMAKER){
- printf("window maker version \n");
- createXBMfromXPM(wmbatppc_mask_bits, wmbatppc_master_xpm, wmbatppc_mask_width, wmbatppc_mask_height);
- openXwindow(argc, argv, wmbatppc_master_xpm, wmbatppc_mask_bits, wmbatppc_mask_width, wmbatppc_mask_height);
- } else {
- printf("ximian gnome version \n");
- createXBMfromXPM(xgbatppc_mask_bits, xgbatppc_master_xpm, xgbatppc_mask_width, xgbatppc_mask_height);
- openXwindow(argc, argv, xgbatppc_master_xpm, xgbatppc_mask_bits, xgbatppc_mask_width, xgbatppc_mask_height);
- }
- RedrawWindow();
+ mask_bits = malloc(wm->width * wm->height * sizeof(char));
- initGUIelements () ;
+ if (mask_bits == NULL)
+ {
+ fprintf(stderr, "%s: cannot allocate memory !\n", argv[0]);
+ return;
+ }
- if (wm == WMAKER){
- for (i=0;i<10;i++){
- drawJukeBox(i) ;
- updatePlug(UNPLUGGED) ;
- updateCharg(NOCHARGE) ;
- RedrawWindow() ;
- usleep(100000) ;
- }
- for (i=9;i>=0;i--){
- drawJukeBox(i) ;
- updatePlug(UNPLUGGED) ;
- updateCharg(NOCHARGE) ;
- RedrawWindow() ;
- usleep(100000) ;
- }
- }
-
+ createXBMfromXPM(mask_bits, wm->xpm, wm->width, wm->height);
+ openXwindow(argc, argv, wm->xpm, mask_bits, wm->width, wm->height);
+
+ free(mask_bits);
+
+ RedrawWindow();
- while (1) {
-
- curtime = time(0);
-
- if (1) {
- memcpy(&last, &tv, sizeof(tv));
-
+ initGUIelements(wm);
+
+ if (wm->type == WMAKER)
+ {
+ for (i = 0; i < 10; i++)
+ {
+ drawJukeBox(i);
+ updatePlug(UNPLUGGED);
+ updateCharg(NOCHARGE);
+ RedrawWindow();
+ usleep(100000);
+ }
+ for (i = 9; i >= 0; i--)
+ {
+ drawJukeBox(i);
+ updatePlug(UNPLUGGED);
+ updateCharg(NOCHARGE);
+ RedrawWindow();
+ usleep(100000);
+ }
+ }
+
+ while (1)
+ {
/*
* Update display
*/
-
+
DisplayBat();
RedrawWindow();
- }
+
+#ifdef ENABLE_XOSD
+ curtime = time(NULL);
+
+ if ((gui.osd != NULL) &&
+ ((curtime >= next_osd) || (next_osd == 0)))
+ next_osd = DisplayOSD();
+#endif /* ENABLE_XOSD */
- /*
- * X Events
- */
- while (XPending(display)) {
- XNextEvent(display, &Event);
- switch (Event.type) {
- case Expose:
- RedrawWindow();
- break;
- case DestroyNotify:
- XCloseDisplay(display);
- exit(0);
- case ButtonPress:
- switch (screen) {
- case 0: screen=1; break;
- case 1: screen=0; break;
- };
- break;
- }
+ /*
+ * X Events
+ */
+ while (XPending(display))
+ {
+ XNextEvent(display, &Event);
+ switch (Event.type)
+ {
+ case Expose:
+ RedrawWindow();
+ break;
+ case DestroyNotify:
+ XCloseDisplay(display);
+ exit(0);
+ case ButtonPress:
+#ifdef ENABLE_XOSD
+ DisplayOSD();
+#endif /* ENABLE_XOSD */
+ break;
+ }
+ }
+
+ usleep(sys_pmu.update_rate);
}
-
- usleep(update_rate);
- }
}
/*
* Blits a string at given co-ordinates
*/
-void BlitString(char *name, int x, int y, int is_big) {
- int i;
- int c;
- int k;
-
+void BlitString (char *name, int x, int y, int is_big)
+{
+ int i;
+ int c;
+ int k;
+
k = x;
- for (i=0; name[i]; i++){
- c = toupper(name[i]);
- if (c >= 'A' && c <= 'Z'){ // its a letter
- c -= 'A';
- copyXPMArea(c * 6, 74+YOFFSET, 6, 8, k, y);
- k += 6;
- } else {
- if (c>='0' && c<='9'){ // its a number or symbol
- c -= '0';
- if (is_big == BIG){
- copyXPMArea(68 + c * 7 , 22+YOFFSET, 7, 10, k, y);
- k += 7 ;
- } else {
- copyXPMArea(c * 6, 64+YOFFSET, 6, 8, k, y);
- k += 6;
- }
- } else {
- copyXPMArea(1, 84+YOFFSET, 6, 8, k, y);
- k += 6;
- }
+ for (i=0; name[i]; i++)
+ {
+ c = toupper(name[i]);
+ if (c >= 'A' && c <= 'Z') /* its a letter */
+ {
+ c -= 'A';
+ copyXPMArea(c * 6, 74+xpm.offset.y, 6, 8, k, y);
+ k += 6;
+ }
+ else
+ {
+ if (c>='0' && c<='9') /* its a number or symbol */
+ {
+ c -= '0';
+ if (is_big == BIG)
+ {
+ copyXPMArea(68 + c * 7 , 22+xpm.offset.y, 7, 10, k, y);
+ k += 7 ;
+ }
+ else
+ {
+ copyXPMArea(c * 6, 64+xpm.offset.y, 6, 8, k, y);
+ k += 6;
+ }
+ }
+ else
+ {
+ copyXPMArea(1, 84+xpm.offset.y, 6, 8, k, y);
+ k += 6;
+ }
}
- }
+ }
}
-void BlitNum(int num, int x, int y, int is_big, int two_digits) {
+void BlitNum (int num, int x, int y, int is_big, int two_digits)
+{
char buf[1024];
int newx=x;
int temp=0 ;
-
+
if (two_digits == 1)
- sprintf(buf, "%02i", num);
- else {
- if (two_digits == 2) {
- temp = num - 100 ;
- copyXPMArea(10, 64+YOFFSET, 2, 8, x+4, y); /* print the hundreds unit */
- newx = x + 6 ;
- sprintf(buf, "%02i", temp);
- } else {
- sprintf(buf, "%03i", num);
- }
- }
+ sprintf(buf, "%02i", num);
+ else
+ {
+ if (two_digits == 2)
+ {
+ temp = num - 100;
+ copyXPMArea(10, 64+xpm.offset.y, 2, 8, x+4, y); /* print the hundreds unit */
+ newx = x + 6;
+ sprintf(buf, "%02i", temp);
+ }
+ else
+ {
+ sprintf(buf, "%03i", num);
+ }
+ }
BlitString(buf, newx, y, is_big);
}
/*
* Usage
*/
-void usage(void) {
- fprintf(stderr, "\nwmbatppc - Lou <titelou at free.fr> http://titelou.free.fr\n\n");
- fprintf(stderr, "usage:\n");
+void usage (void)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "wmbatppc %s - Lou <titelou at free.fr> http://titelou.free.fr\n", WMBATPPC_VERSION);
+ fprintf(stderr, " Julien BLACHE <jb at jblache.org>\n\n");
+ fprintf(stderr, "Usage:\n");
fprintf(stderr, " -display <display name>\n");
- fprintf(stderr, " -r update rate in milliseconds (default:100)\n");
+ fprintf(stderr, " -geometry <X11 geometry string>\n");
+ fprintf(stderr, " -r update rate in milliseconds (default:100)\n");
+ fprintf(stderr, " -w WindowMaker/AfterStep GUI\n");
+#ifdef ENABLE_XOSD
+ fprintf(stderr, " -o disable On-Screen Display\n");
+#endif /* ENABLE_XOSD */
+ fprintf(stderr, " -x swallowed application GUI (for GNOME Panel)\n");
+ fprintf(stderr, " -t use pmud on TCP port 879\n");
+ fprintf(stderr, " -u [PATH] use pmud via UNIX domain socket\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "When invoked as \'batppc\', a line similar to the following is\n");
+ fprintf(stderr, "printed on the console :\n");
+ fprintf(stderr, " PC 100%% 80%% 01:20\n");
+ fprintf(stderr, "See man batppc for details about this output.\n");
fprintf(stderr, "\n");
}
/*
* printversion
*/
-void printversion(void) {
+void printversion (void)
+{
fprintf(stderr, "wmbatppc v%s\n", WMBATPPC_VERSION);
}
diff --git a/wmbatppc.h b/wmbatppc.h
index 9c583d4..7a248c8 100644
--- a/wmbatppc.h
+++ b/wmbatppc.h
@@ -1,124 +1,176 @@
/*
* Revision 0.2 24 Nov 2000 Lou
*
+ * $Id: wmbatppc.h 32 2004-10-13 17:43:38Z julien $
*/
+#ifndef __WMBATPPC_H__
+#define __WMBATPPC_H__
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <dirent.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <math.h>
-#include <limits.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
#include <sys/socket.h>
+#include <sys/un.h>
-#include <netinet/in.h>
-#include <netdb.h>
+#ifdef ENABLE_XOSD
+# include <xosd.h>
+#endif /* ENABLE_XOSD */
-#include <X11/Xlib.h>
-#include <X11/xpm.h>
-#include <X11/extensions/shape.h>
+/* Should be defined in <sys/un.h> ... */
+#ifndef UNIX_PATH_MAX
+# define UNIX_PATH_MAX 108
+#endif
-#define WMBATPPC_VERSION "0.1"
+#define WMBATPPC_VERSION "2.5"
-#define LEFT_BATTERY 0
-#define RIGHT_BATTERY 1
+#define LEFT_BATTERY 0
+#define RIGHT_BATTERY 1
-#define HIGH_BATT 0 // color green
-#define LOW_BATT 1 // color red
-#define MED_BATT 2 // color yellow
+#define HIGH_BATT 0 // color green
+#define LOW_BATT 1 // color red
+#define MED_BATT 2 // color yellow
-#define NO_BATT 3
-#define IS_BATT 4
+#define NO_BATT 3
+#define IS_BATT 4
-#define NOCHARGE 0
-#define CHARGE 1
-#define UNPLUGGED 0
-#define PLUGGED 1
+#define NOCHARGE 0
+#define CHARGE 1
+#define UNPLUGGED 0
+#define PLUGGED 1
-#define LIMITED 0
-#define INFINITE 1
+#define LIMITED 0
+#define INFINITE 1
-#define SMALL 0
-#define BIG 1
+#define SMALL 0
+#define BIG 1
-#define HOURS 0
-#define MINUTES 1
+#define HOURS 0
+#define MINUTES 1
-#define V 0
-#define MV 1
+#define V 0
+#define MV 1
-#define COMMA 0
-#define PERCENT 1
+#define COMMA 0
+#define PERCENT 1
-#define WMAKER 10
-#define XIMIAN 20
+#define WMAKER 10
+#define XIMIAN 20
-#define PMU_VERSION_KEYLARGO 12
+#define PMU_VERSION_KEYLARGO 12
-#define PMU_CONFIG_KEYWORD "pmu"
-#define PMU_STYLE_NAME "pmu"
+#define PMU_CONFIG_KEYWORD "pmu"
+#define PMU_STYLE_NAME "pmu"
-#define PMUD_INPUT_DELIM " \t\n{}"
+#define PMU_PROC_INFO "/proc/pmu/info"
+#define PMU_PROC_BATTERY_BASE "/proc/pmu/battery_"
+#define PMU_PROC_PRESENT (1 << 0)
+#define PMU_PROC_CHARGING (1 << 1)
-#define PMUD_HOST "localhost"
-#define PMUD_PORT 879
-#define PMUD_SERVICE "pmud"
+#define PMUD_INPUT_DELIM " \t\n{}"
-#define PMUD_REFRESH
+#define PMUD_HOST "localhost"
+#define PMUD_PORT 879
+#define PMUD_SERVICE "pmud"
+#define PMUD_SOCKET_PATH "/etc/power/control"
+/*
+ * Uncomment the following line to wait for pmud to refresh battery
+ * information, otherwise we update every 100 milliseconds
+ */
+//#define PMUD_REFRESH
+#define UPDATE_RATE 100000
-typedef struct {
- int available;
- int current;
- int percentage;
- int charging;
- int voltage;
-} battery ;
-
-typedef struct {
- int pmud_version ;
- battery b [2] ;
- int batt_state [2] ;
- int time_left ;
- int ac_connected ;
- int show_charge_time ;
- int current ;
-} pmud_info ;
-
-typedef struct {
- int x ;
- int y ;
-} coords ;
-
-typedef struct {
- coords plug ;
- coords charg ;
- coords timeleft[2] ;
- coords voltage[2] ;
- coords batt[2] ;
- coords percent[2] ;
- coords jukeBox[2] ;
- coords symbols[2] ;
-} interface ;
+/*
+ * Colors for TTY output
+ */
+#define BWHITE "\e[1;37m"
+#define BRED "\e[1;31m"
+#define BYELLOW "\e[1;33m"
+#define BGREEN "\e[1;32m"
+#define BRESET "\e[0m"
+
+typedef struct
+{
+ int available;
+ int state;
+ int current;
+ int percentage;
+ int charging;
+ int voltage;
+} battery;
+
+typedef struct
+{
+ int pmud_domain;
+ char socket_path[UNIX_PATH_MAX];
+ int update_rate;
+ void (*read_pmu) (void);
+ int pmud_version;
+ battery b[2];
+ int time_left;
+ int ac_connected;
+ int show_charge_time;
+ int current;
+} pmud_info;
+
+typedef struct
+{
+ int x;
+ int y;
+} coords;
+
+typedef struct
+{
+ coords plug;
+ coords charg;
+ coords timeleft[2];
+ coords voltage[2];
+ coords batt[2];
+ coords percent[2];
+ int jukeBoxParts;
+ coords jukeBox[2];
+ coords jukeBoxSize[2];
+ coords symbols[2];
+#ifdef ENABLE_XOSD
+ xosd *osd;
+#endif /* ENABLE_XOSD */
+} gui_info;
+
+typedef struct
+{
+ coords offset;
+ coords jukeBoxImg[12];
+ coords plugImg[2];
+ coords chargImg[2];
+ coords battImg[8];
+ coords plugSize;
+ coords chargSize;
+ coords battSize;
+ coords voltIndSize;
+ coords voltIndImg;
+ coords timeleftIndSize;
+ coords timeleftIndImg;
+} gui_xpm;
+
+typedef struct
+{
+ int type;
+ int width;
+ int height;
+ char **xpm;
+} wm_info;
+
+typedef enum
+{
+ KL_IBOOK,
+ KL_PISMO,
+ KL_UNKNOWN
+} mactype;
void usage(void);
void printversion(void);
void BlitString(char *name, int x, int y, int is_big);
void BlitNum(int num, int x, int y, int is_big, int two_digits);
-void wmbatppc_routine(int, char **);
+void wmbatppc_routine(int argc, char **argv, wm_info *wm);
+
+#endif /* !__WMBATPPC_H__ */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbatppc.git
More information about the Pkg-wmaker-commits
mailing list