SEARCH

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

You are not logged in.

#76 2015-08-21 18:52:38

iami
Member
Registered: 2013-09-06
Posts: 44

Re: Conky v1.10 Thread

cairo_set_operator(cr, CAIRO_OPERATOR_DEST_OVER)

Offline

Help fund CrunchBang, donate to the project!

#77 2015-08-21 20:22:09

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

Re: Conky v1.10 Thread

Draw_X_With_Cairo()
	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)
	"Draw Stuff Here"
	cairo_destroy(cr)
	cairo_surface_destroy(cs)
end

Offline

#78 2015-08-22 06:54:04

iami
Member
Registered: 2013-09-06
Posts: 44

Re: Conky v1.10 Thread

That indeed crossed my mind but since i do all my drawing in 1 function and do not use cairo_restore(cr) it might be something on my end? Will try to boil it down later today.

Offline

#79 2015-08-25 19:49:08

iami
Member
Registered: 2013-09-06
Posts: 44

Re: Conky v1.10 Thread

cairo_set_source_rgba(cr, 0, 0, 0.9, 0.8)
cairo_rectangle(cr, 0,-20,500,-90)
cairo_fill(cr)

cairo_set_operator(cr, CAIRO_OPERATOR_ATOP)

cairo_set_source_rgba(cr, 0, 0.5, 0.5, 0.8)
cairo_rectangle(cr, 50,30,500,-90)
cairo_fill(cr)

Last edited by iami (2015-08-26 06:49:46)

Offline

#80 2015-08-25 22:48:21

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

Re: Conky v1.10 Thread

^^ & ^ - You guys are light years over my head ....

Wrong thread - moved.

Offline

#81 2015-08-26 07:03:50

iami
Member
Registered: 2013-09-06
Posts: 44

Re: Conky v1.10 Thread

1) Create cairo "stuff":
function conky_drawRectangles()
	-- Check Conky status
	if conky_window == nil or conky_window.height == 0 then return end
		
	-- Set-up cairo
	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)
2) Draw things eg a rectangle (note you can draw multiple at once, eg in a for loop):
       cairo_rectangle (cr, x, y, width, height)
3) Set the color (or image, but that requires slightly different code) which will fill the rectangle:
       cairo_set_source_rgba(cr, r, g, b, a)
4) Draw the shape:
      cairo_fill(cr) (other options are available: cairo_stroke(cr) for outer border, cairo_paint(cr) to fill with an image)
5) Clean up resources (of you get memory leaks):
	-- Clean up Cairo
	cairo_destroy(cr)
	cairo_surface_destroy(cs)		
end <- end of draw funtion

Offline

#82 2015-09-01 12:14:51

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

Re: Conky v1.10 Thread

Hi all !
Since a new update I got a serious conky problem... I got some lua scripts which are no more recognize when I launch conky :

conky -c ~/.conky/ConkyChronoClear/ConkyChronoClear
conky: Syntax error (/home/raphix/.conky/ConkyChronoClear/ConkyChronoClear:2: '=' expected near 'yes') while reading config file. 
conky: Assuming it's in old syntax and attempting conversion.
conky: llua_load: /home/raphix/.conky/ConkyChronoClear/ChronoClear.lua:32: attempt to call global 'rgb_to_r_g_b' (a nil value)
conky: desktop window (29b) is root window
conky: window type - normal
conky: drawing to created window (0x2400001)
conky: drawing to double buffer
conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
conky: llua_do_call: function conky_draw_bg execution failed: attempt to call a nil value
conky: llua_do_call: function conky_draw_bg execution failed: attempt to call a nil value
conky: llua_do_call: function conky_draw_bg execution failed: attempt to call a nil value
..........etc

Before the update everithing worked fine. I think the problem comes from here :

conky: llua_load: /home/raphix/.conky/ConkyChronoClear/ChronoClear.lua:32: attempt to call global 'rgb_to_r_g_b' (a nil value)

But I don't know how to fix it...
ChronoClear.lua:

--[[ 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)
 27 Jan 2014 - Personnalisation - ragamatrix (#! forum (en,fr) ubuntu.fr))	
use in conkyrc

lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT

]]

