blob: 867e7c4176167b2da2d449d0b0e754865f886fd6 (
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
29
30
31
32
33
34
35
36
|
local wibox = require("wibox")
local widgets_util = require("util.widgets")
local gears = require("gears")
local temperature = {}
function temperature:set_file(file)
self._private.file = file
self._timer:emit_signal("timeout")
end
function linux_update(widget)
local tempf = io.open(widget._private.file)
if tempf then
local temp = tempf:read() / 1000
tempf:close()
widget:set_text(string.format(widget._private.format, temp))
else
widget:set_text("err")
end
end
-- return correct widget for os
if osname == "Linux" then
return function(file)
local w = wibox.widget.textbox()
gears.table.crush(w, temperature, true)
w._private.file = file or ""
w._private.format = "%d°"
widgets_util.add_timer(w, linux_update, 5)
--return widgets.watchfn(linux.temperature, 5)
return w
end
end
return wibox.widget.textbox("unsupported os")
|