-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemperature.lua
69 lines (52 loc) · 1.13 KB
/
temperature.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--functions related to looking up hardware temperature values
function LookupThermal()
local Glob, str, path, val
Glob=filesys.GLOB("/sys/class/thermal/thermal_zone*")
path=Glob:next()
while path ~= nil
do
str=SysFSReadFile(path.."/type")
if str == "x86_pkg_temp"
then
str=SysFSReadFile(path.."/temp")
val=tonumber(str) / 1000.0
AddDisplayValue("cpu_temp", val, "% 3.1f", thermal_color_map)
end
path=Glob:next()
end
end
function LookupCoreTemp(dir)
local Glob, str, path, val
local temp=0
Glob=filesys.GLOB(dir.. "/temp*input")
path=Glob:next()
while path ~= nil
do
str=SysFSReadFile(path)
val=tonumber(str) / 1000
if val > temp then temp=val end
path=Glob:next()
end
return temp
end
function LookupHWmon()
local Glob, str, path
Glob=filesys.GLOB("/sys/class/hwmon/*")
path=Glob:next()
while path ~= nil
do
if filesys.exists(path.."/name") == true
then
str=SysFSReadFile(path.."/name")
if str == "coretemp"
then
AddDisplayValue("cpu_temp", LookupCoreTemp(path), nil, thermal_color_map)
end
end
path=Glob:next()
end
end
function LookupTemperatures()
LookupThermal()
LookupHWmon()
end