SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#4351 2012-12-14 14:22:20

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

ragamatrix wrote:
Sector11 wrote:

Red Giant Earth 7 Billion years from now

We are going to "ConkyAstroPhysic"
Impressive and beautifull, I think I'll be too old to have a coffee at this time...

Yea, I think that would be an Ice-Tea day anyway and like you I won't be here.  big_smile


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

Help fund CrunchBang, donate to the project!

#4352 2012-12-14 14:27:46

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

@ mrpeachy - and anyone using the new "chronograph-mrpeachy.lua" (that's what I called it)

There is a fix needed in lines 249 and 250:

200,--string or coodinate for clock center x
200,--string or coodinate for clock center y

to

centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y

abdGO2LH.jpg
to keep the minute hand in line.

I don't know how many times I've told him he has to play with the rest of the kids!

This is a keeper!

Last edited by Sector11 (2012-12-14 14:28:43)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4353 2012-12-14 14:37:03

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

You remember me that I had the idea to make an astro conky but I gave up.
That covered all my screen; and I've found it to "heavy", but the link where you can check the pictures can be usefull for others...
astroconky
example link; but I think the website is under construction :
venus_link

Ok I've founded the new updated website where people can find "precious data"
See that
Here : jcweather.us

Last edited by ragamatrix (2012-12-14 14:50:10)

Offline

#4354 2012-12-14 20:13:21

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

ragamatrix wrote:

You remember me that I had the idea to make an astro conky but I gave up.
That covered all my screen; and I've found it to "heavy", but the link where you can check the pictures can be usefull for others...
astroconky
example link; but I think the website is under construction :
venus_link

Ok I've founded the new updated website where people can find "precious data"
See that
Here : jcweather.us

Yea, I remember that, you could put then in a window - open when you want and close when not needed.  big_smile


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4355 2012-12-14 20:20:43

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

@ mrpeachy

Told you it was a keeper ... here she is under construction (still got conky stuff to do on the bottom):
abtuhuFz.jpg

here it is without the red squares....
acoFMDPD.jpg

Now that's one fine Chronograph - I just retired mine for yours.  wink
And it's not even 24HRS either.

Last edited by Sector11 (2012-12-14 20:22:46)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4356 2012-12-14 21:08:15

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

thanks sector11 smile
ill put up a 24 hour version at some point in the near future!

Last edited by mrpeachy (2012-12-14 21:09:05)

Offline

#4357 2012-12-14 21:36:29

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 459

Re: Conky v1.9 Thread

ragamatrix wrote:

You remember me that I had the idea to make an astro conky but I gave up.
That covered all my screen; and I've found it to "heavy", but the link where you can check the pictures can be usefull for others...
astroconky
example link; but I think the website is under construction :
venus_link

Ok I've founded the new updated website where people can find "precious data"
See that
Here : jcweather.us

an astro-conky with actual datas would look good (for example the actual distance earth to moon)!

Offline

#4358 2012-12-14 21:57:11

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

24 hour version

--chronograph mrpeachy 12/13/12 - i blame sector11 for starting the whole chronograph thing!
require 'cairo'
extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
function conky_main()
if conky_window == nil then return end
local updates=tonumber(conky_parse("${updates}"))
if updates<=3 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)
--#########################################################################################################
--defaults
default_font_name="White Rabbit"
default_font_size=22
default_font_face="n"
default_hex_color=0xffffff
default_alpha=1
default_red=1
default_green=1
default_blue=1
default_horizontal_justify="l"	--"l"=left, "r"=right, "c"=center
default_vertical_justify="n" 	--"n"=normal, "nb"=normal-ybearing, "m"=middle, "mb"=middle-ybearing, "t"=top
default_rotation="0"
--font({f="name",fs=size,ff="face"}) face="n" or "b" or "i" or "bi"
--hexcolor({c=hexcolor,a=alpha})
--rgbcolor({r=,g=,b=,a=})
--text({x=x,y=y,t="text",hj=horizontal_justify,vj=vertical_justify,r=rotation})
--set center coordinates
centx,centy=200,200
--########################################################################################
--background circle
hexcolor({c=0x212121})
cairo_arc(cr,centx,centy,118,0,2*math.pi)
cairo_fill(cr)
--background circle
hexcolor({c=0x3c3c3c})
cairo_arc(cr,centx,centy,108,0,2*math.pi)
cairo_fill(cr)
--setup font and color
font({})
hexcolor({c=0xccaa7a})
--set clock type
clock_hours=24
--draw inbetween marks
cairo_set_line_width(cr,1)
for i=1,60 do
	--if string.find(i/5,"%.")~=nil then
	x,y=pt(centx,centy,108,((360/60)*i))
	cairo_move_to(cr,x,y)
	x,y=pt(centx,centy,98,((360/60)*i))
	cairo_line_to(cr,x,y)
	cairo_stroke(cr)
	--end
end--for
--draw numbers and dots around main circle
if clock_hours==24 then
for i=1,24 do
	if i==24 or i==8 or i==16 then
	x,y=pt(centx,centy,82,((360/24)*i))	
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
	if i==4 or i==12 or i==20 then
	hexcolor({c=0xdac09b})
	x,y=pt(centx,centy,98,((360/24)*i))
	cairo_arc(cr,x,y,6,0,2*math.pi)
	cairo_fill(cr)
	else
	hexcolor({c=0xccaa7a})
	x,y=pt(centx,centy,98,((360/24)*i))
	cairo_arc(cr,x,y,4,0,2*math.pi)
	cairo_fill(cr)
	end
end--for
elseif clock_hours==12 then
for i=1,12 do
	if i==12 or i==4 or i==8 then
	x,y=pt(centx,centy,84,((360/12)*i))	
	text({y=y,x=x,t=i,hj="c",vj="m"})
	end
	if i==2 or i==6 or i==10 then
	hexcolor({c=0xdac09b})
	x,y=pt(centx,centy,98,((360/12)*i))
	cairo_arc(cr,x,y,6,0,2*math.pi)
	cairo_fill(cr)
	else
	hexcolor({c=0xccaa7a})
	x,y=pt(centx,centy,98,((360/12)*i))
	cairo_arc(cr,x,y,4,0,2*math.pi)
	cairo_fill(cr)
	end
end--for
end
--outer circle
cairo_arc(cr,centx,centy,108,0,2*math.pi)
cairo_stroke(cr)
--########################################################################################
--hours of day at 2 position
dcx,dcy=pt(centx,centy,98,60)
font({fs=8})
--numbers
for i=0,24,3 do
x,y=pt(dcx,dcy,68,180+((120/24)*i))
text({y=y,x=x,t=string.format("%02d",i),hj="c",vj="m"})
end--for
--marks
for i=0,24 do
	if string.find(i/3,"%.")~=nil and i~=0 then
	x,y=pt(dcx,dcy,60,180+((120/24)*i))
	cairo_move_to(cr,x,y)
	x,y=pt(dcx,dcy,56,180+((120/24)*i))
	cairo_line_to(cr,x,y)
	cairo_stroke(cr)
	else
	x,y=pt(dcx,dcy,58,180+((120/24)*i))
	cairo_arc(cr,x,y,1.5,0,2*math.pi)
	cairo_fill(cr)
	end
