summaryrefslogtreecommitdiff
path: root/awesome/widgets/temperature.lua
blob: 8cf1aa9d4c4f74513e2edabb94efb96965efcff6 (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
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)
	local temp = tempf:read() / 1000
	tempf:close()

	widget:set_text(math.floor(temp))
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")