Hi,

  I discovered that sysutils/conky (1.9.0) does not detect battery/AC
status on OpenBSD andn therefore does not change the update_interval
accordingly. The original code that was in there looked like it was for
Linux (and possibly FreeBSD but I think FreeBSD uses apm like OpenBSD does
correct me if I'm wrong?)

  I've patched conky.c so that it uses get_apm_adapter() to find out the
status and switch update_interval accordingly.

  I am aware there's a newer version of conky out (1.10) but I wanted to fix
conky draining my battery when the AC wasn't plugged in. I know I could just
set update_interval to 5 seconds, but this seemed more in line with how you
would expect conky to behave.

  Thoughts? Suggestions?

  Thanks,
  Tom
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/conky/Makefile,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 Makefile
--- Makefile    1 Jun 2018 14:24:55 -0000       1.54
+++ Makefile    19 Sep 2018 20:18:50 -0000
@@ -7,7 +7,7 @@ COMMENT=        light-weight system monitor
 DISTNAME=      conky-1.9.0
 CATEGORIES=    sysutils
 HOMEPAGE=      http://conky.sourceforge.net/
-REVISION=      15
+REVISION=      16
 
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE:=conky/}
 
Index: patches/patch-src_conky_c
===================================================================
RCS file: /cvs/ports/sysutils/conky/patches/patch-src_conky_c,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 patch-src_conky_c
--- patches/patch-src_conky_c   31 Dec 2012 09:36:38 -0000      1.6
+++ patches/patch-src_conky_c   19 Sep 2018 20:18:51 -0000
@@ -1,6 +1,11 @@
 $OpenBSD: patch-src_conky_c,v 1.6 2012/12/31 09:36:38 chrisz Exp $
---- src/conky.c.orig   Thu May  3 23:22:21 2012
-+++ src/conky.c        Tue Jul 24 18:10:39 2012
+
+Correctly change update_interval based on whether AC is plugged in
+or on battery for OpenBSD.
+
+Index: src/conky.c
+--- src/conky.c.orig
++++ src/conky.c
 @@ -125,7 +125,7 @@
  
  /* FIXME: apm_getinfo is unused here. maybe it's meant for common.c */
@@ -39,17 +44,26 @@ $OpenBSD: patch-src_conky_c,v 1.6 2012/1
                        OBJ(apm_adapter) {
                                char *msg;
  
-@@ -3496,12 +3492,14 @@ static void main_loop(void)
+@@ -3494,14 +3490,22 @@ static void main_loop(void)
+       info.looped = 0;
+       while (terminate == 0 && (total_run_times == 0 || info.looped < 
total_run_times)) {
                if(update_interval_bat != NOBATTERY && update_interval_bat != 
update_interval_old) {
-                       char buf[max_user_text];
+-                      char buf[max_user_text];
  
 +#ifndef __OpenBSD__
++                      char buf[max_user_text];
                        get_battery_short_status(buf, max_user_text, "BAT0");
                        if(buf[0] == 'D') {
                                update_interval = update_interval_bat;
                        } else {
                                update_interval = update_interval_old;
                        }
++#else
++            if (strcmp(get_apm_adapter(),"off-line") == 0) {
++                              update_interval = update_interval_bat;
++                  } else {
++                              update_interval = update_interval_old;
++                  }
 +#endif
                }
                info.looped++;

Reply via email to