Re: sysutils/xbattbar patch to add time & date display

2012-04-04 Thread Daniel Bolgheroni
On Tue, Apr 03, 2012 at 07:28:28PM -0400, Brynet wrote:
>
> If anyone has a laptop, you might want to check out xbattbar, it isn't
> nearly as invasive as some other battery monitoring utilities. Alex's
> addition doesn't change that.

BTW, it "breaks" xlock if used with -a option.



Re: sysutils/xbattbar patch to add time & date display

2012-04-04 Thread Daniel Bolgheroni
On Tue, Apr 03, 2012 at 07:28:28PM -0400, Brynet wrote:
>
> If anyone has a laptop, you might want to check out xbattbar, it isn't
> nearly as invasive as some other battery monitoring utilities. Alex's
> addition doesn't change that.

Didn't know about it. Using.

Thank you.



Re: sysutils/xbattbar patch to add time & date display

2012-04-03 Thread Brynet
On Wed, Apr 04, 2012 at 12:06:09AM +0400, Alexander Polakov wrote:
> Brynet (maintainer) suggested to send this to ports@.
> 
> This patch adds an option (-T) to display time and date in
> xbattbar's popup window.
> Personally, I find this very useful: I don't have to run any
> other panel anymore. While there, I added headers to fix some
> of the the warnings. Not sure if it's okay to add functionality
> like this to ports, though, but upstream is not responding to
> mails.

Upstream hasn't released an update since 2000/2001.

If anyone has a laptop, you might want to check out xbattbar, it isn't
nearly as invasive as some other battery monitoring utilities. Alex's
addition doesn't change that.

It fits well with cwm.

> Any comments, oks?

-Bryan.



sysutils/xbattbar patch to add time & date display

2012-04-03 Thread Alexander Polakov
Brynet (maintainer) suggested to send this to ports@.

This patch adds an option (-T) to display time and date in
xbattbar's popup window.
Personally, I find this very useful: I don't have to run any
other panel anymore. While there, I added headers to fix some
of the the warnings. Not sure if it's okay to add functionality
like this to ports, though, but upstream is not responding to
mails.

The man page diff is especially bad, sorry for that.

Any comments, oks?

Index: Makefile
===
RCS file: /cvs/ports/sysutils/xbattbar/Makefile,v
retrieving revision 1.2
diff -u -p -u -r1.2 Makefile
--- Makefile22 May 2011 13:44:47 -  1.2
+++ Makefile3 Apr 2012 19:53:21 -
@@ -6,6 +6,7 @@ COMMENT =   show battery status as a simpl
 
 DISTNAME = xbattbar_1.4.2
 PKGNAME =  ${DISTNAME:S/_/-/}
+REVISION = 0
 WRKDIST =  ${WRKDIR}/${DISTNAME:S/_/-/}
 CATEGORIES =   sysutils x11
 
Index: patches/patch-xbattbar_c
===
RCS file: /cvs/ports/sysutils/xbattbar/patches/patch-xbattbar_c,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 patch-xbattbar_c
--- patches/patch-xbattbar_c22 May 2011 12:32:41 -  1.1.1.1
+++ patches/patch-xbattbar_c3 Apr 2012 19:53:21 -
@@ -1,7 +1,101 @@
-$OpenBSD: patch-xbattbar_c,v 1.1.1.1 2011/05/22 12:32:41 schwarze Exp $
 xbattbar.c.origTue May 17 12:29:19 2011
-+++ xbattbar.c Tue May 17 12:32:20 2011
-@@ -575,7 +575,7 @@ void battery_check(void)
+$OpenBSD$
+--- xbattbar.c.origTue Apr  3 23:30:11 2012
 xbattbar.c Tue Apr  3 23:30:17 2012
