blob: 985291d5ce69fd8656a08fcd0da21de2c0942da9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
local wibox = require("wibox")
local widgets = require("util.widgets")
local osname = require("util.osname")
local linux = { file = nil }
function linux.temperature(widget)
-- read meminfo
local tempf = io.open(linux.file)
if tempf then
local temp = tempf:read() / 1000
tempf:close()
widget:set_text(math.floor(temp))
else
widget:set_text("err")
end
end
-- return correct widget for os
if osname == "Linux" then
return function(file)
linux.file = file
return widgets.watchfn(linux.temperature, 5)
end
end
return wibox.widget.textbox("unsupported os")
|