aboutsummaryrefslogtreecommitdiffstats
path: root/.conky/cronograph/scripts
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-13 21:12:21 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-13 21:12:21 +0800
commit78f7be4e4b6501b15b5fefc9f7824bbadf0daf2a (patch)
treeb761e28709e4a6f45458c323b8870150827ef831 /.conky/cronograph/scripts
parente1ce158f65c472b7c8d14c04fce94c85bc881a6c (diff)
downloaddotfiles-78f7be4e4b6501b15b5fefc9f7824bbadf0daf2a.tar.bz2
Added various dotfiles.
* Xresources * profile, xprofile, xinitrc * bash (aliases, logout, profile, rc, completion) * gitconfig * gtkrc and gtk-bookmarks * i3 configs (with py3status configs) * i3status.conf * lftp/rc * tmux.conf * xbindkeysrc * mpdconf * ncmpcpp (config and keys) * sbclrc * vifm (vifmrc, colors) * urxvt (perl extensions) * conkyrc (and conky/cronograph configs)
Diffstat (limited to '.conky/cronograph/scripts')
-rwxr-xr-x.conky/cronograph/scripts/blinkingLED3
-rwxr-xr-x.conky/cronograph/scripts/clock_rings.lua358
-rwxr-xr-x.conky/cronograph/scripts/multi_rings.lua375
3 files changed, 736 insertions, 0 deletions
diff --git a/.conky/cronograph/scripts/blinkingLED b/.conky/cronograph/scripts/blinkingLED
new file mode 100755
index 0000000..3f4c814
--- /dev/null
+++ b/.conky/cronograph/scripts/blinkingLED
@@ -0,0 +1,3 @@
+${image $HOME/.conky/cronograph/images/Blank.png -p 129, 241 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image $HOME/.conky/cronograph/images/Blue.png -p 129, 241 -s 40x40}${endif}
+${image $HOME/.conky/cronograph/images/Blank.png -p 19, 129 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image $HOME/.conky/cronograph/images/Blue.png -p 19, 129 -s 40x40}${endif}
+${image $HOME/.conky/cronograph/images/Blank.png -p 240, 129 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image $HOME/.conky/cronograph/images/Blue.png -p 240, 129 -s 40x40}${endif}
diff --git a/.conky/cronograph/scripts/clock_rings.lua b/.conky/cronograph/scripts/clock_rings.lua
new file mode 100755
index 0000000..fb6a838
--- /dev/null
+++ b/.conky/cronograph/scripts/clock_rings.lua
@@ -0,0 +1,358 @@
+--[[
+Clock Rings by londonali1010 (2009)
+
+This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua script.
+
+IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement near the end of the script uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num > 5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num > 3; conversely if you update Conky every 0.5s, you should use update_num > 10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.
+
+To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
+ lua_load ~/scripts/clock_rings-v1.1.1.lua
+ lua_draw_hook_pre clock_rings
+
+Changelog:
++ v1.1.1 -- Fixed minor bug that caused the script to crash if conky_parse() returns a nil value (20.10.2009)
++ v1.1 -- Added colour option for clock hands (07.10.2009)
++ v1.0 -- Original release (30.09.2009)
+]]
+
+settings_table = {
+ {
+ -- Edit this table to customise your rings.
+ -- You can create more rings simply by adding more elements to settings_table.
+ -- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
+ name='time',
+ -- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
+ arg='%I.%M',
+ -- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
+ max=12,
+ -- "bg_colour" is the colour of the base ring.
+ bg_colour=0xFFFFFF,
+ -- "bg_alpha" is the alpha value of the base ring.
+ bg_alpha=0.1,
+ -- "fg_colour" is the colour of the indicator part of the ring.
+ fg_colour=0xFFFFFF,
+ -- "fg_alpha" is the alpha value of the indicator part of the ring.
+ fg_alpha=0.5,
+ -- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
+ x=150, y=150,
+ -- "radius" is the radius of the ring.
+ radius=135,
+ -- "thickness" is the thickness of the ring, centred around the radius.
+ thickness=4,
+ -- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
+ start_angle=0,
+ -- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
+ end_angle=360
+ },
+ {
+ name='time',
+ arg='%M.%S',
+ max=60,
+ bg_colour=0xFFFFFF,
+ bg_alpha=0.1,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.5,
+ x=150, y=150,
+ radius=140,
+ thickness=4,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='time',
+ arg='%S',
+ max=60,
+ bg_colour=0xFFFFFF,
+ bg_alpha=0.1,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.5,
+ x=150, y=150,
+ radius=145,
+ thickness=4,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0x000000,
+ bg_alpha=0.1,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=150, y=150,
+ radius=66,
+ thickness=130,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=150, y=150,
+ radius=1,
+ thickness=10,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=85, y=150,
+ radius=30,
+ thickness=1,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0x000000,
+ bg_alpha=0.3,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=85, y=150,
+ radius=15,
+ thickness=27,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=85, y=150,
+ radius=1,
+ thickness=2,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=215, y=150,
+ radius=30,
+ thickness=1,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0x000000,
+ bg_alpha=0.3,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=215, y=150,
+ radius=15,
+ thickness=27,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=215, y=150,
+ radius=1,
+ thickness=2,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=150, y=75,
+ radius=25,
+ thickness=1,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0x000000,
+ bg_alpha=0.3,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=150, y=75,
+ radius=13,
+ thickness=22,
+ start_angle=0,
+ end_angle=360
+ },
+ {
+ name='',
+ arg='',
+ max=100,
+ bg_colour=0xFFFFFF,
+ bg_alpha=1.0,
+ fg_colour=0xFFFFFF,
+ fg_alpha=0.0,
+ x=150, y=75,
+ radius=1,
+ thickness=2,
+ start_angle=0,
+ end_angle=360
+ },
+ }
+
+-- Use these settings to define the origin and extent of your clock.
+
+clock_r=127
+
+-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.
+
+clock_x=150
+clock_y=150
+
+-- Colour & alpha of the clock hands
+
+clock_colour=0xFFFFFF
+clock_alpha=1
+
+-- Do you want to show the seconds hand?
+
+show_seconds=true
+
+require 'cairo'
+
+function rgb_to_r_g_b(colour,alpha)
+ return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
+end
+
+function draw_ring(cr,t,pt)
+ local w,h=conky_window.width,conky_window.height
+
+ local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
+ local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
+
+ local angle_0=sa*(2*math.pi/360)-math.pi/2
+ local angle_f=ea*(2*math.pi/360)-math.pi/2
+ local t_arc=t*(angle_f-angle_0)
+
+ -- Draw background ring
+
+ cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
+ cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
+ cairo_set_line_width(cr,ring_w)
+ cairo_stroke(cr)
+
+ -- Draw indicator ring
+
+ cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
+ cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
+ cairo_stroke(cr)
+end
+
+function draw_clock_hands(cr,xc,yc)
+ local secs,mins,hours,secs_arc,mins_arc,hours_arc
+ local xh,yh,xm,ym,xs,ys
+
+ secs=os.date("%S")
+ mins=os.date("%M")
+ hours=os.date("%I")
+
+ secs_arc=(2*math.pi/60)*secs
+ mins_arc=(2*math.pi/60)*mins+secs_arc/60
+ hours_arc=(2*math.pi/12)*hours+mins_arc/12
+
+ -- Draw hour hand
+
+ xh=xc+0.7*clock_r*math.sin(hours_arc)
+ yh=yc-0.7*clock_r*math.cos(hours_arc)
+ cairo_move_to(cr,xc,yc)
+ cairo_line_to(cr,xh,yh)
+
+ cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
+ cairo_set_line_width(cr,5)
+ cairo_set_source_rgba(cr,rgb_to_r_g_b(clock_colour,clock_alpha))
+ cairo_stroke(cr)
+
+ -- Draw minute hand
+
+ xm=xc+clock_r*math.sin(mins_arc)
+ ym=yc-clock_r*math.cos(mins_arc)
+ cairo_move_to(cr,xc,yc)
+ cairo_line_to(cr,xm,ym)
+
+ cairo_set_line_width(cr,3)
+ cairo_stroke(cr)
+
+ -- Draw seconds hand
+
+ if show_seconds then
+ xs=xc+clock_r*math.sin(secs_arc)
+ ys=yc-clock_r*math.cos(secs_arc)
+ cairo_move_to(cr,xc,yc)
+ cairo_line_to(cr,xs,ys)
+
+ cairo_set_line_width(cr,1)
+ cairo_stroke(cr)
+ end
+end
+
+function conky_clock_rings()
+ local function setup_rings(cr,pt)
+ local str=''
+ local value=0
+
+ str=string.format('${%s %s}',pt['name'],pt['arg'])
+ str=conky_parse(str)
+
+ value=tonumber(str)
+ if value == nil then value = 0 end
+ pct=value/pt['max']
+
+ draw_ring(cr,pct,pt)
+ end
+
+ -- Check that Conky has been running for at least 5s
+
+ 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=cairo_create(cs)
+
+ local updates=conky_parse('${updates}')
+ update_num=tonumber(updates)
+
+ if update_num>5 then
+ for i in pairs(settings_table) do
+ setup_rings(cr,settings_table[i])
+ end
+ end
+
+ draw_clock_hands(cr,clock_x,clock_y)
+end
diff --git a/.conky/cronograph/scripts/multi_rings.lua b/.conky/cronograph/scripts/multi_rings.lua
new file mode 100755
index 0000000..b9735b2
--- /dev/null
+++ b/.conky/cronograph/scripts/multi_rings.lua
@@ -0,0 +1,375 @@
+--==============================================================================
+-- multi_rings.lua
+--
+-- author : SLK
+-- version : v2011011601
+-- license : Distributed under the terms of GNU GPL version 2 or later
+--
+--==============================================================================
+
+require 'cairo'
+
+--------------------------------------------------------------------------------
+-- clock DATA
+-- HOURS
+clock_h = {
+ {
+ name='time', arg='%H', max_value=12,
+ x=150, y=150,
+ graph_radius=140,
+ graph_thickness=3,
+ graph_unit_angle=30, graph_unit_thickness=5,
+ graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
+ graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
+ txt_radius=100,
+ txt_weight=1, txt_size=10.0,
+ txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
+ graduation_radius=125,
+ graduation_thickness=10, graduation_mark_thickness=2,
+ graduation_unit_angle=30,
+ graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0,
+ },
+}
+-- MINUTES
+clock_m = {
+ {
+ name='time', arg='%M', max_value=60,
+ x=150, y=150,
+ graph_radius=100,
+ graph_thickness=3,
+ graph_unit_angle=6, graph_unit_thickness=3,
+ graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
+ graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
+ txt_radius=100,
+ txt_weight=0, txt_size=9.0,
+ txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
+ graduation_radius=57,
+ graduation_thickness=0, graduation_mark_thickness=2,
+ graduation_unit_angle=30,
+ graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
+ },
+}
+-- SECONDS
+clock_s = {
+ {
+ name='time', arg='%S', max_value=60,
+ x=150, y=150,
+ graph_radius=50,
+ graph_thickness=3,
+ graph_unit_angle=6, graph_unit_thickness=3,
+ graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
+ graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
+ txt_radius=100,
+ txt_weight=0, txt_size=12.0,
+ txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
+ graduation_radius=0,
+ graduation_thickness=0, graduation_mark_thickness=0,
+ graduation_unit_angle=0,
+ graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
+ },
+}
+
+--------------------------------------------------------------------------------
+-- gauge DATA
+gauge = {
+{
+ name='cpu', arg='cpu0', max_value=100,
+ x=85, y=150,
+ graph_radius=14,
+ graph_thickness=27,
+ graph_start_angle=0,
+ graph_unit_angle=3.5, graph_unit_thickness=3.0,
+ graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
+ graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
+ hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0,
+ txt_radius=1,
+ txt_weight=0, txt_size=8.0,
+ txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
+ graduation_radius=27,
+ graduation_thickness=4, graduation_mark_thickness=4,
+ graduation_unit_angle=30,
+ graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0,
+ caption='',
+ caption_weight=1, caption_size=8.0,
+ caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
+},
+{
+ name='memperc', arg='', max_value=100,
+ x=215, y=150,
+ graph_radius=14,
+ graph_thickness=27,
+ graph_start_angle=0,
+ graph_unit_angle=3.5, graph_unit_thickness=3.0,
+ graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
+ graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
+ hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0,
+ txt_radius=1,
+ txt_weight=0, txt_size=8.0,
+ txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
+ graduation_radius=27,
+ graduation_thickness=4, graduation_mark_thickness=4,
+ graduation_unit_angle=30,
+ graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0,
+ caption='',
+ caption_weight=1, caption_size=8.0,
+ caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
+},
+{
+ name='fs_used_perc', arg='/', max_value=100,
+ x=150, y=75,
+ graph_radius=10,
+ graph_thickness=23,
+ graph_start_angle=0,
+ graph_unit_angle=3.5, graph_unit_thickness=3.0,
+ graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0,
+ graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0,
+ hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0,
+ txt_radius=1,
+ txt_weight=0, txt_size=8.0,
+ txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
+ graduation_radius=22,
+ graduation_thickness=4, graduation_mark_thickness=4,
+ graduation_unit_angle=30,
+ graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0,
+ caption='',
+ caption_weight=1, caption_size=8.0,
+ caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0,
+},
+}
+
+-------------------------------------------------------------------------------
+-- rgb_to_r_g_b
+-- converts color in hexa to decimal
+--
+function rgb_to_r_g_b(colour, alpha)
+ return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
+end
+
+-------------------------------------------------------------------------------
+-- angle_to_position
+-- convert degree to rad and rotate (0 degree is top/north)
+--
+function angle_to_position(start_angle, current_angle)
+ local pos = current_angle + start_angle
+ return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
+end
+
+-------------------------------------------------------------------------------
+-- draw_clock_ring
+-- displays clock
+--
+function draw_clock_ring(display, data, value)
+ local max_value = data['max_value']
+ local x, y = data['x'], data['y']
+ local graph_radius = data['graph_radius']
+ local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
+ local graph_unit_angle = data['graph_unit_angle']
+ local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
+ local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
+
+ -- background ring
+ cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi)
+ cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
+ cairo_set_line_width(display, graph_thickness)
+ cairo_stroke(display)
+
+ -- arc of value
+ local val = (value % max_value)
+ local i = 1
+ while i <= val do
+ 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))
+ cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha))
+ cairo_stroke(display)
+ i = i + 1
+ end
+ local angle = (graph_unit_angle * i) - graph_unit_thickness
+
+ -- graduations marks
+ local graduation_radius = data['graduation_radius']
+ local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
+ local graduation_unit_angle = data['graduation_unit_angle']
+ local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
+ if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
+ local nb_graduation = 360 / graduation_unit_angle
+ local i = 1
+ while i <= nb_graduation do
+ cairo_set_line_width(display, graduation_thickness)
+ 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))
+ cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
+ cairo_stroke(display)
+ cairo_set_line_width(display, graph_thickness)
+ i = i + 1
+ end
+ end
+
+ -- text
+ local txt_radius = data['txt_radius']
+ local txt_weight, txt_size = data['txt_weight'], data['txt_size']
+ local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
+ local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2)))
+ local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2)))
+ cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight);
+ cairo_set_font_size (display, txt_size);
+ cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha));
+ cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3);
+ cairo_show_text (display, value);
+ cairo_stroke (display);
+end
+
+-------------------------------------------------------------------------------
+-- draw_gauge_ring
+-- displays gauges
+--
+function draw_gauge_ring(display, data, value)
+ local max_value = data['max_value']
+ local x, y = data['x'], data['y']
+ local graph_radius = data['graph_radius']
+ local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
+ local graph_start_angle = data['graph_start_angle']
+ local graph_unit_angle = data['graph_unit_angle']
+ local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
+ local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
+ local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
+ local graph_end_angle = (max_value * graph_unit_angle) % 360
+
+ -- background ring
+ cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
+ cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
+ cairo_set_line_width(display, graph_thickness)
+ cairo_stroke(display)
+
+ -- arc of value
+ local val = value % (max_value + 1)
+ local start_arc = 0
+ local stop_arc = 0
+ local i = 1
+ while i <= val do
+ start_arc = (graph_unit_angle * i) - graph_unit_thickness
+ stop_arc = (graph_unit_angle * i)
+ cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
+ cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
+ cairo_stroke(display)
+ i = i + 1
+ end
+ local angle = start_arc
+
+ -- hand
+ start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
+ stop_arc = (graph_unit_angle * val)
+ cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
+ cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
+ cairo_stroke(display)
+
+ -- graduations marks
+ local graduation_radius = data['graduation_radius']
+ local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
+ local graduation_unit_angle = data['graduation_unit_angle']
+ local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
+ if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
+ local nb_graduation = graph_end_angle / graduation_unit_angle
+ local i = 0
+ while i < nb_graduation do
+ cairo_set_line_width(display, graduation_thickness)
+ start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
+ stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
+ cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
+ cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
+ cairo_stroke(display)
+ cairo_set_line_width(display, graph_thickness)
+ i = i + 1
+ end
+ end
+
+ -- text
+ local txt_radius = data['txt_radius']
+ local txt_weight, txt_size = data['txt_weight'], data['txt_size']
+ local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
+ local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
+ local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
+ cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
+ cairo_set_font_size (display, txt_size)
+ cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
+ cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
+ cairo_show_text (display, value)
+ cairo_stroke (display)
+
+ -- caption
+ local caption = data['caption']
+ local caption_weight, caption_size = data['caption_weight'], data['caption_size']
+ local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
+ local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
+ local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
+ cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
+ cairo_set_font_size (display, caption_size)
+ cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
+ cairo_move_to (display, x + tox + 5, y + toy + 1)
+ -- bad hack but not enough time !
+ if graph_start_angle < 105 then
+ cairo_move_to (display, x + tox - 30, y + toy + 1)
+ end
+ cairo_show_text (display, caption)
+ cairo_stroke (display)
+end
+
+-------------------------------------------------------------------------------
+-- go_clock_rings
+-- loads data and displays clock
+--
+function go_clock_rings(display)
+ local function load_clock_rings(display, data)
+ local str, value = '', 0
+ str = string.format('${%s %s}',data['name'], data['arg'])
+ str = conky_parse(str)
+ value = tonumber(str)
+ draw_clock_ring(display, data, value)
+ end
+
+ for i in pairs(clock_h) do
+ load_clock_rings(display, clock_h[i])
+ end
+ for i in pairs(clock_m) do
+ load_clock_rings(display, clock_m[i])
+ end
+ for i in pairs(clock_s) do
+ load_clock_rings(display, clock_s[i])
+ end
+end
+
+-------------------------------------------------------------------------------
+-- go_gauge_rings
+-- loads data and displays gauges
+--
+function go_gauge_rings(display)
+ local function load_gauge_rings(display, data)
+ local str, value = '', 0
+ str = string.format('${%s %s}',data['name'], data['arg'])
+ str = conky_parse(str)
+ value = tonumber(str)
+ draw_gauge_ring(display, data, value)
+ end
+
+ for i in pairs(gauge) do
+ load_gauge_rings(display, gauge[i])
+ end
+end
+
+-------------------------------------------------------------------------------
+-- MAIN
+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 display = cairo_create(cs)
+
+ local updates = conky_parse('${updates}')
+ update_num = tonumber(updates)
+
+ if update_num > 5 then
+ go_clock_rings(display)
+ go_gauge_rings(display)
+ end
+
+end
+