Code:
--################################################################################
--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 = 16
--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 = 50
local yadjust = 50
--set the box dimensions
local width = 104
local height = 110
--box thickness
local bthick = 8
--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
Bookmarks