daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Oct 17th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --==============================================================================
  2. --                            conky_orange.lua
  3. --
  4. --  author  : SLK
  5. --  version : v2011062101
  6. --  license : Distributed under the terms of GNU GPL version 2 or later
  7. --
  8. --  modified: me
  9. --  version : v20171027
  10. --  notes   : works on 4k screen. uses conky conf newer >v1.1
  11. --==============================================================================
  12.  
  13. require 'cairo'
  14.  
  15. --------------------------------------------------------------------------------
  16. --                                                                    clock DATA
  17. -- HOURS
  18. clock_h = {
  19.     {
  20.     name='time',                   arg='%I',                    max_value=12,
  21.     x=147,                         y=155,
  22.     graph_radius=100,
  23.     graph_thickness=4,
  24.     graph_unit_angle=30,           graph_unit_thickness=30,
  25.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.0,
  26.     graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.3,
  27.     txt_radius=85,
  28.     txt_weight=1,                  txt_size=18.0,
  29.     txt_fg_colour=0xFFFFFF,        txt_fg_alpha=0.6,
  30.     graduation_radius=123,
  31.     graduation_thickness=6,        graduation_mark_thickness=2,
  32.     graduation_unit_angle=30,
  33.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  34.     },
  35. }
  36. -- MINUTES
  37. clock_m = {
  38.     {
  39.     name='time',                   arg='%M',                    max_value=60,
  40.     x=147,                         y=155,
  41.     graph_radius=108,
  42.     graph_thickness=2,
  43.     graph_unit_angle=6,            graph_unit_thickness=6,
  44.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  45.     graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.3,
  46.     txt_radius=121,
  47.     txt_weight=0,                  txt_size=18.0,
  48.     txt_fg_colour=0xFFFFFF,        txt_fg_alpha=0.6,
  49.     graduation_radius=117,
  50.     graduation_thickness=0,        graduation_mark_thickness=2,
  51.     graduation_unit_angle=30,
  52.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  53.     },
  54. }
  55. -- SECONDS
  56. clock_s = {
  57.     {
  58.     name='time',                   arg='%S',                    max_value=60,
  59.     x=147,                         y=155,
  60.     graph_radius=108,
  61.     graph_thickness=2,
  62.     graph_unit_angle=6,            graph_unit_thickness=2,
  63.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.0,
  64.     graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.3,
  65.     txt_radius=121,
  66.     txt_weight=0,                  txt_size=18.0,
  67.     txt_fg_colour=0xFFFFFF,        txt_fg_alpha=0.4,
  68.     graduation_radius=0,
  69.     graduation_thickness=0,        graduation_mark_thickness=0,
  70.     graduation_unit_angle=0,
  71.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
  72.     },
  73. }
  74.  
  75. --------------------------------------------------------------------------------
  76. --                                                                    gauge DATA
  77. gauge = {
  78. {
  79.     name='cpu',                    arg='cpu0',                  max_value=100,
  80.     x=100,                          y=380,
  81.     graph_radius=20,
  82.     graph_thickness=5,
  83.     graph_start_angle=180,
  84.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  85.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  86.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  87.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  88.     txt_radius=15,
  89.     txt_weight=0,                  txt_size=7.0,
  90.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  91.     graduation_radius=28,
  92.     graduation_thickness=0,        graduation_mark_thickness=1,
  93.     graduation_unit_angle=27,
  94.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  95.     caption='',
  96.     caption_weight=1,              caption_size=8.0,
  97.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  98. },
  99. {
  100.     name='cpu',                    arg='cpu1',                  max_value=100,
  101.     x=100,                          y=380,
  102.     graph_radius=30,
  103.     graph_thickness=5,
  104.     graph_start_angle=180,
  105.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  106.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  107.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  108.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  109.     txt_radius=25,
  110.     txt_weight=0,                  txt_size=7.0,
  111.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  112.     graduation_radius=28,
  113.     graduation_thickness=0,        graduation_mark_thickness=1,
  114.     graduation_unit_angle=27,
  115.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  116.     caption='',
  117.     caption_weight=1,              caption_size=8.0,
  118.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  119. },
  120. {
  121.     name='cpu',                    arg='cpu2',                  max_value=100,
  122.     x=100,                          y=380,
  123.     graph_radius=40,
  124.     graph_thickness=5,
  125.     graph_start_angle=180,
  126.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  127.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  128.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  129.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  130.     txt_radius=35,
  131.     txt_weight=0,                  txt_size=7.0,
  132.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  133.     graduation_radius=28,
  134.     graduation_thickness=0,        graduation_mark_thickness=1,
  135.     graduation_unit_angle=27,
  136.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  137.     caption='',
  138.     caption_weight=1,              caption_size=8.0,
  139.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  140. },
  141. {
  142.     name='cpu',                    arg='cpu3',                  max_value=100,
  143.     x=100,                          y=380,
  144.     graph_radius=50,
  145.     graph_thickness=5,
  146.     graph_start_angle=180,
  147.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  148.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  149.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  150.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  151.     txt_radius=45,
  152.     txt_weight=0,                  txt_size=7.0,
  153.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  154.     graduation_radius=28,
  155.     graduation_thickness=0,        graduation_mark_thickness=1,
  156.     graduation_unit_angle=27,
  157.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  158.     caption='',
  159.     caption_weight=1,              caption_size=8.0,
  160.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  161. },
  162. {
  163.     name='cpu',                    arg='cpu4',                  max_value=100,
  164.     x=100,                          y=380,
  165.     graph_radius=60,
  166.     graph_thickness=5,
  167.     graph_start_angle=180,
  168.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  169.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  170.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  171.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  172.     txt_radius=55,
  173.     txt_weight=0,                  txt_size=7.0,
  174.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  175.     graduation_radius=28,
  176.     graduation_thickness=0,        graduation_mark_thickness=1,
  177.     graduation_unit_angle=27,
  178.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  179.     caption='',
  180.     caption_weight=1,              caption_size=8.0,
  181.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  182. },
  183. {
  184.     name='cpu',                    arg='cpu5',                  max_value=100,
  185.     x=100,                          y=380,
  186.     graph_radius=70,
  187.     graph_thickness=5,
  188.     graph_start_angle=180,
  189.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  190.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  191.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  192.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  193.     txt_radius=65,
  194.     txt_weight=0,                  txt_size=7.0,
  195.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  196.     graduation_radius=28,
  197.     graduation_thickness=0,        graduation_mark_thickness=1,
  198.     graduation_unit_angle=27,
  199.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  200.     caption='',
  201.     caption_weight=1,              caption_size=8.0,
  202.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  203. },
  204. {
  205.     name='cpu',                    arg='cpu6',                  max_value=100,
  206.     x=100,                          y=380,
  207.     graph_radius=80,
  208.     graph_thickness=5,
  209.     graph_start_angle=180,
  210.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  211.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  212.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  213.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  214.     txt_radius=75,
  215.     txt_weight=0,                  txt_size=7.0,
  216.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  217.     graduation_radius=28,
  218.     graduation_thickness=0,        graduation_mark_thickness=1,
  219.     graduation_unit_angle=27,
  220.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  221.     caption='',
  222.     caption_weight=1,              caption_size=8.0,
  223.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  224. },
  225. {
  226.     name='cpu',                    arg='cpu7',                  max_value=100,
  227.     x=100,                          y=380,
  228.     graph_radius=90,
  229.     graph_thickness=5,
  230.     graph_start_angle=180,
  231.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  232.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  233.     graph_fg_colour=0xEF5A29,      graph_fg_alpha=0.5,
  234.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
  235.     txt_radius=85,
  236.     txt_weight=0,                  txt_size=7.0,
  237.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  238.     graduation_radius=28,
  239.     graduation_thickness=0,        graduation_mark_thickness=1,
  240.     graduation_unit_angle=27,
  241.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  242.     caption='',
  243.     caption_weight=1,              caption_size=8.0,
  244.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  245. },
  246. {
  247.     name='memperc',                arg='',                      max_value=100,
  248.     x=100,                          y=575,
  249.     graph_radius=24,
  250.     graph_thickness=5,
  251.     graph_start_angle=180,
  252.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  253.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  254.     graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.2,
  255.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=1.0,
  256.     txt_radius=10,
  257.     txt_weight=0,                  txt_size=8.0,
  258.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  259.     graduation_radius=23,
  260.     graduation_thickness=0,        graduation_mark_thickness=2,
  261.     graduation_unit_angle=27,
  262.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
  263.     caption='',
  264.     caption_weight=1,              caption_size=8.0,
  265.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.3,
  266. },
  267. {
  268.     name='fs_used_perc',           arg='/media/host',                     max_value=100,
  269.     x=100,                          y=675,
  270.     graph_radius=24,
  271.     graph_thickness=5,
  272.     graph_start_angle=180,
  273.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  274.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  275.     graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.2,
  276.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=1.0,
  277.     txt_radius=34,
  278.     txt_weight=0,                  txt_size=8.0,
  279.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  280.     graduation_radius=28,
  281.     graduation_thickness=0,        graduation_mark_thickness=1,
  282.     graduation_unit_angle=27,
  283.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  284.     caption='H',
  285.     caption_weight=1,              caption_size=8.0,
  286.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.5,
  287. },
  288. {
  289.     name='fs_used_perc',           arg='/',                max_value=100,
  290.     x=100,                          y=675,
  291.     graph_radius=18,
  292.     graph_thickness=5,
  293.     graph_start_angle=180,
  294.     graph_unit_angle=2.7,          graph_unit_thickness=2.7,
  295.     graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
  296.     graph_fg_colour=0xFFFFFF,      graph_fg_alpha=0.2,
  297.     hand_fg_colour=0xEF5A29,       hand_fg_alpha=1.0,
  298.     txt_radius=10,
  299.     txt_weight=0,                  txt_size=8.0,
  300.     txt_fg_colour=0xEF5A29,        txt_fg_alpha=1.0,
  301.     graduation_radius=28,
  302.     graduation_thickness=0,        graduation_mark_thickness=1,
  303.     graduation_unit_angle=27,
  304.     graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
  305.     caption='M',
  306.     caption_weight=1,              caption_size=8.0,
  307.     caption_fg_colour=0xFFFFFF,    caption_fg_alpha=0.5,
  308. },
  309. }
  310.  
  311. -------------------------------------------------------------------------------
  312. --                                                                 rgb_to_r_g_b
  313. -- converts color in hexa to decimal
  314. --
  315. function rgb_to_r_g_b(colour, alpha)
  316.     return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
  317. end
  318.  
  319. -------------------------------------------------------------------------------
  320. --                                                            angle_to_position
  321. -- convert degree to rad and rotate (0 degree is top/north)
  322. --
  323. function angle_to_position(start_angle, current_angle)
  324.     local pos = current_angle + start_angle
  325.     return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
  326. end
  327.  
  328. -------------------------------------------------------------------------------
  329. --                                                              draw_clock_ring
  330. -- displays clock
  331. --
  332. function draw_clock_ring(display, data, value)
  333.     local max_value = data['max_value']
  334.     local x, y = data['x'], data['y']
  335.     local graph_radius = data['graph_radius']
  336.     local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
  337.     local graph_unit_angle = data['graph_unit_angle']
  338.     local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
  339.     local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
  340.  
  341.     -- background ring
  342.     cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi)
  343.     cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
  344.     cairo_set_line_width(display, graph_thickness)
  345.     cairo_stroke(display)
  346.  
  347.     -- arc of value
  348.     local val = (value % max_value)
  349.     local i = 1
  350.     while i <= val do
  351.         cairo_arc(display, x, y, graph_radius,(  ((graph_unit_angle * i) - graph_unit_thickness)*(2*math.pi/360)  )-(math.pi/2),((graph_unit_angle * i) * (2*math.pi/360))-(math.pi/2))
  352.         cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha))
  353.         cairo_stroke(display)
  354.         i = i + 1
  355.     end
  356.     local angle = (graph_unit_angle * i) - graph_unit_thickness
  357.  
  358.     -- graduations marks
  359.     local graduation_radius = data['graduation_radius']
  360.     local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
  361.     local graduation_unit_angle = data['graduation_unit_angle']
  362.     local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
  363.     if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
  364.         local nb_graduation = 360 / graduation_unit_angle
  365.         local i = 1
  366.         while i <= nb_graduation do
  367.             cairo_set_line_width(display, graduation_thickness)
  368.             cairo_arc(display, x, y, graduation_radius, (((graduation_unit_angle * i)-(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2),(((graduation_unit_angle * i)+(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2))
  369.             cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
  370.             cairo_stroke(display)
  371.             cairo_set_line_width(display, graph_thickness)
  372.             i = i + 1
  373.         end
  374.     end
  375.  
  376.     -- text
  377.     local txt_radius = data['txt_radius']
  378.     local txt_weight, txt_size = data['txt_weight'], data['txt_size']
  379.     local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
  380.     local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2)))
  381.     local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2)))
  382.     cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight);
  383.     cairo_set_font_size (display, txt_size);
  384.     cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha));
  385.     cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3);
  386.     cairo_show_text (display, value);
  387.     cairo_stroke (display);
  388. end
  389.  
  390. -------------------------------------------------------------------------------
  391. --                                                              draw_gauge_ring
  392. -- displays gauges
  393. --
  394. function draw_gauge_ring(display, data, value)
  395.     local max_value = data['max_value']
  396.     local x, y = data['x'], data['y']
  397.     local graph_radius = data['graph_radius']
  398.     local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
  399.     local graph_start_angle = data['graph_start_angle']
  400.     local graph_unit_angle = data['graph_unit_angle']
  401.     local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
  402.     local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
  403.     local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
  404.     local graph_end_angle = (max_value * graph_unit_angle) % 360
  405.  
  406.     -- background ring
  407.     cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
  408.     cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
  409.     cairo_set_line_width(display, graph_thickness)
  410.     cairo_stroke(display)
  411.  
  412.     -- arc of value
  413.     local val = value % (max_value + 1)
  414.     local start_arc = 0
  415.     local stop_arc = 0
  416.     local i = 1
  417.     while i <= val do
  418.         start_arc = (graph_unit_angle * i) - graph_unit_thickness
  419.         stop_arc = (graph_unit_angle * i)
  420.         cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
  421.         cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
  422.         cairo_stroke(display)
  423.         i = i + 1
  424.     end
  425.     local angle = start_arc
  426.  
  427.     -- hand
  428.     start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
  429.     stop_arc = (graph_unit_angle * val)
  430.     cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
  431.     cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
  432.     cairo_stroke(display)
  433.  
  434.     -- graduations marks
  435.     local graduation_radius = data['graduation_radius']
  436.     local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
  437.     local graduation_unit_angle = data['graduation_unit_angle']
  438.     local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
  439.     if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
  440.         local nb_graduation = graph_end_angle / graduation_unit_angle
  441.         local i = 0
  442.         while i < nb_graduation do
  443.             cairo_set_line_width(display, graduation_thickness)
  444.             start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
  445.             stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
  446.             cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
  447.             cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
  448.             cairo_stroke(display)
  449.             cairo_set_line_width(display, graph_thickness)
  450.             i = i + 1
  451.         end
  452.     end
  453.  
  454.     -- text
  455.     local txt_radius = data['txt_radius']
  456.     local txt_weight, txt_size = data['txt_weight'], data['txt_size']
  457.     local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
  458.     local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
  459.     local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
  460.     cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
  461.     cairo_set_font_size (display, txt_size)
  462.     cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
  463.     cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
  464.     cairo_show_text (display, value)
  465.     cairo_stroke (display)
  466.  
  467.     -- caption
  468.     local caption = data['caption']
  469.     local caption_weight, caption_size = data['caption_weight'], data['caption_size']
  470.     local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
  471.     local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
  472.     local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
  473.     cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
  474.     cairo_set_font_size (display, caption_size)
  475.     cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
  476.     cairo_move_to (display, x + tox + 5, y + toy + 1)
  477.     -- bad hack but not enough time !
  478.     if graph_start_angle < 105 then
  479.         cairo_move_to (display, x + tox - 30, y + toy + 1)
  480.     end
  481.     cairo_show_text (display, caption)
  482.     cairo_stroke (display)
  483. end
  484.  
  485. -------------------------------------------------------------------------------
  486. --                                                               go_clock_rings
  487. -- loads data and displays clock
  488. --
  489. function go_clock_rings(display)
  490.     local function load_clock_rings(display, data)
  491.         local str, value = '', 0
  492.         str = string.format('${%s %s}',data['name'], data['arg'])
  493.         str = conky_parse(str)
  494.         value = tonumber(str)
  495.         draw_clock_ring(display, data, value)
  496.     end
  497.    
  498.     for i in pairs(clock_h) do
  499.         load_clock_rings(display, clock_h[i])
  500.     end
  501.     for i in pairs(clock_m) do
  502.         load_clock_rings(display, clock_m[i])
  503.     end
  504.     for i in pairs(clock_s) do
  505.         load_clock_rings(display, clock_s[i])
  506.     end
  507. end
  508.  
  509. -------------------------------------------------------------------------------
  510. --                                                               go_gauge_rings
  511. -- loads data and displays gauges
  512. --
  513. function go_gauge_rings(display)
  514.     local function load_gauge_rings(display, data)
  515.         local str, value = '', 0
  516.         str = string.format('${%s %s}',data['name'], data['arg'])
  517.         str = conky_parse(str)
  518.         value = tonumber(str)
  519.         draw_gauge_ring(display, data, value)
  520.     end
  521.    
  522.     for i in pairs(gauge) do
  523.         load_gauge_rings(display, gauge[i])
  524.     end
  525. end
  526.  
  527. -------------------------------------------------------------------------------
  528. --                                                                         MAIN
  529. function conky_main()
  530.     if conky_window == nil then
  531.         return
  532.     end
  533.  
  534.     local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
  535.     local display = cairo_create(cs)
  536.    
  537.     local updates = conky_parse('${updates}')
  538.     update_num = tonumber(updates)
  539.    
  540.     if update_num > 5 then
  541.         go_clock_rings(display)
  542.         go_gauge_rings(display)
  543.     end
  544.    
  545.     cairo_surface_destroy(cs)
  546.     cairo_destroy(display)
  547. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top