thermal: widget rewritten for sysfs
Default path is set to /sys/class/thermal but at least it's easier to switch to /sys/class/hwmon (i.e. coretemp) now without much code modification. Note; zone IDs are probably different than those in /proc/acpi/thermal_zone
This commit is contained in:
parent
46d52face8
commit
92be5fbae5
2
README
2
README
|
@ -149,7 +149,7 @@ vicious.widgets.cpufreq
|
|||
|
||||
vicious.widgets.thermal
|
||||
- provides temperature levels of ACPI thermal zones
|
||||
- takes the thermal zone as an argument, i.e. "TZS0"
|
||||
- takes the thermal zone as an argument, i.e. "thermal_zone0"
|
||||
- returns 1st value as temperature of requested thermal zone
|
||||
|
||||
vicious.widgets.load
|
||||
|
|
21
thermal.lua
21
thermal.lua
|
@ -4,10 +4,8 @@
|
|||
---------------------------------------------------
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { open = io.open }
|
||||
local setmetatable = setmetatable
|
||||
local string = { match = string.match }
|
||||
local helpers = require("vicious.helpers")
|
||||
-- }}}
|
||||
|
||||
|
||||
|
@ -17,16 +15,17 @@ module("vicious.thermal")
|
|||
|
||||
-- {{{ Thermal widget type
|
||||
local function worker(format, thermal_zone)
|
||||
-- Get an ACPI thermal zone
|
||||
local f = io.open("/proc/acpi/thermal_zone/"..thermal_zone.."/temperature")
|
||||
-- Handler for incompetent users
|
||||
if not f then return {0} end
|
||||
local line = f:read("*line")
|
||||
f:close()
|
||||
local thermal = setmetatable(
|
||||
{ _path = "/sys/class/thermal/" .. thermal_zone },
|
||||
helpers.pathtotable
|
||||
)
|
||||
|
||||
local temperature = tonumber(string.match(line, "[%d]?[%d]?[%d]"))
|
||||
-- Get ACPI thermal zone
|
||||
if thermal.temp then
|
||||
return {thermal.temp / 1000}
|
||||
end
|
||||
|
||||
return {temperature}
|
||||
return {0}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue