Code:
--yearclock by mrpeachy 2010
require 'cairo'
function conky_draw_fig()
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
cairo_set_line_width (cr,1)
hx0=200
hy0=200
hrad1=80
hrad2=hrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
hr=os.date("%H")*60*60
mn=os.date("%M")*60
sc=os.date("%S")
hrs=hr+mn+sc
mns=mn+sc
hrad3=hrad2+10
arc=((2*math.pi/360)*((360/(24*60*60)*hrs)))
hx1=0+hrad2*(math.sin(arc))
hy1=0-hrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrs)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrs)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--minutes
mrad1=hrad3
mrad2=mrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
cairo_arc (cr,hx0,hy0,mrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mrad2,0,2*math.pi)
cairo_stroke (cr)
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+mrad1*(math.sin(arc))
my1=0-mrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+mrad2*(math.sin(arc))
my2=0-mrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
mrad3=mrad2+10
arc=((2*math.pi/360)*((360/(60*60)*mns)))
mx1=0+mrad2*(math.sin(arc))
my1=0-mrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(mns)-4)
mx2=0+mrad3*(math.sin(arc))
my2=0-mrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(mns)+4)
mx3=0+mrad3*(math.sin(arc))
my3=0-mrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--seconds
srad1=mrad3
srad2=srad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
srad3=srad2+10
arc=((2*math.pi/360)*((360/(60)*sc)))
sx1=0+srad2*(math.sin(arc))
sy1=0-srad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sc))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sc))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--year
month=os.date("%m")
day=os.date("%d")
mnrad1=hrad1-40
mnrad2=mnrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--lines of months
year=os.date("%G")
t1 = os.time( { year=year,month=03,day=01,hour=00,min=0,sec=0} );
t2 = os.time( { year=year,month=02,day=01,hour=00,min=0,sec=0} );
feb=(os.difftime(t1,t2))/(24*60*60)
jan=31*24*60*60
feb=jan+(feb*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec }
year=os.date("%G")
t1 = os.time( { year=year,month=03,day=01,hour=00,min=0,sec=0} );
t2 = os.time( { year=year,month=02,day=01,hour=00,min=0,sec=0} );
feb=(os.difftime(t1,t2))/(24*60*60)
yeardays=31+feb+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
hr=os.date("%I")
doy=os.date("%j")
yrsecs=((doy-1)*24*60*60)+(sc)+(mn*60)+(hr*60*60)
mnrad3=mnrad2+10
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+mnrad2*(math.sin(arc))
mny1=0-mnrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--month
yrad1=mnrad3
yrad2=yrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
cairo_arc (cr,hx0,hy0,yrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,yrad2,0,2*math.pi)
cairo_stroke (cr)
monthdays = { 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
for i=1,monthdays[tonumber(month)] do
arc=((2*math.pi/360)*((360/monthdays[tonumber(month)])*(i)))
yx1=0+yrad1*(math.sin(arc))
yy1=0-yrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[tonumber(month)])*(i)))
yx2=0+yrad2*(math.sin(arc))
yy2=0-yrad2*(math.cos(arc))
cairo_move_to (cr,hx0+yx1,hy0+yy1)
cairo_line_to (cr,hx0+yx2,hy0+yy2)
cairo_stroke (cr)
end
yrad3=yrad2+10
arc=(2*math.pi/360)*((360/monthdays[tonumber(month)])*(day))
yx1=0+yrad2*(math.sin(arc))
yy1=0-yrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthdays[tonumber(month)])*((day))+4)
yx2=0+yrad3*(math.sin(arc))
yy2=0-yrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthdays[tonumber(month)])*((day))-4)
yx3=0+yrad3*(math.sin(arc))
yy3=0-yrad3*(math.cos(arc))
cairo_move_to (cr,hx0+yx1,hy0+yy1)
cairo_line_to (cr,hx0+yx2,hy0+yy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+yx1,hy0+yy1)
cairo_line_to (cr,hx0+yx3,hy0+yy3)
cairo_stroke (cr)
--system monitor
--cpu
--cairo_set_line_width (cr,1)
--hx0=385
--hy0=383
--hrad1=40
--hrad2=hrad1+10
--br1,bg1,bb1,ba1=1,1,1,1
--cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
--cairo_stroke (cr)
--cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
--cairo_stroke (cr)
--for i=1,100 do
--arc=(2*math.pi/100)*i
--hx1=0+hrad1*(math.sin(arc))
--hy1=0-hrad1*(math.cos(arc))
--arc=(2*math.pi/100)*i
--hx2=0+hrad2*(math.sin(arc))
--hy2=0-hrad2*(math.cos(arc))
--cairo_move_to (cr,hx0+hx1,hy0+hy1)
--cairo_line_to (cr,hx0+hx2,hy0+hy2)
--cairo_stroke (cr)
--end
--cpu=conky_parse('${cpu}')
--hrad3=hrad2+10
--arc=(2*math.pi/360)*((360/100)*((cpu)))
--hx1=0+hrad2*(math.sin(arc))
--hy1=0-hrad2*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((cpu))+4)
--hx2=0+hrad3*(math.sin(arc))
--hy2=0-hrad3*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((cpu))-4)
--hx3=0+hrad3*(math.sin(arc))
--hy3=0-hrad3*(math.cos(arc))
--cairo_move_to (cr,hx0+hx1,hy0+hy1)
--cairo_line_to (cr,hx0+hx2,hy0+hy2)
--cairo_stroke (cr)
--cairo_move_to (cr,hx0+hx1,hy0+hy1)
--cairo_line_to (cr,hx0+hx3,hy0+hy3)
--cairo_stroke (cr)
----memory
--mrad1=hrad3
--mrad2=mrad1+10
--br1,bg1,bb1,ba1=1,1,1,1
--cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--cairo_arc (cr,hx0,hy0,mrad1,0,2*math.pi)
--cairo_stroke (cr)
--cairo_arc (cr,hx0,hy0,mrad2,0,2*math.pi)
--cairo_stroke (cr)
--for i=1,100 do
--arc=(2*math.pi/100)*i
--mx1=0+mrad1*(math.sin(arc))
--my1=0-mrad1*(math.cos(arc))
--arc=(2*math.pi/100)*i
--mx2=0+mrad2*(math.sin(arc))
--my2=0-mrad2*(math.cos(arc))
--cairo_move_to (cr,hx0+mx1,hy0+my1)
--cairo_line_to (cr,hx0+mx2,hy0+my2)
--cairo_stroke (cr)
--end
--mem=tonumber(conky_parse('${memperc}'))
--mrad3=mrad2+10
--arc=(2*math.pi/360)*((360/100)*((mem)))
--mx1=0+mrad2*(math.sin(arc))
--my1=0-mrad2*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((mem))+4)
--mx2=0+mrad3*(math.sin(arc))
--my2=0-mrad3*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((mem))-4)
--mx3=0+mrad3*(math.sin(arc))
--my3=0-mrad3*(math.cos(arc))
--cairo_move_to (cr,hx0+mx1,hy0+my1)
--cairo_line_to (cr,hx0+mx2,hy0+my2)
--cairo_stroke (cr)
--cairo_move_to (cr,hx0+mx1,hy0+my1)
--cairo_line_to (cr,hx0+mx3,hy0+my3)
--cairo_stroke (cr)
----fs_used root
--srad1=mrad3
--srad2=srad1+10
--br1,bg1,bb1,ba1=1,1,1,1
--cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
--cairo_stroke (cr)
--cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
--cairo_stroke (cr)
--for i=1,100 do
--arc=((2*math.pi/360)*((360/100)*i))
--sx1=0+srad1*(math.sin(arc))
--sy1=0-srad1*(math.cos(arc))
--arc=((2*math.pi/360)*((360/100)*i))
--sx2=0+srad2*(math.sin(arc))
--sy2=0-srad2*(math.cos(arc))
--cairo_move_to (cr,hx0+sx1,hy0+sy1)
--cairo_line_to (cr,hx0+sx2,hy0+sy2)
--cairo_stroke (cr)
--end
--fsr=conky_parse('${fs_used_perc /}')
--srad3=srad2+10
--arc=((2*math.pi/360)*((360/(100)*fsr)))
--sx1=0+srad2*(math.sin(arc))
--sy1=0-srad2*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((fsr))-4)
--sx2=0+srad3*(math.sin(arc))
--sy2=0-srad3*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((fsr))+4)
--sx3=0+srad3*(math.sin(arc))
--sy3=0-srad3*(math.cos(arc))
--cairo_move_to (cr,hx0+sx1,hy0+sy1)
--cairo_line_to (cr,hx0+sx2,hy0+sy2)
--cairo_stroke (cr)
--cairo_move_to (cr,hx0+sx1,hy0+sy1)
--cairo_line_to (cr,hx0+sx3,hy0+sy3)
--cairo_stroke (cr)
----fs used home
--mnrad1=srad3
--mnrad2=mnrad1+10
--br1,bg1,bb1,ba1=1,1,1,1
--cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
--cairo_stroke (cr)
--cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
--cairo_stroke (cr)
--for i=1,100 do
--arc=((2*math.pi/360)*((360/100)*i))
--mnx1=0+mnrad1*(math.sin(arc))
--mny1=0-mnrad1*(math.cos(arc))
--arc=((2*math.pi/360)*((360/100)*i))
--mnx2=0+mnrad2*(math.sin(arc))
--mny2=0-mnrad2*(math.cos(arc))
--cairo_move_to (cr,hx0+mnx1,hy0+mny1)
--cairo_line_to (cr,hx0+mnx2,hy0+mny2)
--cairo_stroke (cr)
--end
--fsh=conky_parse('${fs_used_perc /home}')
--mnrad3=mnrad2+10
--arc=((2*math.pi/360)*((360/(100)*fsh)))
--mnx1=0+mnrad2*(math.sin(arc))
--mny1=0-mnrad2*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((fsh))-4)
--mnx2=0+mnrad3*(math.sin(arc))
--mny2=0-mnrad3*(math.cos(arc))
--arc=(2*math.pi/360)*((360/100)*((fsh))+4)
--mnx3=0+mnrad3*(math.sin(arc))
--mny3=0-mnrad3*(math.cos(arc))
--cairo_move_to (cr,hx0+mnx1,hy0+mny1)
--cairo_line_to (cr,hx0+mnx2,hy0+mny2)
--cairo_stroke (cr)
--cairo_move_to (cr,hx0+mnx1,hy0+mny1)
--cairo_line_to (cr,hx0+mnx3,hy0+mny3)
--cairo_stroke (cr)
--cairo_arc (cr,hx0,hy0,mnrad3,0,2*math.pi)
--cairo_stroke (cr)
end
end
And the images - comes with everything, even the red.png test image I used to "centre" the images. I archived the directory: ~/Conky/images/
Bookmarks