-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhwmon.lua
More file actions
90 lines (75 loc) · 3.5 KB
/
Copy pathhwmon.lua
File metadata and controls
90 lines (75 loc) · 3.5 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
-- SPDX-FileCopyrightText: Robert Ryszard Paciorek <rrp@opcode.eu.org>
-- SPDX-License-Identifier: MIT
require "cairo"
require "hwmon_read"
require "utils"
-------------------------
--- Cairo widgets ---
-------------------------
local graph_h = 40
local text_offset = 13
function draw_gpu(cr, conf)
local ybase = init_graph(cr, conf.X, conf.Y, conf.W, graph_h, text_offset)
cairo_set_source_rgba(cr, 1.0, 0.25, 0, 1)
draw_graph(cr, conf.X, ybase, conf.W, graph_h, hist_gpu, hist_ptr, 290)
local usage_str = format_float(hist_gpu[hist_ptr], 4) .. "W"
set_default_font(cr, 1)
cairo_show_text_on_center(cr, conf.X, ybase + text_offset, conf.W, usage_str)
end
function draw_gpu_tooltip(cr, conf)
if not is_tooltip_visible(conf) then return end
min, max, avg = min_max_avg(hist_gpu, hist_ptr, conf.W)
local str = {
"min: " .. format_float(min, 4) .. "W max: " .. format_float(max, 4) .. "W avg: " .. format_float(avg, 4) .. "W",
}
tooltip_draw(cr, str)
end
function draw_term(cr, conf)
set_default_font(cr)
if hwmon.ram.temp.max > 50 then
cairo_set_source_rgba(cr, 1.0, 0.2, 0.0, 1)
else
cairo_set_source_rgba(cr, 0.9, 0.9, 0.9, 1)
end
cairo_move_to(cr, conf.X, conf.Y+9)
cairo_show_text(cr, "RAM: " .. tostring(hwmon.ram.temp.min) .. "°C " .. tostring(hwmon.ram.temp.max) .. "°C")
if hwmon.cpu.temp.max > 90 then
cairo_set_source_rgba(cr, 1.0, 0.2, 0.0, 1)
elseif hwmon.cpu.temp.max > 80 then
cairo_set_source_rgba(cr, 0.9, 0.45, 0, 1)
else
cairo_set_source_rgba(cr, 0.9, 0.9, 0.9, 1)
end
cairo_move_to(cr, conf.X, conf.Y+23)
cairo_show_text(cr, "CPU: " .. tostring(hwmon.cpu.temp.min) .. "°C " .. tostring(hwmon.cpu.temp.max) .. "°C")
if hwmon.gpu.temp.max > 90 then
cairo_set_source_rgba(cr, 1.0, 0.2, 0.0, 1)
else
cairo_set_source_rgba(cr, 0.9, 0.9, 0.9, 1)
end
cairo_move_to(cr, conf.X, conf.Y+37)
cairo_show_text(cr, "GPU: " .. tostring(hwmon.gpu.temp.min) .. "°C " .. tostring(hwmon.gpu.temp.max) .. "°C")
local mb_max = hwmon.mb.temp.max
if hwmon.mdio.temp.c1.val > mb_max then
mb_max = hwmon.mdio.temp.c1.val
end
if hwmon.mb.temp.max > 70 or hwmon.mdio.temp.c1.val > 90 then
cairo_set_source_rgba(cr, 1.0, 0.2, 0.0, 1)
else
cairo_set_source_rgba(cr, 0.9, 0.9, 0.9, 1)
end
cairo_move_to(cr, conf.X, conf.Y+51)
cairo_show_text(cr, " MB: " .. tostring(hwmon.mb.temp.min) .. "°C " .. tostring(mb_max) .. "°C")
end
function draw_term_tooltip(cr, conf)
if not is_tooltip_visible(conf) then return end
local str = {
"GPU: mem: " .. tostring(hwmon.gpu.temp.mem.val) .."°C edge: " .. tostring(hwmon.gpu.temp.edge.val) .. "°C junction: " .. tostring(hwmon.gpu.temp.junction.val) .. "°C"
.. " CPU: ".. tostring(hwmon.cpu.temp.ccd1.val) .. "°C " .. tostring(hwmon.cpu.temp.ccd2.val) .. "°C " .. tostring(hwmon.cpu.temp.gpu_edge.val) .. "°C " .. tostring(hwmon.cpu.temp.ctl.val) .. "°C ",
"MDIO: " .. tostring(hwmon.mdio.temp.c1.val) .. "°C SDA: " .. tostring(hwmon.disks.temp.sda.val) .. "°C"
.. " RAM: " .. tostring(hwmon.ram.temp.c1.val) .. "°C " .. tostring(hwmon.ram.temp.c2.val) .. "°C",
"MB: sysin: " .. tostring(hwmon.mb.temp.sysin.val) .."°C cpuin: " .. tostring(hwmon.mb.temp.cpuin.val) .."°C tsi0: " .. tostring(hwmon.mb.temp.tsi0.val) .. "°C aux: " .. tostring(hwmon.mb.temp.auxtin1.val) .. "°C "
.. tostring(hwmon.mb.temp.auxtin2.val) .. "°C " .. tostring(hwmon.mb.temp.auxtin3.val) .. "°C " .. tostring(hwmon.mb.temp.auxtin4.val) .. "°C " .. tostring(hwmon.mb.temp.auxtin5.val) .. "°C",
}
tooltip_draw(cr, str)
end