diff --git a/widgets/thermal_freebsd.lua b/widgets/thermal_freebsd.lua new file mode 100644 index 0000000..3387a52 --- /dev/null +++ b/widgets/thermal_freebsd.lua @@ -0,0 +1,34 @@ +-- {{{ Grab environment +local setmetatable = setmetatable +local string = { match = string.match } +local helpers = require("vicious.helpers") +-- }}} + + +-- Thermal: provides temperature levels of ACPI and coretemp thermal zones +-- vicious.widgets.thermal +local thermal_freebsd = {} + + +-- {{{ Thermal widget type +local function worker(format, warg) + if not warg then return end + if type(warg) ~= "table" then warg = { warg } end + + local thermals = {} + + for i=1, #warg do + local output = helpers.sysctl(warg[i]) + + if not output then + thermals[i] = -1 + else + thermals[i] = string.match(output, "[%d]+") + end + end + + return thermals +end +-- }}} + +return setmetatable(thermal_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/thermal.lua b/widgets/thermal_linux.lua similarity index 93% rename from widgets/thermal.lua rename to widgets/thermal_linux.lua index b77f652..513d7de 100644 --- a/widgets/thermal.lua +++ b/widgets/thermal_linux.lua @@ -15,7 +15,7 @@ local math = { floor = math.floor } -- Thermal: provides temperature levels of ACPI and coretemp thermal zones -- vicious.widgets.thermal -local thermal = {} +local thermal_linux = {} -- {{{ Thermal widget type @@ -46,4 +46,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(thermal, { __call = function(_, ...) return worker(...) end }) +return setmetatable(thermal_linux, { __call = function(_, ...) return worker(...) end })