end
--day name
font({fs=22})
dtx,dty=pt(dcx,dcy,30,180+60)
text({x=dtx,y=dty,t=string.upper(os.date("%a")),hj="c",vj="m"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
hour=tonumber(os.date("%H"))
dpx,dpy=pt(dcx,dcy,54,180+(120*(hour/24)))
cairo_move_to(cr,dcx,dcy)
cairo_line_to(cr,dpx,dpy)
cairo_stroke(cr)
--########################################################################################
--days of month at 6 position
font({fs=8})
hexcolor({c=0xccaa7a})
cairo_set_line_width(cr,1)
mcx,mcy=pt(centx,centy,98,180)
--date calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time({year=year,month=03,day=01,hour=00,min=0,sec=0});
local t2 = os.time({year=year,month=02,day=01,hour=00,min=0,sec=0});
local feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={31,feb,31,30,31,30,31,31,30,31,30,31} 
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
--marks
for i=1,mdays do
	if string.find((i-1)/3,"%.")~=nil then
	x,y=pt(mcx,mcy,60,300+((120/mdays)*i))
	cairo_move_to(cr,x,y)
	x,y=pt(mcx,mcy,56,300+((120/mdays)*i))
	cairo_line_to(cr,x,y)
	cairo_stroke(cr)
	else
	x,y=pt(mcx,mcy,60,300+((120/mdays)*i))
	cairo_move_to(cr,x,y)
	x,y=pt(mcx,mcy,54,300+((120/mdays)*i))
	cairo_line_to(cr,x,y)
	cairo_stroke(cr)
	end
end--for
--numbers
for i=1,mdays,3 do
x,y=pt(mcx,mcy,68,300+((120/mdays)*i))
text({y=y,x=x,t=string.format("%02d",i),hj="c",vj="m"})
end--for
--month name
font({fs=22})
text({x=mcx,y=mcy-30,t=string.upper(os.date("%b")),hj="c",vj="m"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
day=tonumber(os.date("%e"))
mpx,mpy=pt(mcx,mcy,52,300+(120*(day/mdays)))
cairo_move_to(cr,mcx,mcy)
cairo_line_to(cr,mpx,mpy)
cairo_stroke(cr)
--########################################################################################
--months of year at 10 position
font({fs=8})
hexcolor({c=0xccaa7a})
cairo_set_line_width(cr,1)
ycx,ycy=pt(centx,centy,98,5*60)
--date calculations
td=0
for i=1,12 do
td=td+monthdays[i]
end
angle={}
ang=0
for i=1,12 do
ang=((monthdays[i]/td)*120)+ang
angle[i]=ang
end
months={"J","F","M","A","M","J","J","A","S","O","N","D"}
--arc line
cairo_arc(cr,ycx,ycy,60,adeg(60),adeg(60+ang))
cairo_stroke(cr)
--arc marks
for i=0,12 do
	x,y=pt(ycx,ycy,60,60+((angle[i] or 0)))
	cairo_move_to(cr,x,y)
	x,y=pt(ycx,ycy,56,60+((angle[i] or 0)))
	cairo_line_to(cr,x,y)
	cairo_stroke(cr)
end
--month letters
for i=1,12 do
x,y=pt(ycx,ycy,68,60+((120/12)*i)-(120/24))
text({y=y,x=x,t=months[i],hj="c",vj="m"})
end--for
--year text
font({fs=22})
ytx,yty=pt(ycx,ycy,30,60+60)
text({x=ytx,y=yty,t=string.upper(os.date("%y")),hj="c",vj="m"})
font({fs=12})
text({x=ytx-4,y=yty-10,t="20",hj="c",vj="n"})
--indicator
cairo_set_line_width(cr,2)
hexcolor({c=0xdac09b})
today=tonumber(os.date("%j"))-1
ypx,ypy=pt(ycx,ycy,55,60+(120*(today/td)))
cairo_move_to(cr,ycx,ycy)
cairo_line_to(cr,ypx,ypy)
cairo_stroke(cr)
--center circle
hexcolor({c=0xdac09b,a=1})
cairo_arc(cr,centx,centy,5,0,2*math.pi)
cairo_stroke(cr)
--hand calculations #######################################################
if clock_hours==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*12))
elseif clock_hours==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*24))
end
--call hand drawing function
--hexcolor({c=0xccaa7a,a=0.8})
hexcolor({c=0xdac09b,a=0.8})
cairo_set_line_width(cr,2)
hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
hsec_degs,--string or value for hand degrees
70,--string or value for hand length (radius)
3,--set hand center width in pixels
10,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.9--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
--[[hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
hsec_degs+180,--string or value for hand degrees
30,--string or value for hand length (radius)
6,--set hand center width in pixels
18,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
.8--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)--]]
--MINUTES HAND
--hexcolor({c=0xdac09b,a=0.8})
hands(
200,--string or coodinate for clock center x
200,--string or coodinate for clock center y
360*((m_to_s+seconds)/(60*60)),--string or value for hand degrees
90,--string or value for hand length (radius)
3,--set hand center width in pixels
8,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.9--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
--[[hands(
centx,--string or coodinate for clock center x
centy,--string or coodinate for clock center y
180+(360*((m_to_s+seconds)/(60*60))),--string or value for hand degrees
30,--string or value for hand length (radius)
4,--set hand center width in pixels
18,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.8--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)--]]
--#########################################################################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end--end main function

--this function draws hands
function hands(clock_centerx,clock_centery,degrees,length,hand_center_width,hand_mid_width,hand_end_width,distance_to_mid)
--draw_middle
--calc start point
xs,ys=pt(clock_centerx,clock_centery,hand_center_width,degrees-90)
cairo_move_to(cr,xs,ys)
x1,y1=pt(clock_centerx,clock_centery,length*distance_to_mid,degrees-(hand_mid_width/2))
cairo_line_to (cr,x1,y1)
x2,y2=pt(clock_centerx,clock_centery,length,degrees)
cairo_arc(cr,x2,y2,hand_end_width,(degrees+180)*(math.pi/180),(degrees)*(math.pi/180))
--cairo_line_to (cr,x2,y2)
x3,y3=pt(clock_centerx,clock_centery,length*distance_to_mid,degrees+(hand_mid_width/2))
cairo_line_to (cr,x3,y3)
--calc end point
xe,ye=pt(clock_centerx,clock_centery,hand_center_width,degrees+90)
cairo_line_to (cr,xe,ye)
cairo_arc(cr,clock_centerx,clock_centery,hand_center_width,(degrees)*(math.pi/180),(degrees+180)*(math.pi/180))
cairo_fill(cr)
end

function adeg(deg)
return(math.pi/180)*(deg-90)
end

function pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end

function font(fontt)
local name=fontt.f	or default_font_name	or "mono"
local size=fontt.fs	or default_font_size	or 12
local face=fontt.ff	or default_font_face	or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="b" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
elseif face=="i" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="bi" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end

function hexcolor(hexcolort)
local col=hexcolort.c	or default_hex_color	or 0xffffff
local a=hexcolort.a	or default_alpha	or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end

function rgbcolor(rgbcolort)
local r=rgbcolort.r		or default_red			or 1
local g=rgbcolort.g		or default_green		or 1
local b=rgbcolort.b		or default_blue			or 1
local a=rgbcolort.a		or default_alpha		or 1
cairo_set_source_rgba(cr,r,g,b,a)
end

function text(textt)
local x=textt.x 		or 100
local y=textt.y 		or 100
local t=textt.t 		or "set txt"
local hj=textt.hj 		or default_horizontal_justify		or "l"
local vj=textt.vj 		or default_vertical_justify		or "n"
local r=textt.r			or default_rotation			or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end--function text ###################################################################

Screenshot_at_2012_12_14_15_56_17.jpg

Offline

#4359 2012-12-14 22:43:40

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

mrpeachy wrote:

thanks sector11 smile
ill put up a 24 hour version at some point in the near future!

It's itchin' to be tweaked too ....

RE: 24HRS
Whenever you can ... I'm going to try as well ... but I'll probably make a mess  big_smile

EDIT: That what I get for answering a post before reading all that followed ...

Oh boy 24HRS - I'm probably the only one that wants it too.

Thank you mrpeachy.

Works for me -->> abhfu2dy.jpg

Last edited by Sector11 (2012-12-14 23:04:28)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4360 2012-12-15 19:22:03

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

Sector11 and any interested,

Finally got the month names to display in place of the corresponding number on the chrono face (thanks for the help mrpeachy).

scrot

adraMbG5.jpg

and the code:

--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
 21 Jun 2012 - Chronograph modifications by Sector11
 22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
 12 Nov 2012 - memory leak plugged - mrpeachy
 14 Nov 2012 - Personnalisation - Didier-T (forum Ubuntu.fr)
 26 Nov 2012 - The Clock - Sector11 (small version)
 15 Dec 2012 - Month name displayed instead of hour number (ie: 1 2 3 4 May 6 7 8 . . . .) (Thanks to mrpeachy for the help) - DrakarNoir

use in conkyrc

lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT

 -- INDEX
 -- ### CLOCK POSITION - AND DEFAULTS ###
 -- ### SET BORDER OPTIONS FOR "CLOCKS" ### -- I don't know how to remove this - NOT NEEDED
 --     See lines 39 to 41 for overall size changes
 -- ### START DIAL B ### Day Names Dial ###
 --     See Lines 84 - 87 and 131 for changes
 -- ### START DIAL C ### Month Names Dial ###
 --     See Lines 150 -153 and 198 for changes
 -- ### START DIAL D ### Day Numbers Dial ###
 --     See Lines 234 & 265 for  changes
 -- ### START CLOCK A ###
 --     See Lines  &  and 441 & 467 changes
 -- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
 -- CLOCK A HOUR HAND
 -- CLOCK A MINUTE HAND SETUP
 -- CLOCK A SECOND HAND SETUP

NOTE:  Putting ### CLOCK A ### last insures that it's functions are written
       over the other dials.
]]

