KAworu FreeBSD ACPI Widget
FreeBSD provide a nice tool to get various system information: sysctl(8)
Contents |
FreeBSD ACPI interface for Lua
System information under FreeBSD can be read using sysctl(8). I did write a sysctl(3) interface for lua, you can get it here.
UPDATE:
thanks to Renato Botelho, lua-sysctl is now in the FreeBSD port system :D
cd /usr/ports/devel/lua-sysctl && make install clean
How to Use
sysctl.get(key)
returns two values. first returned value is the sysctl(3) value, second value is the format of returned value
- "I" int
- "UI" unsigned int
- "IK" int, in (kelv * 10) (used to get temperature)
- "L" long
- "UL" unsigned long
- "Q" quad_t
- "A" char *
- "T,dev_t" dev_t
- "S,clockinfo" struct clockinfo
- "S,loadavg" struct loadavg
- "S,timeval" struct timeval
- "S,vmtotal" struct vmtotal
sysctl.set(key, newval)
set the sysctl's key to newval. return nothin' and throw lua error if any problem occur.
sysctl.IK2celsius(kelv)
convert a sysctl's IK value into celsius and return it.
sysctl.IK2farenheit(kelv)
convert a sysctl's IK value into farenheit and return it.
creating the ACPI Widget
You need to load the library (in your rc.lua file). For example, if you have ~/.config/awesome/lib/sysctl/core.so and ~/.config/awesome/lib/sysctl.lua:
package.cpath = package.cpath .. ';' .. awful.util.getdir("config") .. '/lib/?.so'
require("lib/sysctl")
If you installed lua-sysctl via the port system, you don't need to tweak the package.cpath, and can require("sysctl")
And voilĂ ! You can use sysctl.get() etc. to query sysctl and get any system information.
Example
You can check my config here for a complete example of use, and other user's config.
Have fun!