+@@ -29,6 +29,9 @@ static char *ReleaseVersion="1.4.2";
+ #include 
+ #include 
+ #include 
++#include 
++#include 
++#include 
+ #include 
+ #include 
+ #include 
+@@ -67,6 +70,8 @@ char *ONOUT_C  = "olive drab";
+ char *OFFIN_C  = "blue";
+ char *OFFOUT_C = "red";
+ 
++char *clockfmt = "%+";
++int displayclock = False;
+ int alwaysontop = False;
+ 
+ struct itimerval IntervalTimer; /* APM polling interval timer */
+@@ -118,7 +123,7 @@ void usage(char **argv)
+   fprintf(stderr,
+ "\n"
+ "usage:\t%s [-a] [-h|v] [-p sec] [-t thickness]\n"
+-"\t\t[-I color] [-O color] [-i color] [-o color]\n"
++"\t\t[-I color] [-O color] [-i color] [-o color] [-T time-format]\n"
+ "\t\t[ top | bottom | left | right ]\n"
+ "-a: always on top.\n"
+ "-v, -h: show this message.\n"
+@@ -126,6 +131,7 @@ void usage(char **argv)
+ "-p: polling interval. [def: 10 sec.]\n"
+ "-I, -O: bar colors in AC on-line. [def: \"green\" & \"olive drab\"]\n"
+ "-i, -o: bar colors in AC off-line. [def: \"blue\" and \"red\"]\n"
++"-T: show time in popup window. [def: %%+]\n"
+ "top, bottom, left, right: bar localtion. [def: \"bottom\"]\n",
+ argv[0]);
+   exit(0);
+@@ -223,7 +229,7 @@ main(int argc, char **argv)
+   int ch;
+ 
+   about_this_program();
+-  while ((ch = getopt(argc, argv, "at:f:hI:i:O:o:p:v")) != -1)
++  while ((ch = getopt(argc, argv, "at:f:hI:i:O:o:p:T::v")) != -1)
+ switch (ch) {
+ case 'a':
+   alwaysontop = True;
+@@ -251,6 +257,12 @@ main(int argc, char **argv)
+   bi_interval = atoi(optarg);
+   break;
+ 
++case 'T':
++  if (optarg)
++clockfmt = optarg;
++  displayclock = 1;
++  break;
++
+ case 'h':
+ case 'v':
+   usage(argv);
+@@ -339,7 +351,14 @@ void showdiagbox(void)
+   int pixw, pixh;
+   int boxw, boxh;
+   char diagmsg[64];
++  char timemsg[64];
++  time_t now;
+ 
++  /* compose time and date message */
++  if (displayclock) {
++time(&now);
++strftime(timemsg, 64, clockfmt, localtime(&now));
++  }
+   /* compose diag message and calculate its size in pixels */
+   sprintf(diagmsg,
+  "AC %s-line: battery level is %d%%",
+@@ -349,6 +368,8 @@ void showdiagbox(void)
+   pixh = fontp->ascent + fontp->descent;
+   boxw = pixw + DiagXMergin * 2;
+   boxh = pixh + DiagYMergin * 2;
++  if (displayclock)
++boxh += pixh + DiagYMergin;
+ 
+   /* create status window */
+   if(winstat != -1) disposediagbox();
+@@ -367,6 +388,11 @@ void showdiagbox(void)
+  gcstat,
+  DiagXMergin, fontp->ascent+DiagYMergin,
+  diagmsg, strlen(diagmsg));
++  if (displayclock)
++XDrawString(disp, winstat, gcstat,
++   boxw/2 - XTextWidth(fontp, timemsg, strlen(timemsg))/2,
++   2*fontp->ascent+2*DiagYMergin,
++   timemsg, strlen(timemsg));
+ }
+ 
+ void disposediagbox(void)
+@@ -575,7 +601,7 @@ void battery_check(void)
  
  #endif /* __FreeBSD__ */
  
Index: patches/patch-xbattbar_man
===
RCS file: patches/patch-xbattbar_man
diff -N patches/patch-xbattbar_man
--- /dev/null   1 Jan 1970 00:00:00 -
+++ patches/patch-xbattbar_man  3 Apr 2012 19:53:21 -
@@ -0,0 +1,21 @@
+$OpenBSD$
+--- xbattbar.man.orig  Tue Apr