require 'cairo'
 -- ### CLOCK POSITION - AND DEFAULTS ##########################################
local init={
center_x=135,
center_y=135,
radius=118,
lang="English", -- English French Greek Spanish
hour=12, -- 12 | 24
second=true, --true | false - Seconds: dots and numbers IF 12HR
line=true, -- true | false - Part Second Hand
color=0xFF0000, --color for day, day number and month IF NO SECOND HAND
alpha=1 --alpha for day, day number and month IF NO SECOND HAND
}

 -- ONLY NEED ONE COPY OF THIS FUNCTION
function rgb_to_r_g_b(col,alp)
  return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
local colr, colg, colb, cola=rgb_to_r_g_b(init.color,init.alpha)

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)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)

 -- ### CLOCK 12|24 HR SELECTOR ############################
local clock_type_A=init.hour
 -- ############################ CLOCK 12|24 HR SELECTOR ###

 -- ### SET BORDER OPTIONS FOR "CLOCKS" ####################
--local clock_border_width=0
 -- set color and alpha for clock border
--local cbr,cbg,cbb,cba=1,1,1,1 -- full opaque white
 -- gap from clock border to minute marks
local b_to_m=0
 -- #################### SET BORDER OPTIONS FOR "CLOCKS" ###

 -- ### START DIAL B ### Day Names Dial ####################
 -- DIAL POSITION
local center_x=init.center_x
local center_y=init.center_y
local radius=22
 -- FONT
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
 -- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",} end
if init.lang == "French" then text_days={"dim","lun","mar","mer","jeu","ven","sam",} end
if init.lang == "Greek" then text_days={"ΔΕΥ","ΤΡΙ","ΤΕΤ","ΠΕΜ","ΠΑΡ","ΣΑΒ","ΚΥΡ",} end
if init.lang == "Spanish" then text_days={"dom","lun","mar","mie","jue","vie","sab",} end

