2013-09-07 12:06:42 +02:00
|
|
|
--[[
|
2017-09-04 12:43:00 +02:00
|
|
|
|
|
|
|
Licensed under GNU General Public License v2
|
|
|
|
* (c) 2013, Luke Bonham
|
|
|
|
|
2013-09-07 12:06:42 +02:00
|
|
|
--]]
|
|
|
|
|
2017-04-02 19:35:03 +02:00
|
|
|
local helpers = require("lain.helpers")
|
|
|
|
local wibox = require("wibox")
|
|
|
|
local open = io.open
|
|
|
|
local tonumber = tonumber
|
2013-09-07 12:06:42 +02:00
|
|
|
|
|
|
|
-- coretemp
|
2017-02-08 14:15:48 +01:00
|
|
|
-- lain.widget.temp
|
2013-09-07 12:06:42 +02:00
|
|
|
|
2017-02-08 20:45:11 +01:00
|
|
|
local function factory(args)
|
2017-04-02 19:35:03 +02:00
|
|
|
local temp = { widget = wibox.widget.textbox() }
|
2013-09-10 23:02:11 +02:00
|
|
|
local args = args or {}
|
2015-10-20 15:17:44 +02:00
|
|
|
local timeout = args.timeout or 2
|
2014-01-21 16:01:28 +01:00
|
|
|
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
|
2013-09-10 23:02:11 +02:00
|
|
|
local settings = args.settings or function() end
|
2013-09-07 12:06:42 +02:00
|
|
|
|
2017-01-27 14:35:27 +01:00
|
|
|
function temp.update()
|
2017-04-02 19:35:03 +02:00
|
|
|
local f = open(tempfile)
|
2016-05-29 17:13:52 +02:00
|
|
|
if f then
|
2015-07-26 00:59:23 +02:00
|
|
|
coretemp_now = tonumber(f:read("*all")) / 1000
|
2014-01-04 12:23:24 +01:00
|
|
|
f:close()
|
|
|
|
else
|
|
|
|
coretemp_now = "N/A"
|
|
|
|
end
|
|
|
|
|
2015-10-20 15:17:44 +02:00
|
|
|
widget = temp.widget
|
|
|
|
settings()
|
2013-09-07 12:06:42 +02:00
|
|
|
end
|
|
|
|
|
2017-01-27 14:35:27 +01:00
|
|
|
helpers.newtimer("coretemp", timeout, temp.update)
|
2016-03-03 12:40:49 +01:00
|
|
|
|
2017-01-25 17:13:14 +01:00
|
|
|
return temp
|
2013-09-07 12:06:42 +02:00
|
|
|
end
|
|
|
|
|
2017-04-02 19:35:03 +02:00
|
|
|
return factory
|