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

Did any one ever use

cairo_set_operator(cr, CAIRO_OPERATOR_DEST_OVER)

I know what it does: Cairo operators but it  just doesn't seem to do anything.

Offline

Be excellent to each other!

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

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

Re: Conky v1.10 Thread

^ No, but I know a reason it might not work depending on how you wrote your Lua script.

I have seen some peoples Lua scripts where each of their different types of "Draw_X_With_Cairo()" functions creates (and hopefully destroys) a new cairo surface every time it is called.

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

I don't think playing with most of those options will do anything unless you are drawing multiple things to the same cairo surface though I have not tested it to make sure.

You can make one cairo surface in your main thread and draw things to it using functions like this.

function draw_shaded_text(CR, text, xpos, ypos, COLOR, shade_color)
	cairo_set_source_rgba (CR,shade_color[1],shade_color[2],shade_color[3],shade_color[4]) --# set shade color
	cairo_move_to (CR,(xpos + 1),(ypos + 1))
	cairo_show_text (CR,text)
	cairo_stroke (CR)
	cairo_set_source_rgba (CR,COLOR[1],COLOR[2],COLOR[3],COLOR[4]) --# set font color
	cairo_move_to (CR,xpos,ypos)
	cairo_show_text (CR,text)
	cairo_stroke (CR)
	return CR
end --# function cr = draw_shaded_text(cr, )

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

Ok i can not figure it out:

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)

According to Cairo Example this should give the first rectangle with the part of the second if they overlap (they do).
-> they are just drawn both as if no operator was special operator is set.

CAIRO_OPERATOR_DEST_ATOP

This gives the overlapping area of both rectangles in the color of the first rectangle while the cairo example suggest the second rectangle should be drawn completely, it seems missing.

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.


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

Offline

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

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

Re: Conky v1.10 Thread

It might be "scary" at first sight but cairo is not that hard, the documentation is rather good and here is a good starting tutorial: ZetCode Tuorial (don't mind the drawing to screen, conky takes care of that.) Here is the documentation: Cairo Docs, you probably only need the "Drawing" part when you start, actually this: cairo_t

Basically, (in your drawing function):

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

ragamatrix wrote:

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 :

Hi old friend ... welcome back.

I have moved your post to our new Conky v1.10 thread ... since I believe you are having a problem with this version.


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

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.


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

Offline

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

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

Re: Conky v1.10 Thread

yep no problem wink I'm not good enough in lua to understand what happen, but it's strange because the "draw_bg.lua" still functionning... May be I have to find another "hands-clock" to put in these lua_bg rings...  O:)
1441113594.png

Offline

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

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

Re: Conky v1.10 Thread

ragamatrix wrote:

Thanks a lot if someone can help wink

The first thing to do is update your .conkyrc to the new format.
The new conky kind of supports the old format but not everything works right.

Offline

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

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

Re: Conky v1.10 Thread

arclance wrote:
ragamatrix wrote:

Thanks a lot if someone can help wink

The first thing to do is update your .conkyrc to the new format.
The new conky kind of supports the old format but not everything works right.

Thanks again !
I tried to use the convert.lua script to convert the conkyrc in the good "sentence" "format" but it doesn't work well. I also tried manually but I don't knox how to call the lua script in that new way...

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$

ConkyChronoNew:(manualy made... :8 )

conky.config = {
    -- work in background (disabled for testing)
    background = false,

    -- better fonts
    use_xft = true,
    --xftalpha = 1,

    -- update interval
    update_interval = 60.0,
    total_run_times = 0,

    -- window settings
    own_window = true,
    own_window_transparent = true,
    own_window_type = 'normal',
    own_window_hints = 'undecorated, below, sticky, skip_taskbar, skip_pager',
    own_window_argb_visual = true,
    --own_window_argb_value = 0,

    -- anti-flickering
    double_buffer = true,

    -- size
    minimum_width = 480,
    minimum_height = 470,
    maximum_width = 480,

    -- shadows
    draw_shades = true,
    default_shade_color = 'black',

    -- borders
    draw_outline = false,
    default_outline_color = 'red',
    draw_graph_borders = true,

    -- frame
    draw_borders = false,

    -- color
    default_color = 'white',

    -- position
    alignment = 'top_right',
    gap_x = 5,
    gap_y = 15,

    -- misc
    no_buffers = true,
    uppercase = false,
    cpu_avg_samples = 2,
    if_up_strictness = 'address',

    show_graph_range = false,
    show_graph_scale = false,
    --default_bar_height = 6,
    --default_bar_width = 200,
    text_buffer_size = 1000,
    override_utf8_locale = true,

    font = 'Liberation Sans:bold:size=9', --important for shades
    template0 = 'Liberation Sans:bold:size=9',
    template1 = 'Liberation Mono:bold:size=7',
	--lua_load = '~/.conky/ConkyChronoClear/draw_bg.lua',
	--lua_load = '~/.conky/ConkyChronoClear/ChronoClear.lua',
	--lua_draw_hook_pre main,
}

conky.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}
--fond
---${lua conky_draw_bg 225 20 10 450 450 0x000000 0.5}
--#system
---${lua conky_draw_bg 75 170 280 150 150 0x000000 0.3}
--mois
---${lua conky_draw_bg 68 278 167 134 134 0x000000 0.3}
--jours
---{lua conky_draw_bg 59 185 56 118 118 0x000000 0.3}
--jours-nombres
---${lua conky_draw_bg 66 80 165 132 132 0x000000 0.3}
]]

Offline

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

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

Re: Conky v1.10 Thread

ragamatrix wrote:

I tried to use the convert.lua script to convert the conkyrc in the good "sentence" "format" but it doesn't work well.