local day_number=tonumber(os.date("%w"))
if init.handday == true then
  for i=1,7 do
 -- work out points
    local point=(math.pi/180)*((360/7)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
    local text=text_days[i]--gets text from table
    cairo_text_extents(cr,text,extents)
    local width=extents.width
    local height=extents.height
    cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
    cairo_show_text (cr, text)
    cairo_stroke (cr)
  end
else
  for i=1,7 do -- working out points
    if day_number == i-1 then
      cairo_set_source_rgba (cr,0,1,1,1) -- active colour
    else
      cairo_set_source_rgba (cr,1,1,1,0.0) -- non-active day names
    end
    local point=(math.pi/180)*((360/7)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
    local text=text_days[i]--gets text from table
    cairo_text_extents(cr,text,extents)
    local width=extents.width
    local height=extents.height
    cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
    cairo_show_text (cr, text)
    cairo_stroke (cr)
  end
 -- INNER POINTS POSITION, radius smaller than text circle
  local radius=7
  for i=1,7 do
    if day_number == i-1 then
      cairo_set_source_rgba (cr,0,1,1,1) -- active colour
    else
      cairo_set_source_rgba (cr,1,1,1,0.0) -- non-active
    end
    local point=(math.pi/180)*((360/7)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
    cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
    cairo_stroke (cr)
  end
end
 -- ######################################### END DIAL B ###

 -- ### START DIAL D ### Day Numbers Dial ##################
 -- GET NUMBER OF DAYS IN CURRENT MONTH
 -- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
if init.hour == 12 then
  febdaynum=tonumber((os.difftime(t1,t2))/(12*60*60))
else
  febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
end
 -- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
 -- TEXT positioning
local center_x=init.center_x
local center_y=init.center_y
local radius=85
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 16)
local this_day=tonumber(os.date("%d"))
  for i=1,number_days do
 -- OUTTER POINTS POSTION FOR TEXT
    local point=(math.pi/180)*((360/number_days)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
    --only print even numbers
    if math.mod(i, 2) == 0 and math.mod(this_day, 2)==0 then
    text=string.format("%01d",i) --formats numbers to single digit
   -- text=string.format("%02d",i) --formats numbers to double digits
    elseif math.mod(i, 2) ~= 0 and math.mod(this_day, 2)~=0 then
    text=string.format("%01d",i) --formats numbers to single digit
    --text=string.format("%02d",i) --formats numbers to double digits
    else
    text=""
    end --odd even matching
    cairo_text_extents(cr,text,extents)
    local width=extents.width
    local height=extents.height
	if i==this_day then
     cairo_set_source_rgba (cr,0,1,1,1) -- active colour
	else
	cairo_set_source_rgba (cr,1,1,1,0.2) -- dim inactive numbers
	end
     cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
     cairo_show_text (cr, text)
     cairo_stroke (cr)
  end
 -- INNER POINTS POSITION, radius smaller than text circle
  local radius=70
  for i=1,number_days do
    local point=(math.pi/180)*((360/number_days)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
	if i==this_day then
     cairo_set_source_rgba (cr,0,1,1,1) -- active colour
	else
	cairo_set_source_rgba (cr,1,1,1,0.2) -- dim the points
	end
    cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
    cairo_stroke (cr)
  end
 -- ######################################### END DIAL D ###

 -- ### START CLOCK A ######################################
 -- SET MARKS ###
 -- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=init.hour
 -- set mark length
local m_length_A=0 -- doesn't work but can't delete
 -- set mark width
local m_width_A=0 -- doesn't work but can't delete
 -- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
 -- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,0 -- opaque white -- doesn't work but can't delete
 -- SETUP HOUR HANDS ###
 -- CLOCK A HOUR HAND
hh_length_A=66
 -- set hour hand width
hh_width_A=4
 -- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
 -- set hour hand color
 -- hhr,hhg,hhb,hha=1,0,1,0 -- fully opaque white --doesn't work
 -- SETUP MINUTE HANDS ###
 -- CLOCK A MINUTE HAND SETUP
 -- set length of minute hand
mh_length_A=100
 -- set minute hand width
mh_width_A=2
 -- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
 -- set minute hand color
--mhr,mhg,mhb,mha=1,1,1,0.5 -- fully opaque white --doesn't work

 -- SETUP SECOND HAND ###
 -- CLOCK A SECOND HAND SETUP -- DOESN'T WORK - Why ???????????????????????????
 -- set length of seconds hand -- yes I know it is commented out!
--sh_length_A=150
 -- set hour hand width
--sh_width_A=2
 -- set hour hand line cap
--sh_cap=CAIRO_LINE_CAP_ROUND
 -- set seconds hand color
--shr,shg,shb,sha=1,0,0,1 -- fully opaque red

 -- PART SECOND HAND
--position
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
if init.line == true then
  local arc=(math.pi/180)*((360/60)*seconds)
  --calculate point 1
  local radius1=100
  local x1=0+radius1*math.sin(arc)
  local y1=0-radius1*math.cos(arc)
  --calculate point 2
  local radius2=107
  local x2=0+radius2*math.sin(arc)
  local y2=0-radius2*math.cos(arc)
  --draw line connecting points
  cairo_move_to (cr, center_x+x1,center_y+y1)
  cairo_line_to (cr, center_x+x2, center_y+y2)
  cairo_set_source_rgba (cr,255/255,0/255,0/255,1) -- PART SECOND HAND
  cairo_stroke (cr)
end

 -- CLOCK A ### 12 HR TIME ###
 -- CLOCK SETTINGS
clock_radius=0 --does not work
clock_centerx=init.center_x -- centre of Clock hands
clock_centery=init.center_y -- centre of Clock hands
 -- DRAWING CODE
 -- DRAW MARKS
 -- stuff that can be moved outside of the loop, needs only be set once
 -- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A -- WHAT IS THIS??
 -- set line cap type
cairo_set_line_cap  (cr, m_cap)
 -- set line width
cairo_set_line_width (cr,m_width_A)
 -- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
 -- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
 -- drawing code using the value of i to calculate degrees
 -- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
 -- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
 -- draw the line
cairo_stroke (cr)
end -- of for loop
 -- HOUR MARKS -- ???????????????????????????????????????????????????????????????
 -- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
 -- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
 -- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
 -- convert minutes to seconds
m_to_s=minutes*60
 -- get current seconds
seconds=tonumber(os.date("%S"))
 -- DRAW HOUR HAND ###
 -- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
 -- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A)) -- use equation ~ eliminate decimals
 -- set radius to calculate hand points
radius=hh_length_A
 -- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
 -- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
 -- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,0,1,1,0.7) -- active colour Hour Hand ================
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
 -- DRAW MINUTE HAND
 -- get minutes and seconds just as seconds
msecs=m_to_s+seconds
 -- calculate degrees for each second
msec_degs=msecs*0.1
 -- set radius to calculate hand points
radius=mh_length_A
 -- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
 -- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
 -- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,0,1,1,0.7) -- active colour Minute Hand ==============
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
 -- ### CLOCK A ###
local center_x=init.center_x -- Centre of the HR / Min Numbers
local center_y=init.center_y -- Centre of the HR / Min Numbers
local radius=init.radius -- 12/24 HR CLOCK Hours/Minutes radius -- seeline 42
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 22)
cairo_set_source_rgba (cr,1,1,1,0.0) -- HR Clock numbers
 -- TABLE OF TEXT -- in order
if init.hour == 12 then
  text_days={"12","1","2","3","4","5","6","7","8","9","10","11",}
    for i=1,12 do
 -- OUTTER POINTS POSTION FOR TEXT
    local point=(math.pi/180)*((360/12)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
    local text=text_days[i]--gets text from table
    cairo_text_extents(cr,text,extents)
    local width=extents.width
    local height=extents.height
    cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
    cairo_show_text (cr, text)
    cairo_set_source_rgba (cr,1,1,1,0.0)
    cairo_stroke (cr)
  end
 -- INNER POINTS POSITION, radius smaller than text circle
  local radius=101 -- 12 HR Clock
  for i=1,12 do
    local point=(math.pi/180)*((360/12)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
    cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
    cairo_set_source_rgba (cr,1,1,1,0.5)
    cairo_stroke (cr)
  end
end
 -- ############################################################################
 -- POSITION FOR TEXT HOUR NUMBERS
  if init.hour == 12 and init.second == true then
    text_days={"","1","2","3","4","","6","7","8","9","","11","12","13","14","","16","17","18","19","","21","22","23","24","","26","27","28","29","","31","32","33","34","","36","37","38","39","","41","42","43","44","","46","47","48","49","","51","52","53","54","","56","57","58","59","",}
 -- INNER POINTS POSITION, radius smaller than text circle
    cairo_set_source_rgba (cr,1,1,1,0.2) -- does not work -- settings moved
    cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    for i=1,60 do
      local radius=100 -- dots for seconds A Clock
      local point=(math.pi/180)*((360/60)*(i-1))
      local x=0+radius*(math.sin(point))
      local y=0-radius*(math.cos(point))
      if seconds == i-1 then
        cairo_set_source_rgba (cr,255/255,0/255,0/255,0.3) -- does not work - settings moved
      else
        if i-1 == 0 or i-1 == 5 or i-1 == 10 or i-1 == 15 or i-1 == 25 or i-1 == 30 or i-1 == 35 or i-1 == 40 or i-1 == 45 or i-1 == 50 or i-1 == 55 then
          cairo_set_source_rgba (cr,0,1,1,1) -- active colour
        else
          cairo_set_source_rgba (cr,0,1,1,0.5) -- dots for seconds A Clock
        end
      end
      cairo_arc (cr,center_x+x,center_y+y,1/2,0,2*math.pi)
      cairo_stroke (cr)
    end
    radius=radius-3
    cairo_set_font_size (cr, 10)
    for i=1,60 do
 -- OUTTER POINTS POSTION FOR TEXT
      local point=(math.pi/180)*((360/60)*(i-1))
      local x=0+radius*(math.sin(point))
      local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
      local text=text_days[i]--gets text from table
      if seconds == tonumber(text) then
      cairo_set_source_rgba (cr,0,1,1,1.0) -- active colour
      else
        cairo_set_source_rgba (cr,1,1,1,0.0) -- seconds numbers
      end
      cairo_text_extents(cr,text,extents)
      local width=extents.width
      local height=extents.height
      cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
      cairo_show_text (cr, text)
      cairo_stroke (cr)
    end
  end
 -- ############################################################################
 -- ### START DIAL C ### Month Names Dial ##################
 --hours, with month displayed instead of hour, 12 hour clock
local center_x=init.center_x --(+85)
local center_y=init.center_y+15
local radius=116
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 24)

month_number=tonumber(os.date("%m"))
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i))
local x=center_x+radius*(math.sin(point))
local y=center_y-radius*(math.cos(point))
	if i==month_number then
	local text=os.date("%b")--month name
	cairo_text_extents(cr,text,extents)
	cairo_set_source_rgba (cr,0,1,1,1)
   	local w=extents.width
    	local h=extents.height
	cairo_move_to(cr,x-(w/2),y-(h/2))
	cairo_show_text(cr,text)
	cairo_stroke (cr)
	else--if i does not = month_number
	local text=string.format("%01d",i)
	cairo_set_source_rgba (cr,1,1,1,1)
	cairo_text_extents(cr,text,extents)
   	local w=extents.width
    	local h=extents.height
	cairo_move_to(cr,x-(w/2),y-(h/2))
	cairo_show_text(cr,text)
	cairo_stroke (cr)
	end--if

