Доделал скрипт backgraund.lua С его помощью можно не только выводить фон для коньков, но и рисовать кнопки, бары, всего ещё не перепробовал.
--[[ backgraund.lua by olgmen 16.11.2010
Выводит в окно conky фон с градиентной окраской
Для запуска скрипта поместите следующие строки в conkyrc выше слова TEXT
Displays the window conky background with gradient color
To run the script put the following lines to the above words conkyrc
lua_load /path/to/the/lua/script/backgraund.lua
lua_draw_hook_pre draw_backgraund
06.02.2011 - добавлена возможность ввода радиусов отдельных углов
x - координаты по горизонтали верхнего левого угла, по умолчанию = 0
y - координаты по вертикали верхнего левого угла, по умолчанию = 0
width - ширина, по умолчанию = ширине окна conky
height - высота, по умолчанию = высоте окна conky
radius - общее значение радиуса для всех углов
t_l_radius - радиус верзнего левого угла, по умолчанию = 0
t_r_radius - радиус верхнего правого угла, по умолчанию = 0
b_l_radius - радиус нижнего левого угла, по умолчанию = 0
b_r_radius - радиус нижнего правого угла, по умолчанию = 0
orientation - направление градиентной окраски. Возможны 8 вариантов расположения цвета
"nn" - сверху вниз
"ee" - справа налево
"ss" - снизу вверх
"ww" - слева направо, по умолчанию
"ne", "se", "sw", "nw" - промежуточные.
colour -
]]
require 'cairo'
function conky_draw_backgraund()
value = conky_parse("${time %S}")
backgraund_settings={
-- ------------------------- первый ряд, слева ---------------
{
x = 10,
y = 25,
width = 150,
height = 100,
colour = {{0, 0xc0c0c0, 1},{0.5, 0xc0c0c0, 1},{1, 0xc0c0c0, 1}},
},
-- -------------------------- первый ряд справа ---------------
{
x = 180,
y = 25,
radius = 25,
width = 150,
height = 100,
colour = {{0, 0xc0c0c0, 1},{0.5, 0xc0c0c0, 1},{1, 0xc0c0c0, 1}},
},
-- ----------------------------второй ряд, слева ---------------
{
x = 10,
y = 140,
width = 150,
height = 100,
t_l_radius = 20,
b_r_radius = 20,
colour = {{0, 0xc0c0c0, 1},{0.5, 0xc0c0c0, 1},{1, 0xc0c0c0, 1}},
},
-- --------------------------- второй ряд справа ----------------
{
x = 180,
y = 140,
t_l_radius = 25,
t_r_radius = 25,
width = 150,
height = 48,
colour = {{0, 0xc0c0c0, 1},{0.5, 0xc0c0c0, 1},{1, 0xc0c0c0, 1}},
},
{
x = 180,
y = 190,
b_l_radius = 25,
b_r_radius = 25,
width = 150,
height = 48,
colour = {{0, 0xc0c0c0, 1},{0.5, 0xc0c0c0, 1},{1, 0xc0c0c0, 1}},
},
-- ------------------------- третий ряд слева ------------------------
{
x = 10,
y = 250,
width = 150,
height = 100,
t_l_radius = 20,
b_r_radius = 20,
colour = {{0, 0xc0c0c0, 1},{0.5, 0xc0c0c0, 1},{1, 0xc0c0c0, 1}},
},
{
x = 15,
y = 255,
width = 140,
height = 90,
t_l_radius = 20,
b_r_radius = 20,
colour = {{0, 0x000000, 1},{0.5, 0x000000, 1},{1, 0x000000, 1}},
},
-- ------------------------ третий ряд, справа -----------------
{
x = 180,
y = 250,
width = 150,
height = 150,
colour = {{0, 0xc0c0c0, 0.5},{0.5, 0xc0c0c0, 0.5},{1, 0xc0c0c0, 0.5}},
},
{
x = 190,
y = 260,
radius = 65,
width = 130,
height = 130,
colour = {{0, 0x101010, 1},{0.5, 0x101010, 1},{1, 0xa9a9a9, 1}},
orientation = "sw"
},
{
x = 200,
y = 270,
radius = 55,
width = 110,
height = 110,
colour = {{0, 0x101010, 1},{0.5, 0x101010, 1},{1, 0xa9a9a9, 1}},
orientation = "ne",
},
-- ----------------------- четвертый ряд слева ----------------------
{
x = 10,
y = 360,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "nn",
},
{
x = 95,
y = 360,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "ne",
},
{
x = 10,
y = 420,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "ee",
},
{
x = 95,
y = 420,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "se",
},
{
x = 10,
y = 480,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "ss",
},
{
x = 95,
y = 480,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "sw",
},
{
x = 10,
y = 540,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "ww",
},
{
x = 95,
y = 540,
width = 70,
height = 55,
colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FF00, 0.5},{1, 0xFFFF00, 0.1}},
orientation = "nw",
},
-- ---------------------- четвертый ряд справа -----------------------
{
x = 190,
y = 420,
radius = 65,
width = 130,
height = 130,
colour = {{0, 0x101010, 1},{0.5, 0x101010, 1},{1, 0xa9a9a9, 1}},
orientation = "sw"
},
{
x = 200,
y = 430,
radius = 55,
width = 110,
height = 110,
--colour = {{0, 0x101010, 1},{0.5, 0x101010, 1},{1, 0xa9a9a9, 1}},
orientation = "nn",
},
-- --------------------- горизонтальный бар ----------------
{
x = 190,
y = 560,
width = 150,
height = 30,
colour = {{0, 0xa9a9a9, 1},{0.5, 0xa9a9a9, 1},{1, 0xa9a9a9, 1}},
},
{
x = 205,
y = 573,
width = 120,
height = 6,
colour = {{0, 0x000000, 0.5},{0.5, 0x000000, 0.5},{1, 0x000000, 0.5}},
},
{
x = 205,
y = 573,
width = value*2,
height = 6,
colour = {{0, 0x00ff00, 0.5},{0.5, 0x00ff00, 0.5},{1, 0x00ff00, 0.5}},
},
}
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)
for i,v in pairs(backgraund_settings) do
display_background(v)
end
cairo_destroy(cr)
end
-- ------------------------------------------------------------
function display_background(t)
if t.x == nil then t.x = 0 end
if t.y == nil then t.y = 0 end
if t.width == nil then t.width = conky_window.width end
if t.height == nil then t.height = conky_window.height end
if t.t_l_radius == nil then t.t_l_radius = 0 end
if t.t_r_radius == nil then t.t_r_radius = 0 end
if t.b_l_radius == nil then t.b_l_radius = 0 end
if t.b_r_radius == nil then t.b_r_radius = 0 end
if t.orientation == nil then t.orientation = "ww" end
if t.radius ~= nil then t.t_l_radius, t.t_r_radius, t.b_l_radius, t.b_r_radius = t.radius, t.radius, t.radius, t.radius end
if t.colour == nil then
t.colour = {{0, 0x00ffff, 0.1},{0.5, 0x00FFFF, 0.5},{1, 0x00FFFF, 0.1}}
end
local degrees = math.pi / 180.0
cairo_new_sub_path (cr)
cairo_arc (cr, t.x + t.width - t.t_r_radius, t.y + t.t_r_radius, t.t_r_radius, -90 * degrees, 0 * degrees)
cairo_arc (cr, t.x + t.width - t.b_r_radius, t.y + t.height - t.b_r_radius, t.b_r_radius, 0 * degrees, 90 * degrees)
cairo_arc (cr, t.x + t.b_l_radius, t.y + t.height - t.b_l_radius, t.b_l_radius, 90 * degrees, 180 * degrees)
cairo_arc (cr, t.x + t.t_l_radius, t.y + t.t_l_radius, t.t_l_radius, 180 * degrees, 270 * degrees)
cairo_close_path (cr)
if #t.colour == 1 then
cairo_set_source_rgba(cr,rgb_to_r_g_b2(t.colour[1]))
else
local pat
local pts=linear_orientation_bg(t)
pat = cairo_pattern_create_linear (pts[1], pts[2], pts[3], pts[4])
for i=1, #t.colour do
cairo_pattern_add_color_stop_rgba (pat, t.colour[1], rgb_to_r_g_b2(t.colour))
end
cairo_set_source (cr, pat)
cairo_fill (cr)
cairo_pattern_destroy(pat)
end
end
-- ---------------------------------------
function rgb_to_r_g_b2(tcolour)
colour, alpha = tcolour[2], tcolour[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
-- ----------------------------------------
function linear_orientation_bg(t)
if t.orientation == "nn" then
p = {t.x + t.width/2, t.y, t.x + t.width/2, t.y + t.height}
elseif t.orientation == "ne" then
p = {t.x + t.width, t.y, t.x, t.y + t.height}
elseif t.orientation == "ee" then
p = {t.x + t.width, t.y + t.height/2, t.x, t.y + t.height/2}
elseif t.orientation == "se" then
p = {t.x +t.width, t.y + t.height, t.x, t.y}
elseif t.orientation == "ss" then
p = {t.x + t.width/2, t.y + t.height, t.x + t.width/2, t.y}
elseif t.orientation == "sw" then
p = {t.x, t.y + t.height, t.x + t.width, t.y}
elseif t.orientation == "ww" then
p = {t.x, t.y + t.height/2, t.x + t.width, t.y + t.height/2}
else
p = {t.x, t.y, t.x + t.width, t.y + t.height}
end
return p
end
комментарии в скрипте, если что непонятно спрашивайте в личку, на мыло и джабер.