i posted a lua script that gave dials some time ago but i didn't really get around to finishing the script as the dials turned out to be rather processor intensive
but i have reworked the script and used a different mechanism to draw the dials and they are significantly less intensive than before
--dials version 2 by mrpeachy dec 2011
require 'cairo'
function conky_dial()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--#########################################################################################################
--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS--SETTINGS
--cut below section, paste below and edit settings for new dial-------
--you do not have to set all vales as defualt values are set elsewhere
t={--this table contains the settings for one table
input=conky_parse("${cpu}"),--input number to display
scale_h=50,--range of numbers in scale, ie if 50, then when 50 at top, 0 at bottom
input_max=100,--max of input
scale=5,--distance in pixels between units in the scale
ten_w=13,--width of tens lines
ten_nw=20,--position of tens numbers from left/bottom edge
ten_num=1,--1 to show tens numbers,0 not to show
five_w=10,--width of 5 lines,0 not to show fives lines
five_nw=20,--position of fives numbers from left/bottom edge
five_num=1,-- 1 to show fives numbers, 0 not to show
one_w=5,--width of units lines, 0 not to show lines
one_nw=15,--position of units numbers from left/bottom edge
one_num=0,--1 to show units, 0 not to show
dial_w=55,--width of dial
dial_hadj=10,--adds length to dial at top to hide numbers that may extend past edge
font="Mono",--font
fsize=12,--font size
tadj=-5,--adjust text,positive numbers move text down/right, negative up/left
lines=3,--set position of lines, 1=left,2=right,3=both
xpos=100.5,--position of bottom left hand corner
ypos=350.5,
vorh=1,--orientation of dial, 1=vertical, 2=horizontal
}
drawdial(t)
--cut above section, paste below and edit settings for new dial-------
--cut below section, paste below and edit settings for new dial-------
t={
input=conky_parse("${memperc}"),
xpos=250,
ypos=270.5,
vorh=2,
}
drawdial(t)
--cut above section, paste below and edit settings for new dial-------
--cut below section, paste below and edit settings for new dial-------
t={
input=conky_parse("${fs_used_perc /home}"),
xpos=100,
ypos=270.5,
vorh=2,
}
drawdial(t)
--cut above section, paste below and edit settings for new dial-------
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
function drawdial(t)
--set variable and defaults-----------------------------------------------
if t.input~=nil then input=t.input else input=conky_parse("${cpu}") end
if t.scale_h~=nil then scale_h=t.scale_h else scale_h=50 end
if t.input_max~=nil then input_max=t.input_max else input_max=100 end
if t.scale~=nil then scale=t.scale else scale=5 end
if t.ten_w~=nil then ten_w=t.ten_w else ten_w=13 end
if t.ten_nw~=nil then ten_nw=t.ten_nw else ten_nw=15 end
if t.ten_num~=nil then ten_num=t.ten_num else ten_num=1 end
if t.five_w~=nil then five_w=t.five_w else five_w=10 end
if t.five_nw~=nil then five_nw=t.five_nw else five_nw=15 end
if t.five_num~=nil then five_num=t.five_num else five_num=1 end
if t.one_w~=nil then one_w=t.one_w else one_w=5 end
if t.one_nw~=nil then one_nw=t.one_nw else one_nw=15 end
if t.one_num~=nil then one_num=t.one_num else one_num=0 end
if t.dial_w~=nil then dial_w=t.dial_w else dial_w=55 end
if t.dial_hadj~=nil then dial_hadj=t.dial_hadj else dial_hadj=10 end
if t.font~=nil then font=t.font else font="Mono" end
if t.fsize~=nil then fsize=t.fsize else fsize=20 end
if t.tadj~=nil then tadj=t.tadj else tadj=5 end
if t.lines~=nil then lines=t.lines else lines=3 end
if t.xpos~=nil then xpos=t.xpos else xpos=300.5 end
if t.ypos~=nil then ypos=t.ypos else ypos=350.5 end
if t.vorh~=nil then vorh=t.vorh else vorh=1 end
--------------------------------------------------------------------------
--set tables
scale_t={}
for i=1,scale_h do
scale_t[i]=input+(scale_h/2)-(i-1)
end
table.sort(scale_t)
table.insert(scale_t,1,scale_t[1]-1)
tens={}
fives={}
ones={}
local function ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
--sort positions for tens fives and ones----------------------------------------
for i,v in ipairs(scale_t) do
if ends(v,"0")==true then
table.insert(tens,i)
t=1
else
t=0
end
if ends(v,"5")==true then
table.insert(fives,i)
f=1
else
f=0
end
if t==0 and f==0 then
table.insert(ones,i)
end
end
--draw vertical or horizontal dial##########################################################################
if vorh==1 then
--background black
cairo_set_source_rgba (cr,0,0,0,1)
cairo_rectangle (cr,xpos,ypos,((((scale_h+2)*scale))+dial_hadj),-dial_w)
cairo_fill (cr)
--lines and numbers
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,1)
adj10=tadj
adj5=tadj
adj1=tadj
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
for i=1,#tens do
--ten lines
if ten_w~=0 then
if lines==1 or lines==3 then
cairo_move_to (cr,xpos+(tens[i]*scale),ypos)
cairo_rel_line_to (cr,0,-ten_w)
cairo_stroke (cr)
end
if lines==2 or lines==3 then
cairo_move_to (cr,xpos+(tens[i]*scale),ypos-dial_w)
cairo_rel_line_to (cr,0,ten_w)
cairo_stroke (cr)
end
end
--ten numbers
if ten_num==1 then
text=scale_t[tens[i]]
if text<0 then text=input_max+text end
if text>(input_max-1) then text=text-input_max end
if text==0 then text="0"..text end
cairo_move_to (cr,xpos+(tens[i]*scale)+(adj10),(ypos-ten_nw))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
end--for i tens
---------------------------------------------------
for i=1,#fives do
--five lines
if five_w~=0 then
if lines==1 or lines==3 then
cairo_move_to (cr,xpos+(fives[i]*scale),ypos)
cairo_rel_line_to (cr,0,-five_w)
cairo_stroke (cr)
end
if lines==2 or lines==3 then
cairo_move_to (cr,xpos+(fives[i]*scale),ypos-dial_w)
cairo_rel_line_to (cr,0,five_w)
cairo_stroke (cr)
end
end
--five numbers
if five_num==1 then
text=scale_t[fives[i]]
if text<0 then text=input_max+text end
if text>(input_max-1) then text=text-input_max end
if text<10 then text="0"..text end
cairo_move_to (cr,xpos+(fives[i]*scale)+(adj5),(ypos-five_nw))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
end--for i =fives
-------------------------------------------------------------
for i=1,#ones do
--ones lines
if one_w~=0 then
if lines==1 or lines==3 then
cairo_move_to (cr,xpos+(ones[i]*scale),ypos)
cairo_rel_line_to (cr,0,-one_w)
cairo_stroke (cr)
end
if lines==2 or lines==3 then
cairo_move_to (cr,xpos+(ones[i]*scale),ypos-dial_w)
cairo_rel_line_to (cr,0,one_w)
cairo_stroke (cr)
end
end
--one numbers
if one_num==1 then
text=scale_t[ones[i]]
if text<0 then text=input_max+text end
if text>(input_max-1) then text=text-input_max end
if text<10 then text="0"..text end
cairo_move_to (cr,xpos+(ones[i]*scale)+(adj1),(ypos-one_nw))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
end--for i =ones
--gradient-----------------------------------------------------
rh=-dial_w
rw=((((scale_h+2)*scale))+dial_hadj)
local pat = cairo_pattern_create_linear (xpos,0,xpos+rw,0);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.95, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.5, 0, 0, 0, 0);
cairo_pattern_add_color_stop_rgba (pat, 0.05, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
cairo_rectangle (cr,xpos,ypos,rw, rh);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
--indicator
cairo_set_source_rgba (cr,1,1,1,1)
cairo_move_to (cr,xpos+(((scale_h+2)*scale)/2),ypos)
cairo_rel_line_to (cr,0,-dial_w)
cairo_stroke (cr)
--outline
cairo_rectangle (cr,xpos,ypos,((((scale_h+2)*scale))+dial_hadj),-dial_w)
cairo_stroke (cr)
end--if vorh=1
--#########################################################################################
if vorh==2 then
--background black
cairo_set_source_rgba (cr,0,0,0,1)
cairo_rectangle (cr,xpos,ypos,dial_w,((-1*((scale_h+2)*scale))-dial_hadj))
cairo_fill (cr)
--lines and numbers
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,1)
adj10=tadj
adj5=tadj
adj1=tadj
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
for i=1,#tens do
--ten lines
if ten_w~=0 then
if lines==1 or lines==3 then
cairo_move_to (cr,xpos,ypos-(tens[i]*scale))
cairo_rel_line_to (cr,ten_w,0)
cairo_stroke (cr)
end
if lines==2 or lines==3 then
cairo_move_to (cr,xpos+dial_w,ypos-(tens[i]*scale))
cairo_rel_line_to (cr,-ten_w,0)
cairo_stroke (cr)
end
end
--ten numbers
if ten_num==1 then
text=scale_t[tens[i]]
if text<0 then text=input_max+text end
if text>(input_max-1) then text=text-input_max end
if text==0 then text="0"..text end
cairo_move_to (cr,xpos+ten_nw,(ypos-(tens[i]*scale))+(adj10))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
end--for i tens
---------------------------------------------------
for i=1,#fives do
--five lines
if five_w~=0 then
if lines==1 or lines==3 then
cairo_move_to (cr,xpos,ypos-(fives[i]*scale))
cairo_rel_line_to (cr,five_w,0)
cairo_stroke (cr)
end
if lines==2 or lines==3 then
cairo_move_to (cr,xpos+dial_w,ypos-(fives[i]*scale))
cairo_rel_line_to (cr,-five_w,0)
cairo_stroke (cr)
end
end
--five numbers
if five_num==1 then
text=scale_t[fives[i]]
if text<0 then text=input_max+text end
if text>(input_max-1) then text=text-input_max end
if text<10 then text="0"..text end
cairo_move_to (cr,xpos+five_nw,(ypos-(fives[i]*scale)+(adj5)))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
end--for i =fives
-------------------------------------------------------------
for i=1,#ones do
--ones lines
if one_w~=0 then
if lines==1 or lines==3 then
cairo_move_to (cr,xpos,ypos-(ones[i]*scale))
cairo_rel_line_to (cr,one_w,0)
cairo_stroke (cr)
end
if lines==2 or lines==3 then
cairo_move_to (cr,xpos+dial_w,ypos-(ones[i]*scale))
cairo_rel_line_to (cr,-one_w,0)
cairo_stroke (cr)
end
end
--one numbers
if one_num==1 then
text=scale_t[ones[i]]
if text<0 then text=input_max+text end
if text>(input_max-1) then text=text-input_max end
if text<10 then text="0"..text end
cairo_move_to (cr,xpos+one_nw,(ypos-(ones[i]*scale)+(adj1)))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
end--for i =ones
--gradient-----------------------------------------------------
rh=((-1*((scale_h+2)*scale))-dial_hadj)
rw=dial_w
local pat = cairo_pattern_create_linear (0,ypos,0,ypos+rh);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.95, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.5, 0, 0, 0, 0);
cairo_pattern_add_color_stop_rgba (pat, 0.05, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
cairo_rectangle (cr,xpos,ypos,rw, rh);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
--indicator
cairo_set_source_rgba (cr,1,1,1,1)
cairo_move_to (cr,xpos,ypos-(((scale_h+2)*scale)/2))
cairo_rel_line_to (cr,dial_w,0)
cairo_stroke (cr)
--outline
cairo_rectangle (cr,xpos,ypos,dial_w,((-1*((scale_h+2)*scale))-dial_hadj))
cairo_stroke (cr)
end--if vorh=2
end--drawdial