end--for loop
 -- ######################################### END DIAL C ###
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end -- end main function

and as...

mrpeachy wrote:

hmm i'm looking through didier-t's script and (no offense meant) it is really overly complicated to do what it is doing

i am well acquainted with messy code myself and all the work that has gone into the chronograph design by the various contributers has created a good looking conky... but someone needs to clean this clock smile

I concur! However, perhaps someone more knowledgeable in lua scripting could help as I am just beginning to teach myself lua (with absolutely no previous code or language skills on which to build).

I am also beginning to work on the same idea for the day of the week in place of the date number.

scrot:

abbGc4by.jpg


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#4361 2012-12-15 20:09:30

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

DrakarNoir wrote:

Sector11 and any interested,

Finally got the month names to display in place of the corresponding number on the chrono face (thanks for the help mrpeachy).

AWESOME - I now have Chrono-DrakarNoir.lua

Thank you - and you too mrpeachy!


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4362 2012-12-15 20:11:41

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

Sector11 wrote:

AWESOME - I now have Chrono-DrakarNoir.lua

Thank you - and you too mrpeachy!

You're welcome!  lol


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#4363 2012-12-16 05:52:34

nomad
Member
Registered: 2012-08-16
Posts: 10
Website

Re: Conky v1.9 Thread

background yes
use_xft yes
xftfont Sans:size=8
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_type desktop
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 200
maximum_width 200
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders yes
default_color white
default_shade_color black
default_outline_color white
alignment top_right
gap_x 12
gap_y 12
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale no

TEXT
${font sans-serif:bold:size=8}SYSTEM ${hr 2}
${font sans-serif:normal:size=8}${exec echo '#!'} $sysname $kernel $alignr $machine
Host:$alignr$nodename
Uptime:$alignr$uptime
File System: $alignr${fs_type}

${font sans-serif:bold:size=8}PROCESSORS ${hr 2}
${font sans-serif:normal:size=8}${cpugraph cpu1}
CPU1: ${cpu cpu1}% ${cpubar cpu1}
CPU2: ${cpu cpu2}% ${cpubar cpu2}

${font sans-serif:bold:size=8}MEMORY ${hr 2}
${font sans-serif:normal:size=8}RAM $alignc $mem / $memmax $alignr $memperc%
$membar

${font sans-serif:bold:size=8}DISKS ${hr 2}
${font sans-serif:normal:size=8}/ $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_used_perc /}%
${fs_bar /}
SWAP $alignc ${swap} / ${swapmax} $alignr ${swapperc}%
${swapbar}

${font sans-serif:bold:size=8}TOP PROCESSES ${hr 2}
${font sans-serif:normal:size=8}${top_mem name 1}${alignr}${top mem 1} %
${top_mem name 2}${alignr}${top mem 2} %
$font${top_mem name 3}${alignr}${top mem 3} %
$font${top_mem name 4}${alignr}${top mem 4} %
$font${top_mem name 5}${alignr}${top mem 5} %

Inbound $alignr ${downspeed eth0} kb/s
${downspeedgraph eth0}
Outbound $alignr ${upspeed eth0} kb/s
${upspeedgraph eth0}
Alt+F2$alignr Run Dialog
Alt+F3$alignr Alt Menu
Super+space$alignr Main Menu
Super+t$alignr Terminal
Super+f$alignr File Manager
Super+e$alignr Editor
Super+m$alignr Media Player
Super+w$alignr Web Browser
Super+g$alignr Graphics Editor
Super+l$alignr Lock Screen
Super+v$alignr Volume Control
Super+x$alignr Logout
PrtSc$alignr Screenshot

Mod Edit - added code wraps - VastOne


Happy Birthday and Spraypaint an Angel on Your Trailer.

Offline

#4364 2012-12-16 06:17:34

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,165
Website

Re: Conky v1.9 Thread

VSIDO

screenshot-12162012-121418am.php


VSIDO | Words That Build Or Destroy

I dev VSIDO

Offline

#4365 2012-12-16 20:02:33

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

Any one,

I am using this draw_bg.lua:

--[[Background originally by londonali1010 (2009)
    ability to set any size for background mrpeachy 2011
    ability to set variables for bg in conkyrc dk75

  the change is that if you set width and/or height to 0
  then it assumes the width and/or height of the conky window

so:

Above and After TEXT  (requires a composite manager or it blinks!)

 lua_load ~/wea_conky/draw_bg.lua
 TEXT
 ${lua conky_draw_bg 10 0 0 0 0 0x000000 0.4}

OR Both above TEXT (no composite manager required - no blinking!)

 lua_load ~/wea_conky/draw_bg.lua
 lua_draw_hook_pre draw_bg 10 0 0 0 0 0x000000 0.5
 TEXT

Note
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.4}
  See below:        1  2 3 4 5 6        7

${lua conky_draw_bg corner_radius x_position y_position width height color alpha}

covers the whole window and will change if you change the minimum_size setting

1 = 20             corner_radius
2 = 0             x_position
3 = 0             y_position
3 = 0             width
5 = 0             height
6 = 0x000000      color
7 = 0.4           alpha
]]

require 'cairo'
local    cs, cr = nil
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function conky_draw_bg(r,x,y,w,h,color,alpha)
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) 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)
w=w
h=h
if w=="0" then w=tonumber(conky_window.width) end
if h=="0" then h=tonumber(conky_window.height) end
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end-- end main function#######################################################

What I want to do is to make a background with a hole in the center (like a donut!) Is this possible?

Like this...remove the center gray area:

adrFuuFd.jpg

Last edited by DrakarNoir (2012-12-16 20:06:17)


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#4366 2012-12-16 20:12:07

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

