-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.lua
38 lines (29 loc) · 974 Bytes
/
temp.lua
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
37
38
local wibox = require("wibox")
local awful = require("awful")
local beautiful = require("beautiful")
mytemp = wibox.layout.margin()
mytemp:set_left(4)
mytemp:set_right(4)
mytemplayout = wibox.layout.fixed.horizontal()
mytemp:set_widget(mytemplayout)
mytempicon = wibox.widget.imagebox()
mytempicon:set_image(beautiful.cpu_icon)
mytemplayout:add(mytempicon)
mytemptext = wibox.widget.textbox()
mytemptext:set_align("right")
mytemplayout:add(mytemptext)
function update_temp (widget)
local fd = io.popen("sensors -u coretemp-isa-0000")
local status = fd:read("*all")
fd:close()
local temps = {}
local _, corecount = string.gsub(status, "Core %d", "%1")
for core=0, corecount, 1 do
temps[core] = string.match(status, "temp%d_input: (%d+%.%d+)")
end
widget:set_markup(math.max(unpack(temps)) .. " °C")
end
update_temp(mytemptext)
mytimer = timer({ timeout = 10.0 })
mytimer:connect_signal("timeout", function () update_temp(mytemptext) end)
mytimer:start()