Hello,

On 2024/01/06 03:42:44 +0100, Benjamin Stürz <benni+open...@stuerz.xyz> wrote:
> On 1/5/24 19:33, James Cook wrote:
> > On Thu, Jan 04, 2024 at 10:24:18PM +0100, Benjamin Stürz wrote:
> >> Hi ports@,
> >>
> >> this is my next little project, after sysutils/lsblk.
> >>
> >> apmtop is a simple utility for measuring power consumption
> >> and statistics related to it, in a little TUI interface.
> >> There is still some work to do, but I wanted to see
> >> if anyone would be interested in using/testing this project.
> >>
> >> Obviously, this is not (yet) commit-ready, so:
> >> Comments and Suggestions are _very_ welcome!
> >>
> >> WWW: https://got.stuerz.xyz/?action=summary&path=apmtop.git
> >>
> >> PS:
> >> The keybindings are in the README.md, until I write a man page.
> >>
> >> Happy new year,
> >> Benjamin Stürz

Well, the port actually looks good, even if a manpage (or at least
installing the README) would be useful :)

I tried it on my desktop and I can say it seems to mostly work.  It
report the cpu temperature as -1 C which I assume means 'not available'.
There is actually one sensor on this machine that reports a temperature,
but since it doesn't contain the "cpu" string in its name it gets
skipped.

        % sysctl -a | grep degC
        hw.sensors.ksmn0.temp0=25.25 degC (Tctl)

it also reports the power as 0, but I guess it's just a metric not
available on my handware.

(BAT is obviously 0 for me too, but it's a desktop)

> > [...]
> > Nice utility! Don't know if I'll use it since I like to squeeze such 
> > things into my status bar, but maybe I can learn from it. One annoyance: 
> > xterm flashes on every update as the TUI is redrawn, which is 
> > distracting when I'm trying to look at something else.

I agree, it's a nice little utility :)

I got a bit annoyed by the screen flashes at each update and gave it a
try at improving it, see diff below.

> I too put these things into my status bar,
> but I wanted to have a nice graph,
> to make optimizing battery life a little easier.

Index: apmtop.c
--- apmtop.c.orig
+++ apmtop.c
@@ -259,7 +259,7 @@ draw_graph (struct graph *g, const char *fmt, int min,
        w -= 2;
        h -= 3;
 
-       wclear (g->win);
+       werase (g->win);
 
        for (int i = 0; i < entries; ++i) {
                int v = g->log[i];
@@ -287,7 +287,7 @@ draw_graph (struct graph *g, const char *fmt, int min,
 static void
 draw (struct display *dpy)
 {
-       clear ();
+       erase ();
 
        draw_graph (&dpy->g[G_CPUUSAGE],        "CPU: %d%%",    0, 100);
        draw_graph (&dpy->g[G_CPUTEMP],         "CPU: %d C",    0, 100);
@@ -302,12 +302,10 @@ draw (struct display *dpy)
 
        printw (" %c delay=%d", dpy->running ? 'R' : 'S', dpy->delay);
 
-       refresh ();
+       wnoutrefresh (stdscr);
        for (int i = 0; i < NGRAPH; ++i)
                wnoutrefresh (dpy->g[i].win);
        doupdate ();
-       move (0, 0);
-
 }
 
 static void

Reply via email to