blob: 38b25d077353ce0bf68c8f9a4f87ba87e189636a (
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
37
38
39
40
41
42
43
44
45
|
paths = {}
do
-- Replace "*" with "[^0]*" in the first glob if your zeroeth thermal sensor is virtual (and
-- thus useless):
local f = assert(io.popen([[
#for file in /sys/class/thermal/thermal_zone*/temp
#do
# [ -e "$file" ] || break
# printf "%s\n" "$file"
#done
for dir in /sys/class/hwmon/*
do
[ -e "$dir" ] || break
IFS= read -r monitor_name < "$dir"/name
# You may have more than one hardware monitor enabled
# If so, disable ones that are not needed
case "$monitor_name" in
coretemp|fam15h_power|k10temp)
printf "%s\n" "$dir"/temp*_input
esac
done
]]))
for p in f:lines() do
table.insert(paths, p)
end
f:close()
end
widget = {
plugin = 'timer',
opts = {period = 2},
cb = function()
for _, p in ipairs(paths) do
local f = assert(io.open(p, 'r'))
local temp = f:read('*number') / 1000
local icon = ""
if temp > 55 then
icon = ""
elseif temp > 80 then
icon = ""
end
return string.format('%s %.0f°C', icon, temp)
end
end,
}
|