-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangle_minus_five_degrees.lua
431 lines (366 loc) · 16.5 KB
/
angle_minus_five_degrees.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
--
-- this is a lua script for use in conky
--
require 'cairo'
-- It still works even if I turn it off...
-- package.path = os.getenv('HOME') .. '/.config/conky/angle_minus_five_degrees/?.lua'
require 'config'
require 'const'
require 'includes/functions'
require 'includes/conky_parse'
function _load_modules(_id)
--
-- This way of writing is not possible with `require`.
--
dofile('config/' .. _id .. '.lua')
dofile('modules/' .. _id .. '.lua')
end
_load_modules('wall_clock_hours24')
_load_modules('wall_clock_hours12')
_load_modules('background_tiles')
_load_modules('bar_more')
_load_modules('ring_cpu')
_load_modules('ring_clock')
_load_modules('ring_more')
_load_modules('graph_cpu')
_load_modules('graph_network')
_load_modules('background_lines')
_load_modules('text_clock')
_load_modules('text_top')
_load_modules('text_detail')
_load_modules('debbug_lines')
--
--
--
function conky_main()
if conky_window == nil then
return
end
local cs = cairo_xlib_surface_create(
conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height
)
local cr_draw = cairo_create(cs)
local base_angle = -5 * (math.pi / 180)
cairo_rotate(cr_draw, base_angle)
--
-- Variable, Const like global scope
--
local global_config = get_config()
local global_conky_parse_updates = tonumber(conky_parse('${updates}'))
local global_conky_parse = get_conky_parse()
local global_const = get_const()
-- load and set color scheme
dofile(global_config.color_scheme)
local global_color = get_color()
-- The width of the left bottom panel is linked to width of the string of today's date (full).
local TODAY_WIDTH = {
FONT_SIZE = 64,
FONT_FACE = global_const.FONT_FACE_2_1,
FONT_WEIGHT = CAIRO_FONT_WEIGHT_NORMAL,
MARGIN = 60,
}
TODAY_WIDTH['WIDTH'] = getting_text_width(cr_draw,
TODAY_WIDTH.FONT_SIZE, global_conky_parse.full_date,
TODAY_WIDTH.FONT_FACE, CAIRO_FONT_SLANT_NORMAL, TODAY_WIDTH.FONT_WEIGHT)
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Wall Clock - hours 24
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.wall_clock_hours24 then
local cfg = get_config_wall_clock_hours24(global_const, global_config, TODAY_WIDTH)
drawing_wall_clock_hours24(cr_draw,
-- position
cfg.center_x, cfg.center_y,
-- Clock hands - 24 hour
cfg.hands_radius_hour24, cfg.hands_width_hour24, cfg.hands_back_length_rate_hour24,
-- Clock marks - 24 hour - main hand
cfg.marks_radius_from_hour24_main, cfg.marks_radius_to_hour24_main, cfg.marks_width_hour24_main,
-- Clock marks - 24 hour - sub hand - short (10 min)
cfg.marks_radius_from_hour24_sub_short, cfg.marks_radius_to_hour24_sub_short, cfg.marks_width_hour24_sub_short,
-- Clock marks - 24 hour - sub hand - long (30min)
cfg.marks_radius_from_hour24_sub_long, cfg.marks_radius_to_hour24_sub_long, cfg.marks_width_hour24_sub_long,
-- Clock number - 24 hour
cfg.number_display_hour24,
cfg.number_adjust_x_hour24, cfg.number_adjust_y_hour24,
cfg.number_font_align_hour24, cfg.number_font_size_hour24, cfg.number_font_face_hour24, cfg.number_font_weight_hour24,
-- etc
cfg.hands_update_interval_mins,
cfg.hands_hour24_fix_degree,
cfg.hands_line_cap, cfg.marks_line_cap,
-- color
global_color.wall_clock)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Wall Clock - hours 12
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.wall_clock_hours12 then
local cfg = get_config_wall_clock_hours12(global_const, global_config, TODAY_WIDTH)
drawing_wall_clock_hours12(cr_draw,
-- position
cfg.center_x, cfg.center_y,
-- Clock hands - 12 hour
cfg.hands_radius_hour12, cfg.hands_width_hour12, cfg.hands_back_length_rate_hour12,
-- Clock hands - minutes
cfg.hands_radius_mins, cfg.hands_width_mins, cfg.hands_back_length_rate_mins,
-- Clock hands - seconds
cfg.hands_display_secs, cfg.hands_radius_secs, cfg.hands_width_secs, cfg.hands_back_length_rate_secs,
-- Clock marks - 12 o'clock, top
cfg.marks_display_mins00, cfg.marks_radius_from_mins00, cfg.marks_radius_to_mins00, cfg.marks_width_mins00,
-- Clock marks - 15 minutes without 12 o'clock
cfg.marks_display_mins15, cfg.marks_radius_from_mins15, cfg.marks_radius_to_mins15, cfg.marks_width_mins15,
-- Clock marks - 10 minutes
cfg.marks_radius_from_mins10, cfg.marks_radius_to_mins10, cfg.marks_width_mins10,
-- Clock marks - 1 minute
cfg.marks_display_mins01,
cfg.marks_radius_from_mins, cfg.marks_radius_to_mins, cfg.marks_width_mins,
-- Clock number - 24 hour
cfg.number_display_mins10,
cfg.number_adjust_x_mins10, cfg.number_adjust_y_mins10,
cfg.number_font_align_x_mins10, cfg.number_font_size_mins10, cfg.number_font_face_mins10, cfg.number_font_weight_mins10,
-- etc
cfg.hands_update_interval_mins,
cfg.hands_line_cap, cfg.marks_line_cap,
-- color
global_color.wall_clock)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Background (Tiles)
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.background_tiles then
local cfg = get_config_background_tiles(global_const, global_config)
drawing_background_tiles(cr_draw, global_const,
-- position
cfg.center_x, cfg.center_y,
-- left bottom width
TODAY_WIDTH.WIDTH, TODAY_WIDTH.MARGIN,
-- gradient
cfg.display_gradient, cfg.rect_step,
-- color
global_color.background_tiles)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Bar More
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.bar_more then
local cfg = get_config_bar_more(global_const, global_config)
drawing_bar_more(cr_draw, global_conky_parse_updates,
-- value
global_conky_parse.cpu.cpu0,
global_conky_parse.memperc,
global_conky_parse.fs_free_perc,
global_const.USAGE_LIMIT.CPU,
global_const.USAGE_LIMIT.MEMORY,
-- bar
cfg.bar_position_x, cfg.bar_position_y, cfg.bar_gap_y,
cfg.bar_line_width, cfg.bar_length,
-- caption
cfg.caption_position_x, cfg.caption_position_y, cfg.caption_gap_y,
cfg.caption_align, cfg.caption_font_face, cfg.caption_font_size, cfg.caption_font_weight,
-- color
global_color.bar_more)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- CPU Load Average Ring
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.ring_cpu then
local cfg = get_config_ring_cpu(global_const, global_config)
drawing_ring_cpu(cr_draw, global_conky_parse_updates,
-- value
global_conky_parse.cpu,
cfg.ring_cpu_usage_limit,
-- position
cfg.ring_position_x, cfg.ring_position_y,
-- ring
cfg.ring_angle_start, cfg.ring_angle_end,
cfg.ring_radius, cfg.ring_width, cfg.ring_gap,
-- caption
cfg.caption_position_x, cfg.caption_position_y, cfg.caption_increment_y,
cfg.caption_align, cfg.caption_font_face, cfg.caption_font_size, cfg.caption_font_weight,
-- color
global_color.ring)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Ring Clock
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.ring_clock then
local cfg = get_config_ring_clock(global_const, global_config)
drawing_ring_clock(cr_draw, global_config,
-- position
cfg.ring_position_x, cfg.ring_position_y,
-- etc
cfg.display_secs,
cfg.display_hour12_japanese_style,
-- ring
cfg.ring_angle_start, cfg.ring_angle_end,
cfg.ring_radius, cfg.ring_width, cfg.ring_gap,
-- caption
cfg.caption_position_x, cfg.caption_position_y, cfg.caption_increment_y,
cfg.aption_align, cfg.caption_font_face, cfg.caption_font_size, cfg.caption_font_weight,
-- color
global_color.ring)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- More Ring
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.ring_more then
local cfg = get_config_ring_more(global_const, global_config)
drawing_ring_more(cr_draw, global_conky_parse_updates,
-- values
global_conky_parse.memperc,
global_conky_parse.ibm_temps_0,
global_const.USAGE_LIMIT.MEMORY,
-- position
cfg.ring_center_x, cfg.ring_center_y,
-- ring
cfg.ring_angle_start, cfg.ring_angle_end,
cfg.ring_radius, cfg.ring_width, cfg.ring_gap,
-- caption
cfg.caption_position_x, cfg.caption_position_y, cfg.caption_increment_y,
cfg.caption_align, cfg.caption_font_face, cfg.caption_font_size, cfg.caption_font_weight,
-- color
global_color.ring)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- CPU Load Average Graph
-- Is this a buggy code?
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.graph_cpu then
local cfg = get_config_graph_cpu(global_const, global_config)
drawing_graph_cpu(cr_draw, global_conky_parse_updates,
-- CPU load average
global_conky_parse.cpu.cpu0,
-- etc
cfg.cpu_array_count, cfg.cpu_usage_limit,
-- graph
cfg.graprh_position_x, cfg.graprh_position_y,
cfg.graph_width, cfg.graph_max_height,
-- caption
cfg.caption_position_x, cfg.caption_position_y,
cfg.caption_position_align, cfg.caption_font_face, cfg.caption_font_size, cfg.caption_font_weight,
-- color
global_color.graph_cpu)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Network Graph
-- This is a buggy code!
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.graph_network then
local cfg = get_config_graph_network(global_const, global_config)
drawing_graph_network(cr_draw, global_conky_parse_updates,
-- interval
cfg.time_interval,
-- network speed
global_conky_parse.upspeedf, global_conky_parse.downspeedf,
-- array's count
cfg.network_array_count_upspeed, cfg.network_array_count_downspeed,
-- graph
cfg.graprh_position_x, cfg.graprh_position_y,
cfg.graph_width, cfg.graph_max_height,
-- caption
cfg.caption_position_x,
cfg.caption_position_y_upspeed, cfg.caption_position_y_downspeed,
cfg.caption_position_align, cfg.caption_font_face, cfg.caption_font_size, cfg.caption_font_weight,
-- color
global_color.graph_network)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Background (Lines)
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.background_lines then
local cfg = get_config_background_lines(global_const, global_config)
drawing_background_lines(cr_draw, global_conky_parse_updates, global_const,
-- position
cfg.center_x, cfg.center_y,
-- left bottom width
TODAY_WIDTH.WIDTH, TODAY_WIDTH.MARGIN,
-- top right gimmick
cfg.display_top_right_gimmick, cfg.highlight_length,
-- etc
cfg.line_cap,
-- color
global_color.background_lines, global_color.debugging)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Clock Text
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.text_clock then
local cfg = get_config_text_clock(global_const, global_config)
drawing_text_clock(cr_draw, global_conky_parse_updates, global_config,
-- position
cfg.position_x, cfg.position_y,
-- hours
cfg.hour_adjust_x, cfg.hour_adjust_y,
cfg.hour_font_align, cfg.hour_font_size, cfg.hour_font_face,
-- am/pm when 12 hour system is in effect
cfg.am_pm_adjust_x, cfg.am_pm_adjust_y,
cfg.am_pm_font_align, cfg.am_pm_font_size, cfg.am_pm_font_face,
-- delimiter
cfg.delimiter_adjust_x, cfg.delimiter_adjust_y,
cfg.delimiter_font_align, cfg.delimiter_font_size, cfg.delimiter_font_face,
-- minutes
cfg.min_adjust_x, cfg.min_adjust_y,
cfg.min_font_align, cfg.min_font_size, cfg.min_font_face,
-- seconds
cfg.display_secs,
cfg.sec_adjust_x, cfg.sec_adjust_y,
cfg.sec_font_align, cfg.sec_font_size, cfg.sec_font_face,
-- etc
cfg.display_24_hour,
cfg.display_hour12_japanese_style,
cfg.suppression_hour_zero,
-- color
global_color.text_clock)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Text Top
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.text_top then
local cfg = get_config_text_top(global_const, global_config)
drawing_text_top(cr_draw, global_conky_parse_updates, global_const,
-- values
global_conky_parse.top,
-- Left side, ${top name n}
cfg.position_x_name, cfg.position_y_name, cfg.adjust_x_name,
-- Right size, ${top cpu n}
cfg.position_x_cpu, cfg.position_y_cpu, cfg.adjust_x_cpu,
-- location etc
cfg.adjust_y, cfg.increment_y,
-- font
cfg.font_face, cfg.font_size, cfg.font_weight,
-- color
global_color.text_top)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Detail text
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.text_detail then
local cfg = get_config_text_detail(global_const, global_config)
drawing_text_detail(cr_draw, global_conky_parse_updates,
-- values
global_config.filesystem.device, global_conky_parse, global_const.USAGE_LIMIT,
-- display global ip address
cfg.display_global_ip_address,
-- display swap
cfg.display_swap,
-- position
cfg.position_x, cfg.position_y, cfg.position_align,
-- large font
cfg.adjust_x_large, cfg.adjust_y_large,
TODAY_WIDTH.FONT_SIZE, TODAY_WIDTH.FONT_FACE, TODAY_WIDTH.FONT_WEIGHT,
-- normal font
cfg.adjust_x_normal, cfg.adjust_y_normal, cfg.gap_y_normal,
cfg.font_size_normal, cfg.font_face_normal,
-- color
global_color.text_detail)
end
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-- Debug lines
-- This is debug
---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
if true == global_config.display_module.debug_lines then
local cfg = get_config_debug_lines()
drawing_debug_lines(cs, base_angle, global_const, global_color.debugging)
end
cairo_destroy(cr_draw)
cairo_surface_destroy(cs)
cr = nil
end