Never tried that myself but I heard it does not work before.
I forgot it existed so I also forgot to tell you not to use it.

ragamatrix wrote:

I also tried manually but I don't knox how to call the lua script in that new way...

That is the only way to do it that actually works I know of.
This is the format for the lua setup.

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

Yours would end up like this

	lua_load = "~/.conky/ConkyChronoClear/draw_bg.lua",
	lua_load = "~/.conky/ConkyChronoClear/ChronoClear.lua",
	lua_draw_hook_pre = "main"
}

Note that you need to remove the "," after the last entry that you had or it won't work.
You may also need to replace the "~" in you config with your "/home/username" to get the full path to your lua files.
I have never tested if that kind of path works correctly in the new version of conky.

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

arclance wrote:

Never tried that myself but I heard it does not work before.
I forgot it existed so I also forgot to tell you not to use it.

It works fine here is how i have used it:

./full_path_to_lua_file/convert.lua /full_path_to_conky_config_file/conky_file_name

(or of course  go to the map in your terminal and use ./ instead )
Warning: this overwrites the given conky file, take a backup before converting!

This is the output for the lua bindings using convert.lua (not tested):

--lua script
	lua_load = '~/.conky/ConkyChronoClear/draw_bg.lua',
	lua_load = '~/.conky/ConkyChronoClear/ChronoClear.lua',
	lua_draw_hook_pre = 'main',
arclance wrote:

Note that you need to remove the "," after the last entry that you had or it won't work.

Currently i'm not doing this and i have no issues, convert.lua does also include an "," after the last entry. But i guess removing it won't hurt either.

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

iami wrote:

It works fine here is how i have used it:

What I have heard is that it sometimes works but not always.
I don't think it works on templates anyway since they need to have characters escaped differently in the new format.

Here is a quote from 2012 (convert.lua was last updated in 2010) to show where I have heard about it not working though.

Sector11 wrote:

Guess it boils down to personal choice at the moment though.  Since 'convert.lua' isn't converting any of my daily conkys I'd have to say it will be an enormous job to do them manually.

I'll play with it though, I have the deb here and going back and forth between the two versions isn't all that hard.

Thanks dk75.

iami wrote:

Warning: this overwrites the given conky file, take a backup before converting!

It accepts two arguments with the second being the new file to create instead of overwriting the old one.

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).
iami wrote:
arclance wrote:

Note that you need to remove the "," after the last entry that you had or it won't work.

Currently i'm not doing this and i have no issues, convert.lua does also include an "," after the last entry. But i guess removing it won't hurt either.

Maybe it works in Lua but in many programing languages it would fail because there is no entry after the last "," and it expects something to be there.
I have never actually made a table with a dangling "," like that in Lua so I assumed that like most programing languages it would yell at you if you do that.

Offline

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

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

Re: Conky v1.10 Thread

Al-right, guess i was lucky with my configs than. For me it did 95% of the job; and i thought you meant the script in general just didn't work at all.

arclance wrote:

It accepts two arguments with the second being the new file to create instead of overwriting the old one.

Did not know this, thanks smile

arclance wrote:

Maybe it works in Lua but in many programing languages it would fail because there is no entry after the last "," and it expects something to be there.
I have never actually made a table with a dangling "," like that in Lua so I assumed that like most programing languages it would yell at you if you do that.

True, it is probably best practice to remove it. It's also possible lua throws and error but conky deals with it internally (i have not checked the code).

Offline

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

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

Re: Conky v1.10 Thread

@iami & arclance thank you for explanations.

I tried many ways that you both explained with the new syntax without success (ChronoClear.lua) which is a big lua script...

I tried other simpler lua(s) conky scripts which are working correctly with the old syntax...  8o
for example:

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

1441186818.png
I don't understand. May be something goes wrong in the lua script.

Offline

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

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

Re: Conky v1.10 Thread

me again...
I've founded the solution. It seems that in conkyrc file doesn't like to call many lua scripts in v1.10. I made something like that: (Difficult to explain with my poor English)
The conkyrc call only one lua script which call others... well:

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

widget.lua:

function conky_main()
    dofile ('/home/raphix/.conky/ConkyChronoClear/draw_bg.lua')
    dofile ('/home/raphix/.conky/ConkyChronoClear/ChronoClear.lua')

--call of the two mains functions in the lua files
    conky_draw_bg()
    conky_main()
    
end

finish:
1441204204.png

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

ragamatrix wrote:

me again...
I've founded the solution. It seems that in conkyrc file doesn't like to call many lua scripts in v1.10. I made something like that: (Difficult to explain with my poor English)

Well done ragamatrix.  WoW! I remember that chronograph.  That was a fun one.

Maybe the noob in me but I see a "potential" problem ... maybe nothing and I'm wrong.

You call (bold italics mine) :

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

and in the widget you call a second "main"

--call of the two mains functions in the lua files
    conky_draw_bg()
    conky_main()

Is it possible that that might cause problems?

Oh, and your English is fine.  big_smile


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

Offline

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

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

Re: Conky v1.10 Thread

thanks for the compliment  smile

Is it possible that that might cause problems?

For me no...  big_smile
I think it's the "main" function of the lua script called... But I'm sure of nothing...

Offline

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

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

Re: Conky v1.10 Thread

ragamatrix wrote:

thanks for the compliment  smile

Is it possible that that might cause problems?

For me no...  big_smile
I think it's the "main" function of the lua script called... But I'm sure of nothing...

It is possible that it could cause problems.
You should probably rename the "conky_main" in "ChronoClear.lua" to something else and then call that in your "widget.lua" script.

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.


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

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

Be excellent to each other!

#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: acrobat

Debian Logo