From 923eb46350b1102749eb05cd2120c96cc6a715d0 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Fri, 18 Oct 2024 21:49:17 -0500 Subject: initial commit --- widgets/temperature.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 widgets/temperature.lua (limited to 'widgets/temperature.lua') diff --git a/widgets/temperature.lua b/widgets/temperature.lua new file mode 100644 index 0000000..a30e1ed --- /dev/null +++ b/widgets/temperature.lua @@ -0,0 +1,26 @@ +local wibox = require("wibox") +local widgets = require("util.widgets") + + +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") -- cgit v1.2.3