Round 2...

Here is the code for the Chrono with the Month name displayed in place of the corresponding time number AND the Day name displayed in place of the corresponding date number (ie:  . . .14 15 Sun 17 18 . . . )

--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
 21 Jun 2012 - Chronograph modifications by Sector11
 22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
 12 Nov 2012 - memory leak plugged - mrpeachy
 14 Nov 2012 - Personnalisation - Didier-T (forum Ubuntu.fr)
 26 Nov 2012 - The Clock - Sector11 (small version)
 15 Dec 2012 - Month name displayed instead of hour number (ie: 1 2 3 4 May 6 7 8 . . . .) (Thanks to mrpeachy for the help) - DrakarNoir
 16 Dec 2012 - Day name displayed in place of the date number (ie: . . .14 15 Sun 17 18 . . .) - DrakarNoir

use in conkyrc

lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT

 -- INDEX
 -- ### CLOCK POSITION - AND DEFAULTS ###
 -- ### SET BORDER OPTIONS FOR "CLOCKS" ### -- I don't know how to remove this - NOT NEEDED
 --     See lines 39 to 41 for overall size changes
 -- ### START DIAL B ### Day Names Dial ###
 --     See Lines 84 - 87 and 131 for changes
 -- ### START DIAL C ### Month Names Dial ###
 --     See Lines 150 -153 and 198 for changes
 -- ### START DIAL D ### Day Numbers Dial ###
 --     See Lines 234 & 265 for  changes
 -- ### START CLOCK A ###
 --     See Lines  &  and 441 & 467 changes
 -- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
 -- CLOCK A HOUR HAND
 -- CLOCK A MINUTE HAND SETUP
 -- CLOCK A SECOND HAND SETUP

NOTE:  Putting ### CLOCK A ### last insures that it's functions are written
       over the other dials.
]]

require 'cairo'
 -- ### CLOCK POSITION - AND DEFAULTS ##########################################
local init={
center_x=135,
center_y=135,
radius=118,
lang="English", -- English French Greek Spanish
hour=12, -- 12 | 24
second=true, --true | false - Seconds: dots and numbers IF 12HR
line=true, -- true | false - Part Second Hand
color=0xFF0000, --color for day, day number and month IF NO SECOND HAND
alpha=0 --alpha for day, day number and month IF NO SECOND HAND
}

 -- ONLY NEED ONE COPY OF THIS FUNCTION
function rgb_to_r_g_b(col,alp)
  return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
local colr, colg, colb, cola=rgb_to_r_g_b(init.color,init.alpha)

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)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)

 -- ### CLOCK 12|24 HR SELECTOR ############################
local clock_type_A=init.hour
 -- ############################ CLOCK 12|24 HR SELECTOR ###

 -- ### SET BORDER OPTIONS FOR "CLOCKS" ####################
--local clock_border_width=0
 -- set color and alpha for clock border
--local cbr,cbg,cbb,cba=1,1,1,1 -- full opaque white
 -- gap from clock border to minute marks
local b_to_m=0
 -- #################### SET BORDER OPTIONS FOR "CLOCKS" ###

 -- ### START DIAL B ### Day Names Dial ####################
 -- DIAL POSITION
local center_x=init.center_x
local center_y=init.center_y
local radius=22
 -- FONT
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
 -- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",} end
if init.lang == "French" then text_days={"dim","lun","mar","mer","jeu","ven","sam",} end
if init.lang == "Greek" then text_days={"ΔΕΥ","ΤΡΙ","ΤΕΤ","ΠΕΜ","ΠΑΡ","ΣΑΒ","ΚΥΡ",} end
if init.lang == "Spanish" then text_days={"dom","lun","mar","mie","jue","vie","sab",} end

--local day_number=tonumber(os.date("%w"))
if init.handday == false then
  for i=1,7 do
 -- work out points
    local point=(math.pi/180)*((360/7)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
    local text=text_days[i]--gets text from table
    cairo_text_extents(cr,text,extents)
    local width=extents.width
    local height=extents.height
    cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
    cairo_show_text (cr, text)
    cairo_stroke (cr)
  end
else
  
end
 -- ######################################### END DIAL B ###

 -- ### START DIAL D ### Day Numbers Dial ##################
 -- GET NUMBER OF DAYS IN CURRENT MONTH
 -- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
febdaynum=tonumber((os.difftime(t1,t2))/(12*60*60))

 -- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]

--days, with day-name displayed instead of digit
mx=135
my=145
radius=85
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
cairo_set_source_rgba (cr,1,1,1,1)
this_day=tonumber(os.date("%d"))
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=mx+radius*(math.sin(point))
local y=my-radius*(math.cos(point))

    --only print even numbers
    if math.mod(i, 2) == 0 and math.mod(this_day, 2)==0 then
    text=string.format("%01d",i) --formats numbers to single digit
    elseif math.mod(i, 2) ~= 0 and math.mod(this_day, 2)~=0 then
    text=string.format("%01d",i) --formats numbers to single digit
    else
    text=""
    end --odd even matching
	if i==this_day then
        cairo_set_source_rgba (cr,1,1,0,1) -- active colour
	local text=os.date("%a")--day name
	cairo_text_extents(cr,text,extents)
   	local w=extents.width
    	local h=extents.height
	cairo_move_to(cr,x-(w/2),y-(h/2))
	cairo_show_text(cr,text)
	cairo_stroke (cr)
	else
	cairo_set_source_rgba (cr,1,1,1,0.5) -- dim inactive numbers
	--local text=string.format("%01d",i)
	cairo_text_extents(cr,text,extents)
   	local w=extents.width
    	local h=extents.height
	cairo_move_to(cr,x-(w/2),y-(h/2))
	cairo_show_text(cr,text)
	cairo_stroke (cr)
	end
   end--for loop
 -- INNER POINTS POSITION, radius smaller than text circle
  local radius=72
  for i=1,number_days do
    local point=(math.pi/180)*((360/number_days)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
	if i==this_day then
     cairo_set_source_rgba (cr,1,1,0,1) -- active colour
	else
	cairo_set_source_rgba (cr,1,1,1,0.2) -- dim the points
	end
    cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
    cairo_stroke (cr)
  end
 -- ######################################### END DIAL D ###

 -- ### START CLOCK A ######################################
 -- SET MARKS ###
 -- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=init.hour
 -- set mark length
local m_length_A=0 -- doesn't work but can't delete
 -- set mark width
local m_width_A=0 -- doesn't work but can't delete
 -- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
 -- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,0 -- opaque white -- doesn't work but can't delete
 -- SETUP HOUR HANDS ###
 -- CLOCK A HOUR HAND
hh_length_A=66
 -- set hour hand width
hh_width_A=3
 -- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
 -- set hour hand color
 -- hhr,hhg,hhb,hha=1,0,1,0 -- fully opaque white --doesn't work
 -- SETUP MINUTE HANDS ###
 -- CLOCK A MINUTE HAND SETUP
 -- set length of minute hand
mh_length_A=100
 -- set minute hand width
mh_width_A=2
 -- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
 -- set minute hand color
--mhr,mhg,mhb,mha=1,1,1,0.5 -- fully opaque white --doesn't work

 -- PART SECOND HAND
--position
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
if init.line == true then
  local arc=(math.pi/180)*((360/60)*seconds)
  --calculate point 1
  local radius1=100
  local x1=0+radius1*math.sin(arc)
  local y1=0-radius1*math.cos(arc)
  --calculate point 2
  local radius2=107
  local x2=0+radius2*math.sin(arc)
  local y2=0-radius2*math.cos(arc)
  --draw line connecting points
  cairo_move_to (cr, center_x+x1,center_y+y1)
  cairo_line_to (cr, center_x+x2, center_y+y2)
  cairo_set_source_rgba (cr,255/255,0/255,0/255,1) -- PART SECOND HAND
  cairo_stroke (cr)
end

 -- CLOCK A ### 12 HR TIME ###
 -- CLOCK SETTINGS
clock_radius=0 --does not work
clock_centerx=init.center_x -- centre of Clock hands
clock_centery=init.center_y -- centre of Clock hands
 -- DRAWING CODE
 -- DRAW MARKS
 -- stuff that can be moved outside of the loop, needs only be set once
 -- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A -- WHAT IS THIS??
 -- set line cap type
cairo_set_line_cap  (cr, m_cap)
 -- set line width
cairo_set_line_width (cr,m_width_A)
 -- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
 -- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
 -- drawing code using the value of i to calculate degrees
 -- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
 -- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
 -- draw the line
cairo_stroke (cr)
end -- of for loop
 -- HOUR MARKS -- ???????????????????????????????????????????????????????????????
 -- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
 -- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
 -- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
 -- convert minutes to seconds
m_to_s=minutes*60
 -- get current seconds
seconds=tonumber(os.date("%S"))
 -- DRAW HOUR HAND ###
 -- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
 -- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A)) -- use equation ~ eliminate decimals
 -- set radius to calculate hand points
