Code:
require 'cairo'
function draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
local angle_0=rstart*(2*math.pi/360)-math.pi/2
local angle_f=rend*(2*math.pi/360)-math.pi/2
local t_arc=(co/100)*(angle_f-angle_0)
-- Draw background ring
cairo_arc(cr,across,down,rad,angle_0,angle_f)
cairo_set_source_rgba(cr,bgr,bgg,bgb,bga)
cairo_set_line_width(cr,inlw)
cairo_stroke(cr)
-- Draw indicator ring
cairo_arc(cr,across,down,rad,angle_0,angle_0+t_arc)
cairo_set_source_rgba(cr,inr,ing,inb,ina)
cairo_stroke(cr)
end
function conky_draw_pos()
if conky_window == nil then return end
if cs == nil or cairo_xlib_surface_get_width(cs) ~= conky_window.width or cairo_xlib_surface_get_height(cs) ~= conky_window.height then
if cs then cairo_surface_destroy(cs) end
cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
end
if cr then cairo_destroy(cr) end
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>=5 then
--NETRING SETUP-------------------------------------------------------------------------------------
wtimer=(updates % 30)+1
months = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
monthnum=tonumber(os.date('%m'))
monthname=os.date('%b')
day=tonumber(os.date('%d'))
if day<12 then
if monthnum==1 then
monthbeforenum=12
else
monthbeforenum=monthnum-1
end
month=months[monthbeforenum]
else
month=monthname
end
if updates==6 or wtimer==1 then
co=(conky_parse("${exec vnstat -m | grep -n '" .. month .. "' | sed -n 1p | awk -F'|' '{print $3}'}"))
co=string.gsub(co," ","")
num=tonumber((string.gsub(co,"%a","")))
units=(string.gsub(co,"[%p%d]",""))
end
if num==nil then num=0 end
print (num,units)
--max number--------------------------
if units=="GB" or units=="GiB" then max=25 end
if units =="MB" or units=="MiB" then max=25600 end
if units =="KB" or units=="KiB" then max=26214400 end
if max==nil then max=0 end
--position-----------------------------
across=275
down=985
--radius of ring-----------------------
rad=30
--ring width---------------------------
inlw=15
--start and end angles---------------
rstart=-135
rend=135
--color and alpha for indicator----
inr,ing,inb,ina=255,0,0,1
--background ring color and alpha-----
bgr,bgg,bgb,bga=255,255,0,1
--calculation, do not edit below---------
co=(num/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina)
--END NETRING SETUP---------------------------------------------------------------------------------
--SETUP:CPU2 Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
co=tonumber(conky_parse('${cpu cpu2}'))
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=290
down=455
--radius of ring-----------------------
rad=40
--ring width---------------------------
inlw=10
--start and end angles---------------
rstart=180
rend=360
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1
--background ring color and alpha-----
bgr,bgg,bgb,bga=1,1,0,1
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:RAM Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
co=tonumber(conky_parse('${memperc}'))
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=290
down=455
--radius of ring-----------------------
rad=25
--ring width---------------------------
inlw=10
--start and end angles---------------
rstart=-180
rend=180
--color and alpha for indicator----
inr,ing,inb,ina=1,1,1,1.0
--background ring color and alpha-----
bgr,bgg,bgb,bga=0.5,0.5,0.5,1.0
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:SWAP Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
co=tonumber(conky_parse('${swapperc}'))
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=290
down=455
--radius of ring-----------------------
rad=8
--ring width---------------------------
inlw=16
--start and end angles---------------
rstart=-180
rend=180
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1.0
--background ring color and alpha-----
bgr,bgg,bgb,bga=1,1,1,0.75
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:7GBACKUP3 Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
mounted=conky_parse('${if_mounted /media/7GBACKUP3}1${else}0${endif}')
if tonumber(mounted)==1 then
co=tonumber(conky_parse('${fs_used_perc /media/7GBACKUP3}'))
else
co=0
end
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=240
down=695
--radius of ring-----------------------
rad=45
--ring width---------------------------
inlw=5
--start and end angles---------------
rstart=180
rend=270
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1.0
--background ring color and alpha-----
mounted=conky_parse('${if_mounted /media/7GBACKUP3}1${else}0${endif}')
if tonumber(mounted)==1 then
bgr,bgg,bgb,bga=0.75,0.75,0,1.0
else
bgr,bgg,bgb,bga=1,1,1,1.0
end
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:120 Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
mounted=conky_parse('${if_mounted /media/120}1${else}0${endif}')
if tonumber(mounted)==1 then
co=tonumber(conky_parse('${fs_used_perc /media/120}'))
else
co=0
end
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=240
down=695
--radius of ring-----------------------
rad=45
--ring width---------------------------
inlw=5
--start and end angles---------------
rstart=270
rend=360
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1.0
--background ring color and alpha-----
mounted=conky_parse('${if_mounted /media/120}1${else}0${endif}')
if tonumber(mounted)==1 then
bgr,bgg,bgb,bga=0.75,0.75,0,1.0
else
bgr,bgg,bgb,bga=1,1,1,1.0
end
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:Sansa Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
wtimer=(updates % 30)+1
if updates==6 or wtimer==1 then
mounted=conky_parse("${if_match ${exec df -h | grep -c 'SANSA CLIPP'} == 1}1${else}0${endif}")
end
if tonumber(mounted)==1 then
co=tonumber(conky_parse("${exec df -h | grep 'SANSA CLIPP' | awk '{print $5}' | sed 's/%//'}"))
else
co=0
end
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=328
down=670
--radius of ring-----------------------
rad=5
--ring width---------------------------
inlw=5
--start and end angles---------------
rstart=-180
rend=180
--color and alpha for indicator----
inr,ing,inb,ina=1,0.75,0,1.0
--background ring color and alpha-----
bgr,bgg,bgb,bga=0,0,0,0.0
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:OS USB Stick Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
mounted=conky_parse('${if_mounted /media/OSUSB}1${else}0${endif}')
if tonumber(mounted)==1 then
co=tonumber(conky_parse('${fs_used_perc /media/OSUSB}'))
else
co=0
end
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=325
down=730
--radius of ring-----------------------
rad=5
--ring width---------------------------
inlw=5
--start and end angles---------------
rstart=-180
rend=180
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1.0
--background ring color and alpha-----
bgr,bgg,bgb,bga=0,0,0,0.0
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
end
end
--NEGATIVE ARCS-------------------------------------------------------------------------------------------
require 'cairo'
function draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
local angle_0=rstart*(2*math.pi/360)-math.pi/2
local angle_f=rend*(2*math.pi/360)-math.pi/2
local t_arc=(co/100)*(angle_f-angle_0)
-- Draw background ring
cairo_arc(cr,across,down,rad,angle_0,angle_f)
cairo_set_source_rgba(cr,bgr,bgg,bgb,bga)
cairo_set_line_width(cr,inlw)
cairo_stroke(cr)
-- Draw indicator ring
local angle_0_r=rend*(2*math.pi/360)-math.pi/2
local angle_f_r=rstart*(2*math.pi/360)-math.pi/2
local t_arc=(co/100)*(angle_f_r-angle_0_r)
cairo_arc_negative(cr,across,down,rad,angle_0_r,angle_0_r+t_arc)
cairo_set_source_rgba(cr,inr,ing,inb,ina)
cairo_stroke(cr)
end
function conky_draw_neg()
if conky_window == nil then return end
if cs == nil or cairo_xlib_surface_get_width(cs) ~= conky_window.width or cairo_xlib_surface_get_height(cs) ~= conky_window.height then
if cs then cairo_surface_destroy(cs) end
cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
end
if cr then cairo_destroy(cr) end
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>=5 then
--SETUP:CPU Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
co=tonumber(conky_parse('${cpu cpu1}'))
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=290
down=455
--radius of ring-----------------------
rad=40
--ring width---------------------------
inlw=10
--start and end angles---------------
rstart=0
rend=180
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1
--background ring color and alpha-----
bgr,bgg,bgb,bga=1,1,0,1
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:7GBACKUP Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
mounted=conky_parse('${if_mounted /media/7GBACKUP}1${else}0${endif}')
if tonumber(mounted)==1 then
co=tonumber(conky_parse('${fs_used_perc /media/7GBACKUP}'))
else
co=0
end
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=240
down=695
--radius of ring-----------------------
rad=45
--ring width---------------------------
inlw=5
--start and end angles---------------
rstart=0
rend=90
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1.0
--background ring color and alpha-----
mounted=conky_parse('${if_mounted /media/7GBACKUP}1${else}0${endif}')
if tonumber(mounted)==1 then
bgr,bgg,bgb,bga=0.75,0.75,0,1.0
else
bgr,bgg,bgb,bga=1,1,1,1.0
end
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
--SETUP:7GBACKUP2 Ring-----------------------------------------------------------------------------
--conky object to be displayed-----
mounted=conky_parse('${if_mounted /media/7GBACKUP2}1${else}0${endif}')
if tonumber(mounted)==1 then
co=tonumber(conky_parse('${fs_used_perc /media/7GBACKUP2}'))
else
co=0
end
if co==nil then co=0 end
--max number--------------------------
max=100
--position-----------------------------
across=240
down=695
--radius of ring-----------------------
rad=45
--ring width---------------------------
inlw=5
--start and end angles---------------
rstart=90
rend=180
--color and alpha for indicator----
inr,ing,inb,ina=1,0,0,1.0
--background ring color and alpha-----
mounted=conky_parse('${if_mounted /media/7GBACKUP2}1${else}0${endif}')
if tonumber(mounted)==1 then
bgr,bgg,bgb,bga=0.75,0.75,0,1.0
else
bgr,bgg,bgb,bga=1,1,1,1.0
end
--calculation, do not edit below---------
co=(co/max)*100
draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction)
--END SETUP---------------copy setup section and paste for additional rings----------
end
end
calendar.lua A script I worked on with mrpeachy's latest (I think) calendar script, plus a date box by dk75.
Code:
--lua calendar script by mrpeachy version 3, 03/04/2011
--fixed issue where months beginning on saturday would not have last dates printed
--added previous and next month dates within calendar
--condensed code, hopefully will run lighter also
--fixed ability to rotate and keep box in right place
require 'cairo'
--------------------------------------------------------------------------------
function conky_draw_fig(cs, cr)
if conky_window == nil then return end
if cs == nil or cairo_xlib_surface_get_width(cs) ~= conky_window.width or cairo_xlib_surface_get_height(cs) ~= conky_window.height then
if cs then cairo_surface_destroy(cs) end
cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
end
if cr then cairo_destroy(cr) end
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
--####################################################################################################
if updates>5 then -- starts the display
--####################################################################################################
--title text color
tred,tgreen,tblue,talpha=1,0,0,1
--title text font
tfont="TransponderAOE"
--title text size
tfontsize=20
--title font bold? Set to 1 for bold font
tfbold=1
--###################################################
--main body text color
bred,bgreen,bblue,balpha=0,0,0.753,1
--main body text font
mfont="TransponderAOE"
--main body text size
mfontsize=20
--main body font bold? Set to 1 for bold font
mfbold=1
--###################################################
--highlight text color
hred,hgreen,hblue,halpha=1,1,0,1
--highlight font
hfont="TransponderAOE"
--highlight size
hfontsize=20
--Highlight font bold? Set to 1 for bold font
hfbold=1
--###################################################
--surrounding numbers 1=on, 0=off
surround=1
--surrounding dates text color
sred,sgreen,sblue,salpha=1,0.723,0,1
--surrounding font
sfont="TransponderAOE"
--surounding size
sfontsize=20
--bold?
sfbold=0
--###################################################
--indicator box enter 1 for box or 0 for no box
box=1
--use the following 2 numbers to adjust box position
xadjust=2.5
yadjust=5
--set the box dimensions
width=28
height=22
--box color
bxred,bxgreen,bxblue,bxalpha=1,0,0,1
--###################################################
--calendar this month ###############################
--###################################################
--position
across=140
down=180
--rotate - this will require repositioning above
rotate=0
--###################################################
--horizontal gap between dates
gaph=32
--###################################################
--gap between day titles and first line
gapt=25
--###################################################
--gap between calendar line
gapl=25
--###################################################
--spacer -- this can help with alignment enter 0, 1 space or 2 spaces between the ""
spacer=" "
--###################################################
--calendar calcs
year=os.date("%G")
today=tonumber(os.date("%d"))
t1 = os.time( { year=year,month=03,day=01,hour=00,min=0,sec=0} );
t2 = os.time( { year=year,month=02,day=01,hour=00,min=0,sec=0} );
feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={ 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local day=tonumber(os.date("%w"))+1
local day_num = today
local remainder=day_num % 7
start_day=day-(day_num % 7)
if start_day<0 then start_day=7+start_day end
month=os.date("%m")
mdays=monthdays[tonumber(month)]
mdaystm=mdays
x=mdays+start_day
dnum={}
dnumh={}
if mdays+start_day<36 then
dlen=35
plen=29
else
dlen=42
plen=36
end
for i=1,dlen do
if i<=start_day then dnum[i]=" "
else dn=i-start_day
if dn=="nil" then dn=0 end
if dn<=9 then dn=(spacer .. dn) end
if i>x then dn="" end
dnum[i]=dn
dnumh[i]=dn
if dn==(spacer .. today) or dn==today then
dnum[i]=""
end
if dn==(spacer .. today) or dn==today then
dnumh[i]=dn
place=i
else dnumh[i]=" "
end
end
end--for
--###################################################
cairo_rotate (cr,(math.pi/180)*(rotate))
--print calendar titles
--###################################################
if tfbold==1 then
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
else
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
end
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
dys={"SU","MO","TU","WE","TH","FR","SA"}
--------------------------------
--use these settings to mess around with positioning
turn=0
ta=0
move=0
rot=0
--------------------------------
for i=1,7 do
cairo_move_to (cr, across+(gaph*(i-1)), down+(i*move))
cairo_rotate (cr,(math.pi/180)*(rot))
cairo_show_text (cr, dys[i])
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(rot*-1))
end
if mfbold==1 then
cairo_select_font_face (cr, mfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
else
cairo_select_font_face (cr, mfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
end
cairo_set_font_size (cr, mfontsize);
cairo_set_source_rgba (cr,bred,bgreen,bblue,balpha)
for i=1,plen,7 do
fn=i
for i=fn,fn+6 do
cairo_move_to (cr, across+(gaph*(i-fn))-((((fn-1)/7)+ta)*turn), (i*move)+down+gapt+(gapl*((fn-1)/7)))
cairo_rotate (cr,(math.pi/180)*(rot))
cairo_show_text (cr, dnum[i])
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(rot*-1))
end
end
if hfbold==1 then
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
else
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
end
cairo_set_font_size (cr, hfontsize);
cairo_set_source_rgba (cr,hred,hgreen,hblue,halpha)
for i=1,plen,7 do
fn=i
for i=fn,fn+6 do
cairo_move_to (cr, across+(gaph*(i-fn))-((((fn-1)/7)+ta)*turn), (i*move)+down+gapt+(gapl*((fn-1)/7)))
cairo_rotate (cr,(math.pi/180)*(rot))
cairo_show_text (cr, dnumh[i])
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(rot*-1))
end
end
--###############################################################################
if surround==1 then
thisstart=tonumber(start_day)+1
thisend=tonumber(start_day)+mdays
previous=tonumber(start_day)
nextmon=dlen-thisend
pmon=tonumber(month)-1
if pmon==0 then pmon=12 end
pmon=monthdays[pmon]
snum={}
for i=1,dlen do
snum[i]=""
end
for i=tonumber(thisend)+1,tonumber(thisend)+nextmon do
snum[i]=i-tonumber(thisend)
end
for i=1,previous do
snum[i]=pmon-(previous-(i))
end
if sfbold==1 then
cairo_select_font_face (cr, sfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
else
cairo_select_font_face (cr, sfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
end
cairo_set_font_size (cr, sfontsize);
cairo_set_source_rgba (cr,sred,sgreen,sblue,salpha)
for i=1,plen,7 do
fn=i
for i=fn,fn+6 do
cairo_move_to (cr, across+(gaph*(i-fn))-((((fn-1)/7)+ta)*turn), (i*move)+down+gapt+(gapl*((fn-1)/7)))
cairo_rotate (cr,(math.pi/180)*(rot))
cairo_show_text (cr, snum[i])
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(rot*-1))
end
end
end
--box aound
if box==1 then
cairo_set_source_rgba (cr,bxred,bxgreen,bxblue,bxalpha)
cairo_set_line_width (cr,1)
if place>0 and place<8 then
cy=down+gapt
elseif
place>7 and place<15 then
cy=down+gapt+gapl
elseif
place>14 and place<22 then
cy=down+gapt+gapl+gapl
elseif
place>21 and place<29 then
cy=down+gapt+gapl+gapl+gapl
elseif
place>28 and place<36 then
cy=down+gapt+gapl+gapl+gapl+gapl
end
placey=place %7
if placey==1 then
cx=across
elseif
placey==2 then
cx=across+(gaph*1)
elseif
placey==3 then
cx=across+(gaph*2)
elseif
placey==4 then
cx=across+(gaph*3)
elseif
placey==5 then
cx=across+(gaph*4)
elseif
placey==6 then
cx=across+(gaph*5)
elseif
placey==0 then
cx=across+(gaph*6)
end
cairo_rectangle (cr,cx-xadjust,cy+yadjust,width,-height)
cairo_stroke (cr)
end
--###################################################
cairo_rotate (cr,(math.pi/180)*(rotate*-1))
--end of calendar
--###################################################
--#################################################################################
end--end if 5
end--end main function
--################################################################################
--Box Function
--################################################################################
do
require "cairo"
local cs, cr = nil
local function conky_set_the_font(cr, fface, fsize, fbold)
if fbold == 1 then
cairo_select_font_face(cr, fface, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD)
else
cairo_select_font_face(cr, fface, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL)
end
cairo_set_font_size(cr, fsize)
end
local function conky_draw_date(cr, extents, string, fred, fgreen ,fblue, falpha, tacross, down)
cairo_set_source_rgba(cr, fred, fgreen, fblue, falpha)
cairo_move_to(cr, tacross - (extents.width /2 ), down)
cairo_show_text(cr, string)
end
function conky_draw_box(cs, cr)
if conky_window == nil then return end
if cs == nil or cairo_xlib_surface_get_width(cs) ~= conky_window.width or cairo_xlib_surface_get_height(cs) ~= conky_window.height then
if cs then cairo_surface_destroy(cs) end
cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
end
if cr then cairo_destroy(cr) end
cr = cairo_create(cs)
local updates = tonumber(conky_parse('${updates}'))
--####################################################################################################
if updates>5 then -- starts the display
--####################################################################################################
--Weekday text color
local wred, wgreen, wblue, walpha = 1, 1, 1, 1
--Weekday text font
local wfont = "TransponderAOE"
--Weekday text size
local wfontsize = 16
--Weekday font bold? Set to 1 for bold font
local wfbold = 1
--###################################################
--Month text color
local mred, mgreen, mblue, malpha = 1, 0, 0, 1
--Month text font
local mfont = "TransponderAOE"
--Month text size
local mfontsize = 18
--Month font bold? Set to 1 for bold font
local mfbold = 1
--###################################################
--Day text color
local dred, dgreen, dblue, dalpha = 1, 1, 0, 1
--Day font
local dfont = "TransponderAOE"
--Day size
local dfontsize = 30
--Day font bold? Set to 1 for bold font
local dfbold = 1
--###################################################
--Year text color
local yred, ygreen, yblue, yalpha = 1, 1, 1, 1
--year font
local yfont = "TransponderAOE"
--Year size
local yfontsize = 18
--Year font bold? Set to 1 for bold font
local yfbold = 1
--###################################################
--indicator box enter 1 for box or 0 for no box
local box = 1
--use the following 2 numbers to adjust box position
local xadjust = 20
local yadjust = 180
--set the box dimensions
local width = 104
local height = 110
--box thickness
local bthick = 5
--box color
local bxred, bxgreen, bxblue, bxalpha = 0, 0, 0.753, 1
--###################################################
--Today's Date Box ###############################
--###################################################
--position
local down = yadjust + bthick
--###################################################
--gap from sides
local gaph = 10
--###################################################
--variables (need to set font face, font size and text string in order to populate text extents structure with text measurements)
-- Weekday
local wdays = os.date("%A")
local ext_wdays = cairo_text_extents_t:create()
conky_set_the_font(cr, wfont, wfontsize, wfbold)
cairo_text_extents(cr, wdays, ext_wdays)
-- Month
local month = os.date("%B")
local ext_month = cairo_text_extents_t:create()
conky_set_the_font(cr, mfont, mfontsize, mfbold)
cairo_text_extents(cr, month, ext_month)
-- Today
local today = tonumber(os.date("%d"))
local ext_today = cairo_text_extents_t:create()
conky_set_the_font(cr, dfont, dfontsize, dfbold)
cairo_text_extents(cr, today, ext_today)
-- Year
local year = os.date("%G")
local ext_year = cairo_text_extents_t:create()
conky_set_the_font(cr, yfont, yfontsize, yfbold)
cairo_text_extents(cr, year, ext_year)
-- text across box center axis
local tacross = xadjust + (width / 2)
-- gap between lines (with 4 lines it will be 3 gaps)
local gapl = (height - (bthick * 2) - (gaph * 2) - ext_wdays.height - ext_month.height - ext_today.height - ext_year.height) / 3
--###################################################
--print box
--###################################################
--Weekday
down = down + gaph + ext_wdays.height
conky_set_the_font(cr, wfont, wfontsize, wfbold)
conky_draw_date(cr, ext_wdays, wdays, wred, wgreen ,wblue, walpha, tacross, down)
--Month
down = down + gapl + ext_month.height
conky_set_the_font(cr, mfont, mfontsize, mfbold)
conky_draw_date(cr, ext_month, month, mred, mgreen ,mblue, malpha, tacross, down)
--Day
down = down + gapl + ext_today.height
conky_set_the_font(cr, dfont, dfontsize, dfbold)
conky_draw_date(cr, ext_today, today, dred, dgreen ,dblue, dalpha, tacross, down)
--Year
down = down + gapl + ext_year.height
conky_set_the_font(cr, yfont, yfontsize, yfbold)
conky_draw_date(cr, ext_year, year, yred, ygreen ,yblue, yalpha, tacross, down)
--box around
if box == 1 then
cairo_set_source_rgba(cr, bxred, bxgreen, bxblue, bxalpha)
cairo_rectangle(cr, xadjust, yadjust, width, height)
cairo_set_line_width(cr, bthick)
cairo_stroke(cr)
end
cairo_stroke(cr)
--#################################################################################
end--end if 5
end--end box function
end
.conkyForecast.config For completeness.
Bookmarks