From: Benjamin Stürz Subject: Re: [new/wip] sysutils/apmtop To: Omar Polo Cc: James Cook , ports@openbsd.org Date: Thu, 11 Jan 2024 22:01:21 +0100 Hi, thanks for the contributions. I have attached a new version of the port. On 1/11/24 11:14, Omar Polo wrote: > Hello, > > Well, the port actually looks good, even if a manpage (or at least > installing the README) would be useful :) apmtop(1) now has a man page. It's still quite bare bones, but so is apmtop itself. > > 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 looks like ksmn(4) is actually a CPU temperature sensor. But why isn't it called 'hw.sensors.cpu0.temp0' then? > > 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 :) Thanks, I'll continue improving it, once I'm done studying for my exams :) > > I got a bit annoyed by the screen flashes at each update and gave it a > try at improving it, see diff below. Thanks, I wasn't able to solve it on my own. But I did solve the wrong-temperature-bug. It was a simple conversion mistake. > >> 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 >