radius=hh_length_A
 -- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
 -- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
 -- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,0,1,1,0.7) -- active colour Hour Hand ================
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)
 -- DRAW MINUTE HAND
 -- get minutes and seconds just as seconds
msecs=m_to_s+seconds
 -- calculate degrees for each second
msec_degs=msecs*0.1
 -- set radius to calculate hand points
radius=mh_length_A
 -- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
 -- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
 -- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
 -- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,0,1,1,0.7) -- active colour Minute Hand ==============
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)
 -- ### CLOCK A ###
local center_x=init.center_x -- Centre of the HR / Min Numbers
local center_y=init.center_y -- Centre of the HR / Min Numbers
local radius=init.radius -- 12/24 HR CLOCK Hours/Minutes radius -- seeline 42
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 22)
cairo_set_source_rgba (cr,1,1,1,0.0) -- HR Clock numbers
 -- TABLE OF TEXT -- in order
if init.hour == 12 then
  text_days={"12","1","2","3","4","5","6","7","8","9","10","11",}
    for i=1,12 do
 -- OUTTER POINTS POSTION FOR TEXT
    local point=(math.pi/180)*((360/12)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
    local text=text_days[i]--gets text from table
    cairo_text_extents(cr,text,extents)
    local width=extents.width
    local height=extents.height
    cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
    cairo_show_text (cr, text)
    cairo_set_source_rgba (cr,1,1,1,0.0)
    cairo_stroke (cr)
  end
 -- INNER POINTS POSITION, radius smaller than text circle
  local radius=101 -- 12 HR Clock
  for i=1,12 do
    local point=(math.pi/180)*((360/12)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=0-radius*(math.cos(point))
    cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
    cairo_set_source_rgba (cr,1,1,1,0.5)
    cairo_stroke (cr)
  end
end
 -- ############################################################################
 -- POSITION FOR TEXT HOUR NUMBERS
  if init.hour == 12 and init.second == true then
    text_days={"","1","2","3","4","","6","7","8","9","","11","12","13","14","","16","17","18","19","","21","22","23","24","","26","27","28","29","","31","32","33","34","","36","37","38","39","","41","42","43","44","","46","47","48","49","","51","52","53","54","","56","57","58","59","",}
 -- INNER POINTS POSITION, radius smaller than text circle
    cairo_set_source_rgba (cr,1,1,1,0.2) -- does not work -- settings moved
    cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    for i=1,60 do
      local radius=100 -- dots for seconds A Clock
      local point=(math.pi/180)*((360/60)*(i-1))
      local x=0+radius*(math.sin(point))
      local y=0-radius*(math.cos(point))
      if seconds == i-1 then
        cairo_set_source_rgba (cr,255/255,0/255,0/255,0.3) -- does not work - settings moved
      else
        if i-1 == 0 or i-1 == 5 or i-1 == 10 or i-1 == 15 or i-1 == 25 or i-1 == 30 or i-1 == 35 or i-1 == 40 or i-1 == 45 or i-1 == 50 or i-1 == 55 then
          cairo_set_source_rgba (cr,0,1,1,1) -- active colour
        else
          cairo_set_source_rgba (cr,0,1,1,0.5) -- dots for seconds A Clock
        end
      end
      cairo_arc (cr,center_x+x,center_y+y,1/2,0,2*math.pi)
      cairo_stroke (cr)
    end
    radius=radius-3
    cairo_set_font_size (cr, 10)
    for i=1,60 do
 -- OUTTER POINTS POSTION FOR TEXT
      local point=(math.pi/180)*((360/60)*(i-1))
      local x=0+radius*(math.sin(point))
      local y=0-radius*(math.cos(point))
 -- CALCULATE CENTRE OF TEXT
      local text=text_days[i]--gets text from table
      if seconds == tonumber(text) then
      cairo_set_source_rgba (cr,0,1,1,1.0) -- active colour
      else
        cairo_set_source_rgba (cr,1,1,1,0.0) -- seconds numbers
      end
      cairo_text_extents(cr,text,extents)
      local width=extents.width
      local height=extents.height
      cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
      cairo_show_text (cr, text)
      cairo_stroke (cr)
    end
  end
 -- ############################################################################
 -- ### START DIAL C ### Month Names Dial ##################
 --hours, with month displayed instead of hour, 12 hour clock
local center_x=init.center_x --(+85)
local center_y=init.center_y+15
local radius=116
cairo_select_font_face (cr, "Planewalker", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 24)

month_number=tonumber(os.date("%m"))
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i))
local x=center_x+radius*(math.sin(point))
local y=center_y-radius*(math.cos(point))
	if i==month_number then
	local text=os.date("%b")--month name
	cairo_text_extents(cr,text,extents)
	cairo_set_source_rgba (cr,0,1,1,1)
   	local w=extents.width
    	local h=extents.height
	cairo_move_to(cr,x-(w/2),y-(h/2))
	cairo_show_text(cr,text)
	cairo_stroke (cr)
	else--if i does not = month_number
	local text=string.format("%01d",i)
	cairo_set_source_rgba (cr,1,1,1,1)
	cairo_text_extents(cr,text,extents)
   	local w=extents.width
    	local h=extents.height
	cairo_move_to(cr,x-(w/2),y-(h/2))
	cairo_show_text(cr,text)
	cairo_stroke (cr)
	end--if

end--for loop
 -- ######################################### END DIAL C ###
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end -- end main function

scrot:

adrFuuFd.jpg


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#4367 2012-12-16 20:28:57

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: Conky v1.9 Thread

DrakarNoir wrote:

Any one,

I am using this draw_bg.lua:

