From 22d49a9e5d85f1e2223abfc6176ca42e621a69df Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:55:23 +0100 Subject: [PATCH] move thermal widget to match new layout --- widgets/thermal_freebsd.lua | 34 ++++++++++++++++++++++ widgets/{thermal.lua => thermal_linux.lua} | 4 +-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 widgets/thermal_freebsd.lua rename widgets/{thermal.lua => thermal_linux.lua} (93%) 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 })