-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.lua
76 lines (55 loc) · 2.3 KB
/
memory.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
69
70
71
72
73
74
75
76
require 'cairo'
require './_main'
function conky_main ()
if conky_window == nil then
return
end
local surface = cairo_xlib_surface_create(
conky_window.display,
conky_window.drawable,
conky_window.visual,
conky_window.width,
conky_window.height)
draw_bg_square(conky_window, surface)
radius = 30
radius_inner = radius * 0.6
offset = 72
offset_x = 8
half = (conky_window.width) / 2
center_mem_x = (half) - ((half - radius) / 2) - radius / 2
center_swap_x = (2 * half) - ((half - radius) / 2) - radius / 2
start_angle = -math.pi
end_angle = math.pi / 2
local canvas = cairo_create(surface)
cairo_set_source_rgba(canvas, el_red, el_green, el_blue, el_alpha)
cairo_set_line_width(canvas, 1)
cairo_arc(canvas, center_mem_x, offset + radius / 2, radius, start_angle, end_angle)
cairo_stroke(canvas)
end_angle_mem = map_range(0, 100, start_angle, end_angle - start_angle, conky_parse('$memperc'))
cairo_move_to(canvas, center_mem_x, offset + radius / 2)
cairo_arc(canvas, center_mem_x, offset + radius / 2, radius - 1, start_angle, end_angle_mem)
cairo_close_path(canvas)
cairo_set_source_rgba(canvas, el_red, el_green, el_blue, el_alpha)
cairo_fill(canvas)
cairo_move_to(canvas, center_mem_x, offset + radius / 2)
cairo_arc(canvas, center_mem_x, offset + radius / 2, radius_inner, start_angle, math.pi)
cairo_close_path(canvas)
cairo_set_source_rgba(canvas, cr_red, cr_green, cr_blue, cr_alpha)
cairo_fill(canvas)
local canvas = cairo_create(surface)
cairo_set_source_rgba(canvas, el_red, el_green, el_blue, el_alpha)
cairo_set_line_width(canvas, 1)
cairo_arc(canvas, center_swap_x, offset + radius / 2, radius, start_angle, end_angle)
cairo_stroke(canvas)
end_angle_swap = map_range(0, 100, start_angle, end_angle - start_angle, conky_parse('$swapperc'))
cairo_move_to(canvas, center_swap_x, offset + radius / 2)
cairo_arc(canvas, center_swap_x, offset + radius / 2, radius_inner, start_angle, end_angle_swap)
cairo_close_path(canvas)
cairo_set_source_rgba(canvas, el_red, el_green, el_blue, el_alpha)
cairo_fill(canvas)
cairo_move_to(canvas, center_swap_x, offset + radius / 2)
cairo_arc(canvas, center_swap_x, offset + radius / 2, radius_inner, start_angle, math.pi)
cairo_close_path(canvas)
cairo_set_source_rgba(canvas, cr_red, cr_green, cr_blue, cr_alpha)
cairo_fill(canvas)
end