What I want to do is to make a background with a hole in the center (like a donut!) Is this possible?

Like this...remove the center gray area:

Yes I believe that is possible.
You would draw a ring the same way as the rings are drawn in abuyahya's ring clock and use that as the background shading shape.
I can try and make it work if you need more help with that.

Offline

#4368 2012-12-16 20:47:57

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

DrakarNoir wrote:

Any one,

What I want to do is to make a background with a hole in the center (like a donut!) Is this possible?

Like this...remove the center gray area:

Make a white circle, play with the alpha setting:

TEXT
${lua get_mounted_data 3}${lua conky_draw_bg 12 0 0 0 0 0x000000 0.6}
${lua conky_draw_bg 175 0 0 350 350 0xffffff 0.2} ## white circle
${lua conky_draw_bg 60 115 31 120 120 0x000000 0.4}
${lua conky_draw_bg 58 32 118 116 116 0x000000 0.4}
${lua conky_draw_bg 58 202 118 116 116 0x000000 0.4}
${lua conky_draw_bg 60 115 200 120 120 0x000000 0.4}

addqly80.jpg


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4369 2012-12-16 20:53:39

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

DrakarNoir wrote:

Round 2...

Here is the code for the Chrono with the Month name displayed in place of the corresponding time number AND the Day name displayed in place of the corresponding date number (ie:  . . .14 15 Sun 17 18 . . . )

And now I have 2 DrakarNoir.lua files:

  1. /media/5/Conky/LUA/Chrono-DrakarNoir.lua

  2. /media/5/Conky/LUA/Chrono-DrakarNoir_2.lua

Thank you

Last edited by Sector11 (2012-12-16 20:53:58)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4370 2012-12-16 21:09:57

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

arclance wrote:

Yes I believe that is possible.
You would draw a ring the same way as the rings are drawn in abuyahya's ring clock and use that as the background shading shape.
I can try and make it work if you need more help with that.

As a matter of fact any help would be appreciated. I looked though abuyahya's ring clock and I do not know enough to make heads nor tails of it  hmm


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#4371 2012-12-16 21:47:49

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: Conky v1.9 Thread

DrakarNoir wrote:
arclance wrote:

Yes I believe that is possible.
You would draw a ring the same way as the rings are drawn in abuyahya's ring clock and use that as the background shading shape.
I can try and make it work if you need more help with that.

As a matter of fact any help would be appreciated. I looked though abuyahya's ring clock and I do not know enough to make heads nor tails of it  hmm

Here is a draw_bg.lua that does ring shaped backgrounds.

--[[Background originally by londonali1010 (2009)
    ability to set any size for background mrpeachy 2011
    ability to set variables for bg in conkyrc dk75
	2012-12-16 - arclance - draw ring shaped backgrounds
]]

require 'cairo'
local    cs, cr = nil

function rgb_to_r_g_b(colour,alpha)
	return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function conky_draw_bg(r,x,y,W,color,alpha)
	--# r = distance of center of ring line from center of ring
	--# x = x-position of center of ring
	--# y = y-position of center of ring
	--# W = width of the ring line
	if conky_window == nil then return end
	if cs == nil then cairo_surface_destroy(cs) end
	if cr == nil then cairo_destroy(cr) 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)
	w=tonumber(conky_window.width)
	h=tonumber(conky_window.height)
	--####################
	cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
	cairo_arc(cr,x,y,r,0,(2*math.pi))
	cairo_set_line_width(cr,W)
	cairo_stroke(cr)
	------------------------------------------------------------
	cairo_surface_destroy(cs)
	cairo_destroy(cr)
	return ""
end-- end main function#######################################################

adfywbMn.png
You call it like this.

conky_draw_bg(r,x,y,W,color,alpha)

--# r = distance of center of ring line from center of ring
--# x = x-position of center of ring
--# y = y-position of center of ring
--# W = width of the ring line

Offline

#4372 2012-12-16 22:26:09

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

arclance wrote:
DrakarNoir wrote:
arclance wrote:

Yes I believe that is possible.
You would draw a ring the same way as the rings are drawn in abuyahya's ring clock and use that as the background shading shape.
I can try and make it work if you need more help with that.

As a matter of fact any help would be appreciated. I looked though abuyahya's ring clock and I do not know enough to make heads nor tails of it  hmm

Here is a draw_bg.lua that does ring shaped backgrounds.

--[[Background originally by londonali1010 (2009)
    ability to set any size for background mrpeachy 2011
    ability to set variables for bg in conkyrc dk75
	2012-12-16 - arclance - draw ring shaped backgrounds
]]

require 'cairo'
local    cs, cr = nil

function rgb_to_r_g_b(colour,alpha)
	return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function conky_draw_bg(r,x,y,W,color,alpha)
	--# r = distance of center of ring line from center of ring
	--# x = x-position of center of ring
	--# y = y-position of center of ring
	--# W = width of the ring line
	if conky_window == nil then return end
	if cs == nil then cairo_surface_destroy(cs) end
	if cr == nil then cairo_destroy(cr) 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)
	w=tonumber(conky_window.width)
	h=tonumber(conky_window.height)
	--####################
	cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
	cairo_arc(cr,x,y,r,0,(2*math.pi))
	cairo_set_line_width(cr,W)
	cairo_stroke(cr)
	------------------------------------------------------------
	cairo_surface_destroy(cs)
	cairo_destroy(cr)
	return ""
end-- end main function#######################################################

http://i.imgbox.com/adfywbMn.png
You call it like this.

conky_draw_bg(r,x,y,W,color,alpha)

--# r = distance of center of ring line from center of ring
--# x = x-position of center of ring
--# y = y-position of center of ring
--# W = width of the ring line

Thanks for the help arclance, I will play around with this and post the changes to the chrono later.


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#4373 2012-12-16 22:34:26

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

arclance wrote:

Here is a draw_bg.lua that does ring shaped backgrounds.

Hey!  Nice and much better that what I suggested as it does just that - a ring.

Good stuff arclance.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#4374 2012-12-16 22:52:59

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: Conky v1.9 Thread

I used arclance's draw_bg.ua to make "donut" shaped backgrounds. I wanted to do this because I wish to display this clock in conjunction with my music conky (see scrot below). However, when the music conky loads first it is not visible behind the clock. My question then is...is this not a true "donut"? If no, is a true "donut" possible or am I missing something?

scrot:

acyA2ScN.jpg


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

Help fund CrunchBang, donate to the project!

#4375 2012-12-16 23:08:56

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: Conky v1.9 Thread

DrakarNoir wrote:

I used arclance's draw_bg.ua to make "donut" shaped backgrounds. I wanted to do this because I wish to display this clock in conjunction with my music conky (see scrot below). However, when the music conky loads first it is not visible behind the clock. My question then is...is this not a true "donut"? If no, is a true "donut" possible or am I missing something?

scrot:

http://t.imgbox.com/acyA2ScN.jpg

It is a true donut.
Nothing is drawn in the center of the ring and it won't cover anything else from the same conky up.

If your music conky is a separate conky (has a different .conkyrc) and you are not using a compositor (compton, compiz, etc.) that is normal since conky will only show the desktop underneath it not another window.

If your music conky and clock conky are combined I would need to see all the code for it to figure out why that happens.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo