diff options
| author | Tim Keller <tjkeller.xyz> | 2024-11-03 16:09:10 -0600 | 
|---|---|---|
| committer | Tim Keller <tjkeller.xyz> | 2024-11-03 16:09:10 -0600 | 
| commit | fea2bd24e83c90c311f4e77ccf46f1464a6f5afb (patch) | |
| tree | 2edc2072ae629d8082fdb653a052df23b1c49f2e /widgets | |
| parent | 9a11cd62ac1ca5659a36fb3111d3bf7dead9d85b (diff) | |
| download | awesome-fea2bd24e83c90c311f4e77ccf46f1464a6f5afb.tar.xz awesome-fea2bd24e83c90c311f4e77ccf46f1464a6f5afb.zip | |
update temp widget to be fancier and other small stuff
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/temperature.lua | 26 | 
1 files changed, 18 insertions, 8 deletions
| diff --git a/widgets/temperature.lua b/widgets/temperature.lua index a30e1ed..867e7c4 100644 --- a/widgets/temperature.lua +++ b/widgets/temperature.lua @@ -1,15 +1,20 @@  local wibox = require("wibox") -local widgets = require("util.widgets") +local widgets_util = require("util.widgets") +local gears = require("gears") +local temperature = {} -local linux = { file = nil } -function linux.temperature(widget) -	-- read meminfo -	local tempf = io.open(linux.file) +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(math.floor(temp)) +		widget:set_text(string.format(widget._private.format, temp))  	else  		widget:set_text("err")  	end @@ -18,8 +23,13 @@ end  -- return correct widget for os  if osname == "Linux" then  	return function(file) -		linux.file = file -		return widgets.watchfn(linux.temperature, 5) +		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 | 
