Conky: [FreeBSD] allow sysctl calls

Created on 30 Oct 2017  路  13Comments  路  Source: brndnmtthws/conky

I think it would be useful a built-in solution to query sysctl values - not only _exec*_ commands.

enhancement

Most helpful comment

Closed via #648.

All 13 comments

@lasers I don't see any benefit to add this function. It will be just a wrapper around exec* with prefixed sysctl in it. What's the point then, when the user can type sysctl manually in exec* with the desired entry in it ?

@su8 I assume she/he/it want #include <sys/sysctl.h> stuffs like rest of files in ./src. Is that doable? Would that be more practical/efficient than to ${exec sysctl -n <name>} repeatedly? If it's going to be exec wrapper, then we definitely should not add this.

@uzsolt Maybe you can tell us why you don't want to use ${exec sysctl -n <name>}?

You mean sys/sysctl.h and more especially the C sysctl() and sysctlbyname() ? There is a shell wrapper sysctl() that does all of the fetching and parsing for the end user instead. The the user can filter the output with other program/pipe even further.

@lasers I think the built-in solution is better than the exec. The exec is more expensive (imho).
The most of conky functions can substitute with exec (and a little cli-trick).

@su8 I don't program the OS. My idea is to get some sysctl-values for example ${sysctl dev.cpu.0.temperature}.

@su8 You mean sys/sysctl.h and more especially the C sysctl() and sysctlbyname() ?

Maybe. It could be similar to that file freebzd.h you worked on. Would it be more efficient to supply multiple systctl variables than to supply multiple exec + sysctl calls? I don't know what sysctl() and sysctlbyname() does behind the scenes.

@uzsolt The most of conky functions can substitute with exec (and a little cli-trick).

I agree. We should simplify everything down to exec, execgauge, execbar, etc. Users could make their own scripts too and point it to exec*. It could get really expensive running all those things too.

(offtopic) NVIDIA support (and its variables) is currently broken on conky, but I won't have problems with ${exec nvidia-smi --format=csv,noheader,nounits=gpu.temperature} so maybe you have a point there.

@su8 You decide what to do here. What is actually better to do here?

The exec is more expensive (imho).

It opens a new process via execl() - https://www.gnu.org/software/libc/manual/html_node/Process-Creation-Example.html which is lighter than system().

We can use sysctlbyname here, but it won't be as flexible as the shell sysctl() along with grep to filter the output even further. It will fetch only a single value from sysctl and display it.

edit: will have to download and install freetbsd to write and test this function, will take several hours.

It will fetch only a single value from sysctl and display it.

I think it's enough in many cases.

@su8 Example variables with sysctl() vs sysctlbyname()?

I think users would specify what they want (with their CPU TEMP prefix) instead of filtering to have many values on same line. Also, with sysctlbyname(), they can have more control by omitting what they don't want in there... if I understand you right with filtering.

What about devel/lua-sysctl (A small sysctl(3) interface for lua, https://github.com/kAworu/lua-sysctl)

@digital-freak The devel/lua-sysctl uses the latest lua, sysutils/conky uses lang/tolua++ which wants 5.1 and can't build with 5.2 (some months ago I tried).

@uzsolt The latest version of lua-sysctl uses the Lua 5.2, but version 1.1 uses Lua 5.1 and works perfect with Conky. I can share the own local port of the devel/lua-sysctl11

Closed via #648.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LeoIannacone picture LeoIannacone  路  3Comments

bad-interpreter picture bad-interpreter  路  4Comments

mreinhardt picture mreinhardt  路  3Comments

BytEvil picture BytEvil  路  4Comments

Microcrap picture Microcrap  路  4Comments