require 'cairo'
--Position et taille horloge
local init={
center_x=245,
center_y=235,
radius=220, -- do not touch
lang="French", --English or Spanish or French
hour=12, --12 or 24
second=true, --true or false
line=false, --hand secondes true or false
handday=false, --hand day true or false
handdaynum=false, --hand day number true or false
handmonth=false, --hand month true or false
color=0xF8F8FF, --color for day, day number and month if none hand
alpha=1 --alpha for day, day number and month if none hand
}

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)
---[##drawings_new_hands
--this function caluculates coordinates for a point around a circle
function pt(px,py,prad,pdeg)--px,py=center coordinates for circle, prad=radius,pdeg is position in degrees, 0 is top
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1--returns coordinates, use in main function like this, x,y=pt(px,py,prad,pdeg)
end

--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

-- ########################################################
-- SETTINGS AREA
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")

local clock_type_A=init.hour -- Large Main 24 HR Clock

-- ###### CLOCK SETTINGS ##################################
-- 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=1

-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- DIAL POSITION FOR TEXT
local center_x=init.center_x-0
local center_y=init.center_y-120
local radius=45
-- FONT
cairo_select_font_face (cr, "Andale Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 13)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",}	end	-- English
if init.lang == "Spanish" then text_days={"Dom","Lun","Mar","Mie","Jue","Vie","Sab",}	end	-- Spanish
if init.lang == "French" then text_days={"Dim","Lun","Mar","Mer","Jeu","Ven","Sam",}	end	-- French
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
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=35
  for i=1,7 do
    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
  -- DRAW HAND -- snaps to current day of week
  local hand_length=30
  local point=(math.pi/180)*((360/7)*(day_number))
  local x=0+hand_length*(math.sin(point))
  local y=0-hand_length*(math.cos(point))
  local hand_width=2
  cairo_move_to (cr,center_x,center_y)
  cairo_line_to (cr,center_x+x,center_y+y)
  cairo_stroke (cr)
else
  for i=1,7 do
    -- work out points
    if day_number == i-1 then
      cairo_set_source_rgba (cr,colr, colg, colb, cola)
    else
      cairo_set_source_rgba (cr,121/255,128/255,144/255,1)--Days ---181, 224, 255
    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
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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####Points days
  local radius=28
  for i=1,7 do
    if day_number == i-1 then
      cairo_set_source_rgba (cr,colr, colg, colb, cola)
    else
      cairo_set_source_rgba (cr,112/255,128/255,144/255,1)
    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 C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=init.center_x+100
local center_y=235
local radius=55
-- FONT
cairo_select_font_face (cr, "Andale Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 13)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",} end -- English
if init.lang == "Spanish" then text_days={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic",} end -- Spanish
if init.lang == "French" then text_days={"Jan","Fév","Mar","Avr","Mai","Jui","Jul","Aôu","Sep","Oct","Nov","Déc",} end -- French
local this_month=tonumber(os.date("%m"))

if init.handmonth == true then
  for i=1,12 do
    -- OUTTER POINTS POSiTION 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
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=32
  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_stroke (cr)
  end
  -- DRAW HAND -- snaps to current month
  local hand_length=28 --radius for this calculation
  local point=(math.pi/180)*((360/12)*(this_month-1))
  local x=0+hand_length*(math.sin(point))
  local y=0-hand_length*(math.cos(point))
  cairo_move_to (cr,center_x,center_y)
  cairo_line_to (cr,center_x+x,center_y+y)
  cairo_stroke (cr)
else
  for i=1,12 do
    if this_month == i then
      cairo_set_source_rgba (cr,colr, colg, colb, cola)
    else
      cairo_set_source_rgba (cr,112/255,128/255,144/255,1)
    end
    -- OUTTER POINTS POSTION FOR TEXT
    local point=(math.pi/180)*((360/12)*(i-1))
    local x=0+radius*(math.sin(point))
    local y=-3-radius*(math.cos(point))
    -- CALCULATE CENTRE OF TEXT
    local text=text_days[i]--gets text from table
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=35
  for i=1,12 do
    if this_month == i then
      cairo_set_source_rgba (cr,colr, colg, colb, cola)
    else
      cairo_set_source_rgba (cr,112/255,128/255,144/255,1)
    end
    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_stroke (cr)
  end

end
-- ### END CLOCK C ########################################

-- ########################################################
-- ### START DIAL D ### Left - 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-100
local center_y=init.center_y-3
local radius=55
cairo_select_font_face (cr, "Andale Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 13)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,245/255,242/255,143/255,1) -- (cr,1,1,1,1)
local this_day=tonumber(os.date("%d"))
if init.handdaynum == true then
  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 then
      --set text when even
      text=string.format("%02d",i) --formats numbers to double digits
    else
      --set text when odd
      text=""
    end--odd even matching
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=40
  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))
    cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
    cairo_stroke (cr)
  end
  -- DRAW HAND -- snaps to current DAY
  local hand_length=35--radius for this calculation
  local point=(math.pi/180)*((360/number_days)*(this_day-1))
  local x=0+hand_length*(math.sin(point))
  local y=0-hand_length*(math.cos(point))
  cairo_move_to (cr,center_x,center_y)
  cairo_line_to (cr,center_x+x,center_y+y)
  cairo_stroke (cr)
else
  for i=1,number_days do
    if this_day == i then
      cairo_set_source_rgba (cr,colr, colg, colb, cola)
    else
      cairo_set_source_rgba (cr,112/255,128/255,144/255,1)
    end
    -- 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 then
      --set text when even
      text=string.format("%02d",i) --formats numbers to double digits
    else
      --set text when odd
      text=""
    end--odd even matching
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=40
  for i=1,number_days do
    if this_day == i then
      cairo_set_source_rgba (cr,colr, colg, colb, cola)
    else
      cairo_set_source_rgba (cr,112/255,128/255,144/255,1)--points day numbers
    end
    local point=(math.pi/180)*((360/number_days)*(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 CLOCK D ########################################

-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- 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,0,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=25
-- set hour hand width
hh_width_E=2
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=35
-- set minute hand width
mh_width_E=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK E SECOND HAND SETUP
-- set length of seconds hand
sh_length_E=32
-- set hour hand width
sh_width_E=1
-- 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
-- CLOCK E ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=45
clock_centerx=init.center_x
clock_centery=init.center_y+85
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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_E
-- set line cap type
cairo_set_line_cap  (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E 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_E))
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_E))
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-- MARKS AROUND CLOCK A
cairo_stroke (cr)
end-- of for loop
-- 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
-- set mark width
local m_width_A=0
-- 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,1 -- opaque white
-- ================================================================
-- SETUP HOUR HANDS #######################################
-- CLOCK A HOUR HAND#######################################new-one=
-- set length of hour hand
hh_length_A=150
-- 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,1,1,.4-- fully opaque white & opacity
-- SETUP MINUTE HANDS #####################################
-- CLOCK A MINUTE HAND SETUP###############################new-one=
-- set length of minute hand
mh_length_A=200
-- 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,.4-- fully opaque white & opacity
-- SETUP SECOND HANDS #####################################
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
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
-- CLOCK A ###### 12 HR TIME ##############################
-- ==============================================================
-- CLOCK SETTINGS
clock_radius=200
clock_centerx=init.center_x
clock_centery=init.center_y
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- 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
-- 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 up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
--NEW HAND DRAWING CODE ##################################################
--call hand drawing function
hands(
clock_centerx,--string or coodinate for clock center x
clock_centery,--string or coodinate for clock center y
hsec_degs,--string or value for hand degrees
hh_length_A,--string or value for hand length (radius)
2,--set hand center width in pixels
10,--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
)

