Pour que ton calendrier soit bien aligné, il faut utiliser une police à chasse fixe, c'est à dire une police dont chaque caractère occupe le même place.
Or la police arial que tu utilises ne l'est pas.
Moi j'utilisai la police Monaco, que tu peux obtenir ici http://www.gringod.com/wp-upload/MONACO.TTF.
Une autre solution est de prendre le calendrier en lua de wlourf, l'avantage c'est que tu peux mettre la police que tu veux, ton calendrier sera toujours aligné.
--[[Calendar Box]]
require 'cairo'
calendar_file= "/home/dominique/.conkyrc/conky15/calendar.txt"
function conky_calendar_box()
-- Retrieve current date
cal_settings={
{
x=120, --obligatoire, x du coin supérieur gauche
y=10, --obligatoire, y du coin supérieur gauche
font="URW Chancery L", --obligatoire : police à utiliser
font_size=16, --obligatoire : taille de la police
two_digits=false, --afficher les nombres avec 2 chiffres (true/false) false par défaut
month_format="%B %Y",--format d'affiche du mois, (défaut = %B -nom complet) http://www.lua.org/pil/22.1.html
month_position="t", --position de la boite mois t,b,l,r (défaut = t)
month_offset=0, --décalage du mois (défaut=0)
hpadding=1, --espace horizontal entre texte et bordure (défaut=2 pixels)
vpadding=0, --espace vertical entre texte et bordure (défaut=2 pixels)
border=0, --taille de la bordure en pixels (défaut=0 pixels)
gap=4, --espace entre deux boites (défaut=2 pixels)
radius=0, --rayon des coins (défaut=0 pixels)
alignment="r", --alignment des chiffres (l,c ou r) (défaut="c")
days_position="t", --position des jours (t/b) (défaut=t)
days_number=2, --nombre de lettres du jour (défaut=1)
display_others_days=false, --affiche les jours des autres mois (true/false) défaut=true
--pour les couleurs, les paramètres du conky doivent être:
--own_window_transparent yes
--own_window_argb_visual yes
--couleurs {couleur1, couleur2, alpha1,alpha2,border1,border2,alpha border1,alpha border2}
--colBox = {0xFF0000,0x0000FF,0,1,0x0000FF,0x00FFFF,0.5,0.5}, --couleur "boite" Date (les chiffres)
--colDays = {0xFF00FF,0x0000FF,1,1,0x0000FF,0x00FF00,1,1}, --couleur "boite" Jour (Lundi, mardi ...)
--colMonth = {0x00FF00,0x0000FF,1,1,0x0000FF,0x00FF00,1,1}, --couleur "boite" Mois
--colBoxTD = {0xFF0000,0xFF0000,0,1,0xFF00FF,0x00FF00,1,1}, --couleur "boite" AUJOURDHUI
--colBoxBH = {0xFF0000,0xFF0000,1,1,0xFF00FF,0x00FF00,1,1}, --couleur "boite" Férié
--couleurs text {couleur1,couleur2, alpha1,alpah2}
colBoxText = {0x30BAFF,0x30BAFF,1,1}, --couleur Texte Date les chiffres)
colBoxTextTD = {0xF21804,0xAA0B02,1,1}, --couleur Texte Date Aujourd'hui
colBoxTextBH = {0x30BAFF,0x30BAFF,1,1}, --couleur Texte Date Férié
--colBoxTextOM = {0xFFFFF0,0xFFF0FF,1,1}, --couleur Texte Date Mois Différent
colDaysText ={0x0D4357,0x0D4357,1,1}, --couleur Texte Jour
colMonthText = {0x0003E5,0x09EFFF,1,1}, --couleur Texte Mois
orientation ="nw", -- orientation du dégradé défaut ="nn", valeurs possibles= nn, ne,ee,se,ss,sw,ww,nw
gradient=1, -- défaut linear(=0) ou radial gradient (défaut=centre du cercle (0 à 1) % du côté d'un carré)
display_info_box=true, --affiche la boite info (false par défaut)
--colInfo = {0xFF0000,0x0000FF,0,1,0x0000FF,0x00FFFF,0.5,0.5}, --couleur de la boite Info
colInfoText = {0x188D9C,0x188D9C,1,1}, --couleur Texte Info
info_position="b", --position de la boite info (défaut=b)
display_empty_info_box=true, --affiche la boite info si pas d'info (true/false), (défaut= false)
}
}
--FIN DES PARAMETRES ------------------
if conky_window == nil then return end
--if tonumber(conky_parse("$updates"))<3 then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create (cs)
for i,v in pairs(cal_settings) do
draw_calendar(v)
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
function draw_square(cr,x,y,width,height,radius)
local degrees = math.pi / 180.0
radius=tonumber(radius)
cairo_new_sub_path (cr);
if radius>0 then
cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
cairo_arc (cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
cairo_arc (cr, x + radius, y+ radius, radius, 180 * degrees, 270 * degrees);
else
cairo_rectangle(cr,x,y,width,height)
end
cairo_close_path (cr);
return
end
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function create_pattern(cr,x,y,w,h,tCol,orientation,gradient)
if gradient~=0 then
create_pattern_radial(cr,x,y,w,h,tCol,orientation,gradient)
else
create_pattern_linear(cr,x,y,w,h,tCol,orientation)
end
end
function create_pattern_linear(cr,x,y,w,h,tCol,orientation)
col0,col1,alpha0,alpha1=tCol[1],tCol[2],tCol[3],tCol[4]
if orientation=="nn" then
p={x+w/2,y,x+w/2,y+h}
elseif orientation=="ne" then
p={x+w,y,x,y+h}
elseif orientation=="ee" then
p={x+w,y+h/2,x,y+h/2}
elseif orientation=="se" then
p={x+w,y+h,x,y}
elseif orientation=="ss" then
p={x+w/2,y+h,x+w/2,y}
elseif orientation=="sw" then
p={x,y+h,x+w,y}
elseif orientation=="ww" then
p={x,y+h/2,x+w,y+h/2}
else
p={x,y,x+w,y+h}
end
local pat = cairo_pattern_create_linear (p[1],p[2],p[3],p[4])
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col0,alpha0))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col1,alpha1))
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
function create_pattern_radial(cr,x,y,w,h,tCol,orientation,gradient)
local col0,col1,alpha0,alpha1=tCol[1],tCol[2],tCol[3],tCol[4]
local decn=gradient
local dec=1-decn
if orientation=="nn" then
p={x+w/2,y+h*decn}
elseif orientation=="ne" then
p={x+w*dec,y+h*decn}
elseif orientation=="ee" then
p={x+w*dec,y+h/2}
elseif orientation=="se" then
p={x+w*dec,y+h*dec}
elseif orientation=="ss" then
p={x+w/2,y+h*dec}
elseif orientation=="sw" then
p={x+w*decn,y+h*dec}
elseif orientation=="ww" then
p={x+w*decn,y+h/2}
else
p={x+w*(1-dec),y+h*(1-dec)}
end
local radius = w/dec
if h>w then radius=h/dec end
local pat = cairo_pattern_create_radial (p[1],p[2],0,p[1],p[2],radius)
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col0,alpha0))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col1,alpha1));
cairo_set_source (cr, pat);
cairo_pattern_destroy(pat)
end
function draw_frame (x0,y0,width,height,tCol,radius,border,orientation,gradient)
cairo_set_operator(cr,CAIRO_OPERATOR_SOURCE)
create_pattern(cr,x0,y0,width,height,{tCol[5],tCol[6],tCol[7],tCol[8]},orientation,gradient)
draw_square(cr,x0,y0,width,height,radius)
cairo_set_line_width(cr,border)
cairo_fill (cr)
--cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
create_pattern(cr,x0,y0,width,height,{tCol[1],tCol[2],tCol[3],tCol[4]},orientation,gradient)
draw_square(cr,x0+border,y0+border,width-border*2,height-border*2,radius)
cairo_fill (cr)
cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
if tCol[2]>0 or tCol[3]>0 then
cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
else
cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
end
create_pattern(cr,x0,y0,width,height,{tCol[1],tCol[2],tCol[3],tCol[4]},orientation,gradient)
draw_square(cr,x0+border,y0+border,width-border*2,height-border*2,radius)
cairo_fill (cr)
cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
end
function string:split(delimiter)
--source for the split function : http://www.wellho.net/resources/ex.php4?item=u108/split
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end
function draw_calendar(t)
local te=cairo_text_extents_t:create()
if t.font==nil or t.x==nil or t.y == nil or t.font_size == nil then
print ("Error in settings")
return
end
x0,y0=t.x,t.y
if t.two_digits then str_format="%02d" else str_format="%d" end
if t.month_format==nil then t.month_format = "%B" end
if t.hpadding==nil then t.hpadding=2 end
if t.vpadding==nil then t.vpadding=2 end
if t.border==nil then t.border=0 end
if t.month_offset==nil then t.month_offset=0 end
if t.gap==nil then t.gap=2 end
if t.radius==nil then t.radius=0 end
if t.days_number==nil then t.days_number=1 end
if t.display_others_days==nil then t.display_others_days=true end
if t.gradient==nil then t.gradient=0 end
if t.display_info_box == nil then t.display_info_box=false end
if t.display_empty_info_box == nil then t.display_empty_info_box=false end
local orientation="nn"
for i,v in ipairs({"nn","ne","ee","se","ss","sw","ww","nw"}) do
if v==t.orientation then orientation=v end
end
local alignment ="c"
for i,v in ipairs({"l","c","r"}) do
if v==t.alignment then alignment=v end
end
local month_position="t"
for i,v in ipairs({"t","b","l","r"}) do
if v==t.month_position then month_position=v end
end
local days_position="t"
for i,v in ipairs({"t","b","l","r"}) do
if v==t.days_position then days_position=v end
end
local info_position="b"
for i,v in ipairs({"t","b","l","r"}) do
if v==t.info_position then info_position=v end
end
function table.copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
if t.colBox ~= nil and #t.colBox ~=8 then t.colBox=nil end
if t.colDays ~= nil and #t.colDays ~=8 then t.colDays=nil end
if t.colMonth ~= nil and#t.colMonth ~=8 then t.colMonth=nil end
if t.colBoxTD ~= nil and #t.colBoxTD ~=8 then t.colBoxTD=nil end
if t.colBoxBH ~= nil and #t.colBoxBH ~=8 then t.colBoxBH=nil end
if t.colInfo ~= nil and #t.colInfo ~=8 then t.colInfo=nil end
if t.colBoxText ~= nil and #t.colBoxText ~= 4 then t.colBoxText=nil end
if t.colBoxTextOM ~= nil and #t.colBoxTextOM ~=4 then t.colBoxText=nil end
if t.colBoxTextTD ~= nil and #t.colBoxTextTD ~= 4 then t.colBoxTextTD=nil end
if t.colDaysText ~= nil and #t.colDaysText ~= 4 then t.colDaysText=nil end
if t.colMonthText ~= nil and #t.colMonthText ~= 4 then t.colMonthText=nil end
if t.colInfoText ~= nil and #t.colInfoText ~= 4 then t.colInfoText=nil end
if t.colBox == nil then t.colBox = {0x000000,0xFFFFFF,0,0,0xFFFFFF,0x000000,0,0} end
if t.colDays == nil then t.colDays = table.copy(t.colBox) end
if t.colMonth == nil then t.colMonth = table.copy(t.colBox) end
if t.colInfo == nil then t.colInfo = t.colBox end
if t.colBoxTD == nil then t.colBoxTD = {t.colBox[2],t.colBox[1],t.colBox[3],t.colBox[4],t.colBox[6],t.colBox[5],t.colBox[7],t.colBox[8]}end
if t.colBoxBH == nil then t.colBoxBH = t.colBox end
if t.colBoxText == nil then t.colBoxText = {0x000000,0x000000,1,1} end
if t.colBoxTextOM == nil then t.colBoxTextOM = {0x00000,0x000000,0.2,0.2} end
if t.colBoxTextTD == nil then t.colBoxTextTD = {0xFF0000,0xFF0000,1,1} end
if t.colBoxTextBH == nil then t.colBoxTextBH = {0xFF0000,0xFF0000,1,1} end
if t.colDaysText == nil then t.colDaysText = {0x999999,0x999999,1,1} end
if t.colMonthText == nil then t.colMonthText = {0x333333,0x333333,1,1} end
if t.colInfoText == nil then t.colInfoText = {0x333333,0x333333,1,1} end
-- i/m
--calculate maximum size of a square
local maxSide=0
cairo_select_font_face(cr, t.font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size(cr,t.font_size)
for d=1,31 do
cairo_text_extents (cr,string.format(str_format,d),te)
maxSide = math.max(maxSide,te.width+te.x_bearing+2*t.hpadding,te.height+te.y_bearing+2*t.vpadding) --te.y_bearing+
end
maxSide=maxSide+2*t.border
d=0
-- Compute what day it was the first of the month (0=Monday)
-- from conky wiki
dtable = os.date("*t")
--this month table
mtable=dtable
mtable.month=dtable.month+t.month_offset
mtable = os.date("*t",os.time(mtable))
day,wday = mtable.day, mtable.wday
first_day = wday - 2 - (day-1) % 7
if first_day < 0 then first_day = first_day + 7 end
local txt_month = os.date(t.month_format, os.time(mtable))
txt_month = string.upper(string.sub(txt_month,1,1)) .. string.sub(txt_month,2)
--last day of month
--[[ ldtable=mtable
ldtable.month=mtable.month+1
ldtable.day,ldtable.hour,ldtable.min,ldtable.sec=1,0,0,0
--print ("av",ldtable.day,ldtable.month,ldtable.hour,ldtable.min,ldtable.sec)
ldtable=os.date("*t",os.time(ldtable)-2)
last_day=ldtable.day
]] --print ("ap",ldtable.day,ldtable.month,ldtable.hour,ldtable.min,ldtable.sec)
-- returns the number of days in a given month and year
-- Compatible with Lua 5.0 and 5.1.
-- from sam_lie
function get_days_in_month(month, year)
local days_in_month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local d = days_in_month[month]
-- check for leap year
if (month == 2) then
if (math.mod(year,4) == 0) then
if (math.mod(year,100) == 0)then
if (math.mod(year,400) == 0) then
d = 29
end
else
d = 29
end
end
end
return d
end
last_day=get_days_in_month(mtable.month, mtable.year)
lpdtable=mtable
lpdtable.month=lpdtable.month-1
mtable = os.date("*t",os.time(lpdtable))
if lpdtable.month==0 then lpdtable.month=12 end
last_p_day=get_days_in_month(lpdtable.month,lpdtable.year)
mtable.month=lpdtable.month+1
mtable = os.date("*t",os.time(mtable))
--read the calendar file
local file = io.open(calendar_file,"r")
local tabcal={}
local idx=1
local line,lineok="",""
local txt_info=""
if file ~= nil then
while true do
line = file:read("*l")
if line == nil then break end
lineok = string.split(line,";")
if (#lineok)==3 then
tabcal[idx]={lineok[1],lineok[2],lineok[3]}
idx=idx+1
if lineok[1] == os.date("%m%d", os.time()) then
txt_info=lineok[3]
end
end
end
end
if not t.display_empty_info_box and txt_info=="" then
t.display_info_box =false
end
if not t.display_info_box then info_position="b" end
local nblines=idx-1
--for i,v in ipairs(tabcal) do print (i,v[1],v[2],v[3]) end
io.close()
--définit le texte des jours
tdays={}
for i=4,11 do
table.insert(tdays,os.date("%A", os.time{year=2010, month=1, day=i}))
end
for i=1,7 do
tdays[i]=string.upper(string.sub(tdays[i],1,1)) .. string.sub(tdays[i],2)
tdays[i]=(string.sub(tdays[i],1,math.max(t.days_number,1)))
end
local display_day=true
--dessine les dates (nombres)
local flagEnd=0
for r=0,5 do
if flagEnd>0 then break end
for c=0,6 do
d=d+1
X=x0+c*maxSide+t.gap*c
Y=y0+r*maxSide+t.gap*r
if month_position=="t" then
Y=Y+maxSide+t.gap
elseif month_position=="l" then
X=X+maxSide+t.gap
end
if info_position=="t" then
Y=Y+maxSide+t.gap
elseif info_position=="l" then
X=X+maxSide+t.gap
end
if days_position=="t" then
Y=Y+maxSide+t.gap
end
--bank holiday or not ?
mtable.day=d-first_day
md = os.date("%m%d", os.time(mtable))
local flagBH = false
for idy=1,nblines do
if tabcal[idy][1] == md then
if tabcal[idy][2] == "1" then
flagBH = true
end
break
end
end
--draw frames
local colorBox=t.colBox
if dtable.day == d-first_day and t.month_offset==0 then
colorBox=t.colBoxTD
elseif flagBH then
colorBox=t.colBoxBH
end
draw_frame (X,Y,maxSide,maxSide,colorBox,t.radius,t.border,orientation,t.gradient)
--format _text
if d<=first_day then --days before
create_pattern(cr,X,Y,maxSide*(1-t.gradient),maxSide*(1-t.gradient),t.colBoxTextOM,orientation,t.gradient)
txt_date=last_p_day-first_day+d
display_day=t.display_others_days
elseif d-first_day>0 and d-first_day<=last_day then -- days of the month
txt_date=d-first_day
local colorText= t.colBoxText
if txt_date==dtable.day and t.month_offset==0 then
colorText=t.colBoxTextTD
elseif flagBH then
colorText=t.colBoxTextBH
end
create_pattern(cr,X,Y,maxSide*(1-t.gradient),maxSide*(1-t.gradient),colorText,orientation,t.gradient)
display_day=true
else --days after
txt_date=d-first_day-last_day
create_pattern(cr,X,Y,maxSide*(1-t.gradient),maxSide*(1-t.gradient),t.colBoxTextOM,orientation,t.gradient)
display_day=t.display_others_days
end
--show text or not
if display_day then
cairo_text_extents (cr,string.format(str_format,txt_date),te)
if alignment=="r" then
delta=maxSide-te.width-te.x_bearing-t.border-t.hpadding
elseif alignment=="c" then
delta=(maxSide-te.width)/2-te.x_bearing
else
delta=t.border+t.hpadding
end
if c==0 or d-first_day==1 then teheight= te.height end
cairo_move_to(cr,X+delta,Y+(maxSide)/2+teheight/2)
cairo_show_text(cr,string.format(str_format,txt_date))
end
if d-first_day>=last_day then
flagEnd=r
end
end
end
--show days (monday, thuesday ...)
if days_position=="t" then
Y=y0
if month_position=="t" then Y=Y+maxSide+t.gap end
if info_position=="t" then Y=Y+maxSide+t.gap end
else
Y=y0+(flagEnd+1)*(maxSide+t.gap)
end
deltaX=0
if month_position=="l" then deltaX=deltaX+maxSide+t.gap end
if info_position=="l" then deltaX=deltaX+maxSide+t.gap end
flagEnd=flagEnd+1
for c =0,6 do
X=x0+c*maxSide+t.gap*c+deltaX
draw_frame (X,Y,maxSide,maxSide,t.colDays,t.radius,t.border,orientation,t.gradient)
cairo_save(cr)
cairo_text_extents (cr,tdays[c+1],te)
local ratio=(maxSide-2*t.border-2*t.hpadding)/(te.width+ te.x_bearing)
if ratio>1 then ratio=1 end
-- print (tdays[c+1],(te.width+ te.x_bearing)>(maxSide-2*t.border-2*t.hpadding),ratio)
local xm = X+(maxSide-te.width-t.hpadding)/2
-- (maxSide-te.width)/2-te.x_bearing
local xm = X+t.hpadding+(maxSide-2*t.hpadding-te.width)/2-te.x_bearing--+t.hpadding/2
local ym = Y+(maxSide+te.height)/2
--if ratio<1 then ym=y0+vbox.height-t.border -t.vpadding end
if ratio<1 then xm=X+t.border+t.hpadding end
if alignment=="r" then
delta=maxSide-te.width-te.x_bearing-t.border-t.hpadding
elseif alignment=="c" then
delta=(maxSide-te.width)/2-te.x_bearing
else
delta=t.border+t.hpadding
end
cairo_move_to(cr,xm,ym)
create_pattern(cr,X,Y,maxSide,maxSide,t.colDaysText,orientation,t.gradient)
cairo_save(cr)
cairo_scale(cr,ratio,1)
cairo_show_text(cr,tdays[c+1])
cairo_restore(cr)
end
function show_big_box(txt,box,position)
cairo_text_extents (cr,txt,te)
hbox={ width = maxSide*7+t.gap*6, height = maxSide}
vbox={ width = maxSide, height = maxSide*(flagEnd+1)+t.gap*flagEnd}
local deltaY = 0
local deltaX = 0
if box=="month" then
tColor=t.colMonth
tColorText=t.colMonthText
if info_position=="l" or info_position=="r" then
hbox={ width = maxSide*8+t.gap*7, height = maxSide}
end
if info_position=="l" then
deltaX = (maxSide+t.gap)
end
if info_position=="t" and month_position=="t" then
deltaY = (maxSide+t.gap)
end
if (month_position=="l" or month_position=="r") and (info_position=="t") then
deltaY=(maxSide+t.gap)
end
if (month_position=="b") and (info_position=="t") then
deltaY=(maxSide+t.gap)
end
elseif box=="info" then
tColor=t.colInfo
tColorText=t.colInfoText
if month_position=="l" or month_position=="r"then
hbox={ width = maxSide*8+t.gap*7, height = maxSide}
end
if month_position=="r" and info_position=="r" then
deltaX=(maxSide+t.gap)
end
if (month_position=="t") and (info_position=="l" or info_position=="r") then
deltaY=(maxSide+t.gap)
end
if (month_position=="t") and (info_position=="b") then
deltaY=(maxSide+t.gap)
end
if (month_position=="b") then
vbox={ width = maxSide, height = maxSide*(flagEnd)+t.gap*(flagEnd-1)}
end
else
return
end
if position=="b" then
flagEnd=flagEnd+1
draw_frame (x0,y0+flagEnd*(maxSide+t.gap)+deltaY,hbox.width,hbox.height,tColor,t.radius,t.border,orientation,t.gradient)
elseif position=="l" then
draw_frame (x0+deltaX,y0+deltaY,vbox.width, vbox.height,tColor,t.radius,t.border,orientation,t.gradient)
elseif position=="r" then
draw_frame (x0+7*(maxSide+t.gap)+deltaX,y0+deltaY,vbox.width,vbox.height,tColor,t.radius,t.border,orientation,t.gradient)
else
draw_frame (x0,y0+deltaY,hbox.width,hbox.height,tColor,t.radius,t.border,orientation,t.gradient)
end
if position=="t" or position=="b" then
cairo_save(cr)
local ratio=(hbox.width-2*t.border-2*t.hpadding)/(te.width + te.x_bearing)
if ratio>1 then ratio=1 end
local xm = x0+hbox.width/2-(te.width/2 + te.x_bearing)
local ym = y0+hbox.height/2-(te.height/2+ te.y_bearing)
if ratio<1 then xm=x0+t.border +t.hpadding end
if position=="b" then ym = ym + flagEnd*(maxSide+t.gap) end
create_pattern(cr,x0,y0,hbox.width,hbox.height,tColorText,orientation,t.gradient)
cairo_translate(cr,xm,ym+deltaY)
cairo_scale(cr,ratio,1)
cairo_show_text(cr,txt)
cairo_restore(cr)
end
if position=="l" or position=="r" then
cairo_save(cr)
--ajuster la taille, à faire avec cairo_set_scaled_font ??
local ratio=(vbox.height-2*t.border-2*t.hpadding)/(te.width + te.x_bearing)
if ratio>1 then ratio=1 end
local xm = x0+vbox.width/2-(te.height/2 + te.y_bearing)+deltaX
local ym = y0+vbox.height/2+(te.width/2+ te.x_bearing)
if ratio<1 then ym= y0 + vbox.height - t.border -t.hpadding end
if position=="r" then xm=xm + 7*(maxSide+t.gap) end
--hum hum ...
create_pattern(cr,xm-hbox.height+te.height,ym-te.width- te.x_bearing,hbox.height,te.width+ te.x_bearing,tColorText,orientation,t.gradient)
cairo_translate(cr,xm,ym+deltaY)
cairo_rotate(cr,-math.pi/2)
cairo_scale(cr,ratio,1)
cairo_show_text(cr,txt)
cairo_restore(cr)
end
end
--txt_info="essa s la co gf f hgf hg ss ss ss ff r ss s"
show_big_box(txt_month,"month",month_position)
if t.display_info_box then
if t.file_info ~= nil then
local file = io.open(t.file_info,"r")
if file ~= nil then txt_info = file:read("*l") end
end
show_big_box(txt_info,"info",info_position)
end
end
function conky_show_ip()
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 file = io.open("/tmp/my_ip.txt","r")
local ip_txt
if file ~= nil then
ip_txt = file:read("*l")
end
if ip_txt~=nil then
cairo_set_font_size (cr, 50.0);
cairo_move_to (cr, 100.0, 100.0);
cairo_set_source_rgba (cr, 0.325490196, 0.258823529, 0.035294118, 0.2);
cairo_show_text (cr, ip_txt);
end
io.close()
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
C'est un peu plus compliqué à mettre en œuvre, mais tu peu faire ce que tu veux avec.
Si tu restes sur un calendrier plus classique, juste quelques remarques sur ton conky:
-"border_margin 0" n'existe plus, maintenant c'est border_inner_margin ou border_outer_margin, mais comme tu le mets a zero tu peux supprimer la ligne, ou la commenter en mettant un # devant: #border_margin 0
-de même tu peux commenter la ligne "use_spacer no" ou mettre la valeur a false (use_spacer no n'existe plus)
tu as ${color1} et ${color2}, mais tu ne définis pas ces couleurs dans la partie qui est avant TEXT, donc ton calendrier est tout blanc