--#########################################################################
-- 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,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
--NEW HAND DRAWING CODE ##################################################
--call hand drawing function
hands(
clock_centerx,--string or coodinate for clock center x
clock_centery,--string or coodinate for clock center y
msec_degs,--string or value for hand degrees
mh_length_A,--string or value for hand length (radius)
2,--set hand center width in pixels
6,--set hand mid width in degrees
0,--set hand end width in pixels, 0=a point
0.75--number from 0 to 1 as a propotion of total hand length, ie 0.5 is exact middle distance
)
-- DRAW SECOND HAND

--[[
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))BOLD
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr)
]]
-- ####################################################################
local center_x=init.center_x
local center_y=init.center_y
local radius=init.radius-5
cairo_select_font_face (cr, "Andale Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 15)
cairo_set_source_rgba (cr,220/255,220/255,220/255,1) --(cr,194/255,204/255,255/255,1)	-- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
if init.hour == 12 then 
  text_days={"12","01","02","03","04","05","06","07","08","09","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
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=180
  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_stroke (cr)
  end
end
if init.hour == 24 then 
  text_days={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
  for i=1,24 do
    -- OUTTER POINTS POSTION FOR TEXT
    local point=(math.pi/180)*((360/24)*(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
    --local extents=cairo_text_extents_t:create()
    --tolua.takeownership(extents)
    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=150
  for i=1,24 do
    local point=(math.pi/180)*((360/24)*(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

-- part of a 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=140
  local x1=0+radius1*math.sin(arc)
  local y1=0-radius1*math.cos(arc)
  --calculate point 2
  local radius2=158
  local x2=0+radius2*math.sin(arc)
  local y2=0-radius2*math.cos(arc)
  --draw line connecting points-- 255, 138, 255
  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)
  cairo_stroke (cr)
end
-- ####################################################################
-- POSITION FOR TEXT HOUR NUMBERS
--affiche secondes
  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,1)
    cairo_select_font_face (cr, "Andale Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    for i=1,60 do
      local radius=200
      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,220/255,220/255,220/255,1)---point for seconds---
      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,1,1,1,1)---points for hours
        else
          cairo_set_source_rgba (cr,112/255,128/255,144/255,1)---points for minutes
        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,248/255,248/255,255/255,1)--trotteuse color
      else
        cairo_set_source_rgba (cr,112/255,128/255,144/255,1)--minutes numbers color
      end
      --local extents=cairo_text_extents_t:create()
      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
-- Fin affiche secondes
-- FONT

-- ########################################################
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function

function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
  return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end

and the conkyrc:

###  Begin Window Settings  ##################################################
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager,sticky
#own_window_title ragamatrix
own_window_class Conky
#own_window_colour gray
### ARGB can be used for real transparency
#own_window_argb_visual yes
#own_window_argb_value 0

# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes

minimum_size 480 470   #Taille minimum (px) ; largeur / hauteur
maximum_width 480 #350      #Largeur maximum (px)

gap_x 15 #15        ### left &right
gap_y 15        ### up & down

alignment tr #ml
###################################################  End Window Settings  ###
###  Font Settings  #########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont Droid Sans Mono:size=8
#xftfont	mono:bold:size=8
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes

uppercase no
######################################################  End Font Settings  ###
###  Color Settings  #########################################################
draw_shades yes #no # amplifies text if yes
default_shade_color 000000

draw_outline no # amplifies text if yes
default_outline_color 000000

#default_color DCDCDC #220 220 220    Gainsboro
default_color Slategrey
color1  AF0001 #darkred
color2  666666
color3  696969
color4  DeepSkyBlue
color5  DodgerBlue1
color6  f6f3cc
color7  green3
color8  F8F8FF
color9  9FB6CD ##SlateGrey
#####################################################  End Color Settings  ###
###  Borders Section  ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders no #yes
#default_graph_size 15 40
#####################################################  End Borders Secton  ###
###  Miscellaneous Section  ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background no

# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none

# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 1024

# Subtract (file system) buffers from used memory?
no_buffers yes

# change GiB to G and MiB to M
short_units yes

# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2

#   Maximum size of user text buffer, i.e. layout below TEXT line in config file
#  (default is 16384 bytes)
# max_user_text 16384
# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
# temperature_unit Fahrenheit

##############################################  End Miscellaneous Section  ###
###  LUA Settings  ###########################################################
## Above and After TEXT - After - requires a composite manager or blinks.
##
#lua script
lua_load ~/.conky/ConkyChronoClear/draw_bg.lua
lua_load ~/.conky/ConkyChronoClear/ChronoClear.lua
lua_draw_hook_pre main

TEXT
${voffset 310}${color green2}${font }${alignc}TOP CPU
${font }${color green2}${goto 185}${top name 1}${top cpu 1} %
${goto 185}${color lightgrey}${top name 2}${top cpu 2} % 
${goto 185}${color lightgrey}${top name 3}${top cpu 3} % 
${goto 185}${color lightgrey}${top name 4}${top cpu 4} %
${voffset 3}${color red}${font }${alignc}TOP RAM

${goto 185}${font }${color red}${top_mem name 1}${top_mem mem 1} %
${goto 185}${color lightgrey}${top_mem name 2}${top_mem mem 2} %
${goto 185}${color lightgrey}${top_mem name 3}${top_mem mem 3} %
${goto 185}${color lightgrey}${top_mem name 4}${top_mem mem 4} %
#${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4}
${lua conky_draw_bg 225 20 10 450 450 0x000000 0.5} #fond
${lua conky_draw_bg 75 170 280 150 150 0x000000 0.3} #system
${lua conky_draw_bg 68 278 167 134 134 0x000000 0.3} #mois
${lua conky_draw_bg 59 185 56 118 118 0x000000 0.3} #jours
${lua conky_draw_bg 66 80 165 132 132 0x000000 0.3} #jours-nombres

Thanks a lot if someone can help wink

Offline

#83 2015-09-01 12:45:23

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

Re: Conky v1.10 Thread

Offline

#84 2015-09-01 12:55:09

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

Re: Conky v1.10 Thread

Thanks sector 11, happy to see you again smile

Offline

#85 2015-09-01 13:05:06

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

Re: Conky v1.10 Thread

Unfortunately I can not help - I am still using v1.9.   sad
But always nice to see an old friend.

Offline

#86 2015-09-01 13:20:17

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

Re: Conky v1.10 Thread

Offline

#87 2015-09-01 13:32:21

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

Re: Conky v1.10 Thread

Offline

#88 2015-09-01 14:53:26

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

Re: Conky v1.10 Thread

raphix@debian:~$ cd /home/raphix/.conky/ConkyChronoClear/
raphix@debian:~/.conky/ConkyChronoClear$ ./convert.lua ConkyChronoClear
bash: ./convert.lua : /usr/bin/lua : mauvais interpréteur: Aucun fichier ou dossier de ce type
raphix@debian:~/.conky/ConkyChronoClear$

Offline

#89 2015-09-01 15:10:35

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

Re: Conky v1.10 Thread

lua_load = "/path/lua_script.lua",
lua_draw_hook_pre = "main",
lua_startup_hook = "start_xdotool",
lua_shutdown_hook = "stop_xdotool"

Last edited by arclance (2015-09-01 15:11:04)

Offline

#90 2015-09-01 17:24:59

iami
Member
Registered: 2013-09-06
Posts: 44

Re: Conky v1.10 Thread

./full_path_to_lua_file/convert.lua /full_path_to_conky_config_file/conky_file_name

Last edited by iami (2015-09-01 17:33:20)

Offline

#91 2015-09-01 21:13:26

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

Re: Conky v1.10 Thread

Altough you can use this script with only 1 arg and let it overwrite the old
config, it's suggested to use 2 args so that the new config is written in a new
file (so that you have backup if something went wrong).

Offline

#92 2015-09-02 07:12:34

iami
Member
Registered: 2013-09-06
Posts: 44

Re: Conky v1.10 Thread

Offline

#93 2015-09-02 09:41:31

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

Re: Conky v1.10 Thread

raphix@debian:~$ conky -c ~/.conky/livarp_cky_topbars
conky: Syntax error (/home/raphix/.conky/livarp_cky_topbars:2: unexpected symbol near '#') while reading config file. 
conky: Assuming it's in old syntax and attempting conversion.
conky: desktop window (29b) is root window
conky: window type - override
conky: drawing to created window (0x2c00001)
conky: drawing to double buffer

Offline

#94 2015-09-02 14:30:28

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

Re: Conky v1.10 Thread

#lua script
lua_load ~/.conky/ConkyChronoClear/widget.lua
lua_draw_hook_pre main

Offline

#95 2015-09-02 15:08:00

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

Re: Conky v1.10 Thread

Offline

#96 2015-09-02 15:31:51

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

Re: Conky v1.10 Thread

Offline

#97 2015-09-02 15:45:28

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

Re: Conky v1.10 Thread

Offline

#98 2015-09-02 16:26:56

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

Re: Conky v1.10 Thread

I was thinking more along the lines of:

#lua script
lua_load ~/.conky/ConkyChronoClear/widget.lua
lua_draw_hook_pre widget

since "main" is used quite a bit in a lot of LUA scripts.

Offline

#99 2015-09-02 16:35:25

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

Re: Conky v1.10 Thread

^ If you do it the way I suggested you can load as many lua scripts in the "widget.lua" as long as they don't have any duplicate function names after you rename things.
You will likely run into problems if you "dofile" load multiple lua files that all have a conky_main function in them.
I don't know exactly what will happen since I have not tested anything but I would guess that either the latest loaded version of a function name would overwrite the last loaded version or it would not work at all.

Nothing is stopping someone from doing what you suggested as well as what I suggested though.

Offline

Help fund CrunchBang, donate to the project!

#100 2015-09-02 16:54:54

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

Re: Conky v1.10 Thread

Logic I believe you're right guys, I'll correct that soon. Thanks again.  cool

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: bleh

Debian Logo