1,951

Re: My Conky Config

dogmatictea wrote:

Hello all. I'm really honoured to be posting on this forum. I have discovered this through google recently and have been experimenting with everyone's conky for a while. I like what you all have done and will post my desktop (although I'm quite a noob, I won't give out my config because I know this code isn't mine, but a combination of a lot that I have found...) I do have one question though. If I wanted my mayan calendar by mrpeachy to..umm...let's say...turn red on 21/12/2012, what would that code be and where put it? Please and thanks?

your desktop looks great (not that i would be bias in any way)
as to your question
something like this where you set colors

nowdate=os.date("%d%m%Y") --days,month,year
changedate=21122012
if tonumber(nowdate)==changedate then
cairo_set_source_rgba (cr,1,0,0,1)--red
else
cairo_set_source_rgba (cr,1,1,1,1)--white
end

that should work w smile

Last edited by mrpeachy (2011-03-04 16:34:32)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

Re: My Conky Config

Sector11 wrote:

I plan on having a coffee with my friends on 22/12/2012!

Here's a little info I found on the Mayan calendar: http://failblog.org/2011/03/02/epic-fai … ag-mayans/

big_smile

When you do things right, people won’t be sure you’ve done anything at all.

1,953

Re: My Conky Config

thanks to sector11 for asking about printing the previous and next month days I found some problems with the calendar scrip and fixed them big_smile

here is the most up to date 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()
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 updates=tonumber(conky_parse('${updates}'))
--####################################################################################################
if updates>5 then -- starts the display
--####################################################################################################
--title text color
tred,tgreen,tblue,talpha=0.9,0,0.3,1
--title text font
tfont="Dystopia"
--title text size
tfontsize=22
--###################################################
--main body text color
bred,bgreen,bblue,balpha=0.6,1,0.6,1
--main body text font
mfont="Dystopia"
--main body text size
mfontsize=18
--###################################################
--highlight text color
hred,hgreen,hblue,halpha=1,1,0.2,1
--highlight font
hfont="Dystopia"
--highlight size
hfontsize=24
--###################################################
--surrounding numbers 1=om, 0=off
surround=1
--surrounding dates text color
sred,sgreen,sblue,salpha=0.3,0.5,0.3,1
--surrounding font
sfont="Dystopia"
--surounding size
sfontsize=18
--###################################################
--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=4
--set the box dimensions
width=35
height=21
--box color
xred,xgreen,xblue,xalpha=1,0.2,0.8,1
--###################################################
--calendar this month ###############################
--###################################################
--position
across=100.5
down=100.5
--rotate - this will require repositioning above
rotate=10
--###################################################
--horizontal gap between dates
gaph=35
--###################################################
--gap between day titles and first line
gapt=20
--###################################################
--gap between calendar line
gapl=20
--###################################################
--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
--###################################################
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
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
cairo_select_font_face (cr, mfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
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
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
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
cairo_select_font_face (cr, sfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
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,xred,xgreen,xblue,xalpha)
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>13 and place<23 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

like this
http://ompldr.org/tN25yYg

Last edited by mrpeachy (2011-03-04 18:32:43)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

1,954

Re: My Conky Config

Played with lua a bit

http://ompldr.org/tN25ycg

~/.conky/widgets.lua

--[[
Ring Meters by londonali1010 (2009)
 
This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
 
To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
    lua_load ~/scripts/rings-v1.2.1.lua
    lua_draw_hook_pre ring_stats
 
]]

-- Background settings
corner_r = 30
main_bg_colour    = 0x000000
main_bg_alpha     = 0.5
main_border_thick     = 2
main_border_color     = 0x000000
main_border_alpha     = 1
-- Bar ccolor settings
bar_bg_color = 0x000000
bar_bg_alpha = 0.7
bar_fg_color = 0x909090
bar_fg_alpha = 1
-- Bars Settings
bar_settings_table = {
    {
        name='mpd_percent',
        arg='',
        max='100',
        x=8, y=28,
        width='400',
        thickness='8',
        orientation='leftright',
        bg_color=bar_bg_color,
        bg_alpha=bar_bg_alpha,
        fg_color=bar_fg_color,
        fg_alpha=bar_fg_alpha,
        padding=1,
    }
}
-- Ring color settings
ring_background_color = 0x000000
ring_background_alpha = 0.7
ring_foreground_color = 0x909090
ring_foreground_alpha = 1
-- Rings settings
ring_settings_table = {
   {
        name='cpu',
        arg='cpu4',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=50, y=55,
        radius=23,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='cpu',
        arg='cpu3',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=50, y=55,
        radius=27,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='cpu',
        arg='cpu2',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=50, y=55,
        radius=31,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=50, y=55,
        radius=35,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=190, y=55,
        radius=32,
        thickness=10,
        start_angle=-180,
        end_angle=-0
    },
    {
        name='fs_used_perc',
        arg='/media/Data',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        g_alpha=ring_foreground_alpha,
        x=330, y=55,
        radius=36,
        thickness=7,
        start_angle=180,
        end_angle=360
    },
    {
        name='fs_used_perc',
        arg='/',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        g_alpha=ring_foreground_alpha,
        x=340, y=55,
        radius=36,
        thickness=7,
        start_angle=0,
        end_angle=180
    },
}
 

require 'cairo'
 
local function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
 
local function draw_ring(cr,t,pt)
    local w,h=conky_window.width,conky_window.height
 
    local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
    local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
 
    local angle_0=sa*(2*math.pi/360)-math.pi/2
    local angle_f=ea*(2*math.pi/360)-math.pi/2
    local t_arc=t*(angle_f-angle_0)
 
    -- Draw background ring
 
    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
    cairo_set_line_width(cr,ring_w)
    cairo_stroke(cr)
 
    -- Draw indicator ring
 
    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
    cairo_stroke(cr)        
end
local function draw_bar(cr,t,pt)
    local h,w=conky_window.height,conky_window.width
    local wth,thc,pdg=pt['width'],pt['thickness'],pt['padding']
    local tf=(wth-2*pdg)*t
    local bgc,bga,fgc,fga=pt['bg_color'],pt['bg_alpha'],pt['fg_color'],pt['fg_alpha']
    local bg_xi,bg_yi=pt['x'],pt['y']
    
    if pt['orientation'] == 'leftright' then
        bg_xf, bg_yf = bg_xi+wth, bg_yi
        fg_xi, fg_yi = bg_xi+pdg, bg_yi
        fg_xf, fg_yf = fg_xi+tf, fg_yi
    end
    if pt['orientation'] == 'rightleft' then
        bg_xf, bg_yf = bg_xi+wth, bg_yi
        fg_xi, fg_yi = bg_xf-pdg, bg_yf
        fg_xf, fg_yf = fg_xi-tf, fg_yi
    end
    if pt['orientation'] == 'updown' then
        bg_xf, bg_yf = bg_xi, bg_yi+wth
        fg_xi, fg_yi = bg_xi, bg_yi+pdg
        fg_xf, fg_yf = fg_xi, fg_yi+tf
    end
    if pt['orientation'] == 'downup' then
        bg_xf, bg_yf = bg_xi, bg_yi
        bg_yi = bg_yf+wth
        fg_xi, fg_yi = bg_xi, bg_yi-pdg
        fg_xf, fg_yf = fg_xi, fg_yi-tf
    end

    cairo_move_to(cr,bg_xi,bg_yi)
    cairo_line_to(cr,bg_xf,bg_yf)
    cairo_set_source_rgba(cr, rgb_to_r_g_b(bgc, bga))
    cairo_set_line_width(cr,thc)
    cairo_stroke(cr)

    cairo_move_to(cr,fg_xi,fg_yi)
    cairo_line_to(cr,fg_xf,fg_yf)
    cairo_set_source_rgba(cr, rgb_to_r_g_b(fgc, fga))
    cairo_set_line_width(cr, thc-(2*pdg))
    cairo_stroke(cr)
end
 
local function conky_widget_stats(widtype)
    local function setup_widgets(cr,pt,type)
        local str=''
        local value=0
 
        str=string.format('${%s %s}',pt['name'],pt['arg'])
        str=conky_parse(str)
 
        value=tonumber(str)
        if value == nil then value = 0 end
        pct=value/pt['max']
         if type == "ring" then draw_ring(cr,pct,pt) end
        if type == "bar"  then draw_bar(cr,pct,pt) end
        
    end
 
    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)
 
    local cr=cairo_create(cs)    
 
    --local updates=conky_parse('${updates}')
    --update_num=tonumber(updates)

   if widtype == 'ring' then
        for i in pairs(ring_settings_table) do
            setup_widgets(cr,ring_settings_table[i],"ring")
        end
    end
    if widtype == 'bar' then
        for i in pairs(bar_settings_table) do
            setup_widgets(cr,bar_settings_table[i],"bar")
        end
    end
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
end


--[[ This is a script made for draw a transaprent background for conky ]]

local function conky_draw_bg()
    if conky_window==nil then return end
    -- General
    local h=conky_window.height
    local w=conky_window.width
    local th=main_border_thick
    local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
    -- Background 
    local cr_bg=cairo_create(cs)
    -- Border setting
    local cr_br=cairo_create(cs)
    
    local function create_pattern(cr,w,h,t)
        cairo_move_to(cr,corner_r,t)
        cairo_line_to(cr,w-corner_r,t)
        cairo_curve_to(cr,w-t,t,w-t,t,w-t,corner_r)
        cairo_line_to(cr,w-t,h-corner_r)
        cairo_curve_to(cr,w-t,h-t,w-t,h-t,w-corner_r,h-t)
        cairo_line_to(cr,corner_r,h-t)
        cairo_curve_to(cr,t,h-t,t,h-t,t,h-corner_r)
        cairo_line_to(cr,t,corner_r)
        cairo_curve_to(cr,t,t,t,t,corner_r,t)
        cairo_close_path(cr)
     end

    create_pattern(cr_bg,w,h,th/2)
    create_pattern(cr_br,w,h,th)

    cairo_set_source_rgba(cr_bg,rgb_to_r_g_b(main_bg_colour,main_bg_alpha))
    cairo_set_source_rgba(cr_br,rgb_to_r_g_b(main_border_color,main_border_alpha))
    
    cairo_set_line_width(cr_br,th)
    
    cairo_fill(cr_bg)
    cairo_stroke(cr_br)
    
    cairo_destroy(cr_bg)
    cairo_destroy(cr_br)
    cairo_surface_destroy(cs)
end

function conky_main_first()
    conky_draw_bg()
    conky_widget_stats('ring')
--    conky_bar_stats()
end
function conky_main_second()
    conky_draw_bg()
    conky_widget_stats('bar')
--    conky_bar_stats()
end
"I'd rather run Linux on a 6.5KHz machine through an ARM emulator than run Vista"

1,955

Re: My Conky Config

SuNjACk wrote:

Played with lua a bit

http://ompldr.org/tN25ycg

~/.conky/widgets.lua

local function conky_draw_bg()
    if conky_window==nil then return end
    -- General
    local h=conky_window.height
    local w=conky_window.width
    local th=main_border_thick
    local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
    -- Background 
    local cr_bg=cairo_create(cs)
    -- Border setting
    local cr_br=cairo_create(cs)
    
    local function create_pattern(cr,w,h,t)
        cairo_move_to(cr,corner_r,t)
        cairo_line_to(cr,w-corner_r,t)
        cairo_curve_to(cr,w-t,t,w-t,t,w-t,corner_r)
        cairo_line_to(cr,w-t,h-corner_r)
        cairo_curve_to(cr,w-t,h-t,w-t,h-t,w-corner_r,h-t)
        cairo_line_to(cr,corner_r,h-t)
        cairo_curve_to(cr,t,h-t,t,h-t,t,h-corner_r)
        cairo_line_to(cr,t,corner_r)
        cairo_curve_to(cr,t,t,t,t,corner_r,t)
        cairo_close_path(cr)
     end

    create_pattern(cr_bg,w,h,th/2)
    create_pattern(cr_br,w,h,th)

    cairo_set_source_rgba(cr_bg,rgb_to_r_g_b(main_bg_colour,main_bg_alpha))
    cairo_set_source_rgba(cr_br,rgb_to_r_g_b(main_border_color,main_border_alpha))
    
    cairo_set_line_width(cr_br,th)
    
    cairo_fill(cr_bg)
    cairo_stroke(cr_br)
    
    cairo_destroy(cr_bg)
    cairo_destroy(cr_br)
    cairo_surface_destroy(cs)
end

that's some good looking code sunjack
i like how you have drawn your background and border
i would have drawn the shape twice, one time ending in fill and the second time ending in stroke
but your way is more elegant smile
i think i'll have to try this method out in the future!

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

1,956

Re: My Conky Config

mrpeachy wrote:

here are some of the things you can do
http://ompldr.org/tN25wZg

can the calendar show the previous and next month dates in the current blank spaces... well the answer is yes it could... i would just have to work out how big_smile

Well, aren't I slow, I've seen that before.  DUH!!!! big_smile
Thanks for the update

Damn, I'm always adding to your ToDo List - give this a priority (1-10, 10 the lowest) of --- oh say --- 87!
Again Thanks.

EDIT: saved as calendar_mrp.lua   big_smile

Last edited by Sector11 (2011-03-04 19:41:48)

1,957

Re: My Conky Config

lrs wrote:

Oh god, I posted in the wrong thread. Is there a way to delete this?

No you are stuck with this ...ummm .. to haunt you forever!!!!!!

and remind you that you are human - so relax!  smile

1,958

Re: My Conky Config

mrpeachy wrote:
SuNjACk wrote:

Played with lua a bit

http://ompldr.org/tN25ycg

~/.conky/widgets.lua

local function conky_draw_bg()
    if conky_window==nil then return end
    -- General
    local h=conky_window.height
    local w=conky_window.width
    local th=main_border_thick
    local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
    -- Background 
    local cr_bg=cairo_create(cs)
    -- Border setting
    local cr_br=cairo_create(cs)
    
    local function create_pattern(cr,w,h,t)
        cairo_move_to(cr,corner_r,t)
        cairo_line_to(cr,w-corner_r,t)
        cairo_curve_to(cr,w-t,t,w-t,t,w-t,corner_r)
        cairo_line_to(cr,w-t,h-corner_r)
        cairo_curve_to(cr,w-t,h-t,w-t,h-t,w-corner_r,h-t)
        cairo_line_to(cr,corner_r,h-t)
        cairo_curve_to(cr,t,h-t,t,h-t,t,h-corner_r)
        cairo_line_to(cr,t,corner_r)
        cairo_curve_to(cr,t,t,t,t,corner_r,t)
        cairo_close_path(cr)
     end

    create_pattern(cr_bg,w,h,th/2)
    create_pattern(cr_br,w,h,th)

    cairo_set_source_rgba(cr_bg,rgb_to_r_g_b(main_bg_colour,main_bg_alpha))
    cairo_set_source_rgba(cr_br,rgb_to_r_g_b(main_border_color,main_border_alpha))
    
    cairo_set_line_width(cr_br,th)
    
    cairo_fill(cr_bg)
    cairo_stroke(cr_br)
    
    cairo_destroy(cr_bg)
    cairo_destroy(cr_br)
    cairo_surface_destroy(cs)
end

that's some good looking code sunjack
i like how you have drawn your background and border
i would have drawn the shape twice, one time ending in fill and the second time ending in stroke
but your way is more elegant smile
i think i'll have to try this method out in the future!

Thanks mate

I have a question
How can I draw gradients? example on the bars

"I'd rather run Linux on a 6.5KHz machine through an ARM emulator than run Vista"

1,959

Re: My Conky Config

SuNjACk wrote:

Played with lua a bit

http://ompldr.org/tN25ycg

~/.conky/widgets.lua

Now that is some elegant!

1,960

Re: My Conky Config

hey sunjack, nice music choice. wink

registered Linux user: #533379
registered #! user: #6769
Whenever someone calls me a computer 'nerd' or a 'Unix-based-system'
all I can think is: You just wait. In a couple of years. I'll be your IT. Then where will you be!

1,961

Re: My Conky Config

@Sector11
i'm glad you did.  Not only did i find and fix a rather major problem in the script, i also cut the number of lines down and i think made the whole thing less processor intensive, although only by a bit im sure, but every bit helps smile

SuNjACk wrote:

Thanks mate

I have a question
How can I draw gradients? example on the bars

heres a link about gradients
http://cairographics.org/samples/gradient/

from this site which has lots of info about cairo drawing in lua
http://cairographics.org/documentation/
(samples is a good place to start)

i havn't done a whole lot with gradients... not sure how easy applying a gradient to a moving bar would be, so the gradient was always the same... if you see what i mean smile

Last edited by mrpeachy (2011-03-04 20:42:00)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

1,962

Re: My Conky Config

mrpeachy wrote:

@Sector11
i'm glad you did.  Not only did i find and fix a rather major problem in the script, i also cut the number of lines down and i think made the whole thing less processor intensive, although only by a bit im sure, but every bit helps smile

SuNjACk wrote:

Thanks mate

I have a question
How can I draw gradients? example on the bars

heres a link about gradients
http://cairographics.org/samples/gradient/

from this site which has lots of info about cairo drawing in lua
http://cairographics.org/documentation/
(samples is a good place to start)

i havn't done a whole lot with gradients... not sure how easy applying a gradient to a moving bar would be, so the gradient was always the same... if you see what i mean smile

The samples are in C unfortunaly sad

I don't know if the function are the same but I found this

http://www.dynaset.org/dogusanh/luacairo.html

"I'd rather run Linux on a 6.5KHz machine through an ARM emulator than run Vista"

1,963

Re: My Conky Config

SuNjACk wrote:

The samples are in C unfortunaly sad

I don't know if the function are the same but I found this

http://www.dynaset.org/dogusanh/luacairo.html

actually most of the samples you can put right into lua like so

num=conky_parse("${cpu}")
x,y=50,10
l,w=200,20
num=num/100
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 1, 1, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 0, 1);
cairo_rectangle (cr, x, y, l, w);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
cairo_set_source_rgba (cr, 0,0,0,1);
cairo_rectangle (cr,x+l,y,-l*(1-num),w)
cairo_fill (cr)

this draws a gradient bar of specified dimensions
then ive chaeted by drawing a black bar on top which hides/reveals the gradient with respect to cpu usage

but yes, sometimes you do have to tweak the code as it is written on those pages -- for example M_PI on the site would be math.pi in lua, and you dont need the "double" in the arc examples and obviously you comment with -- not /

your link looks interesting, ill have a read through it smile

UPDATE - this is a better way of doing it

num=conky_parse("${cpu}")
--position and size
x,y=50,10
l,w=200,20
--background gradient ##########
--start color
sbr,sbg,sbb,sba=0,0,0,1
--end coloe
ebr,ebg,ebb,eba=1,1,1,1
--indicator gradient ##########
--start color
sir,sig,sib,sia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--#############################
num=num/100
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 1, sbr,sbg,sbb,sba);
cairo_pattern_add_color_stop_rgba (pat, 0, ebr,ebg,ebb,eba);
cairo_rectangle (cr, x, y, l, w);
cairo_set_source (cr, pat);
cairo_fill (cr)
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 0, sir,sig,sib,sia);
cairo_pattern_add_color_stop_rgba (pat, 1, eir,eig,eib,eia);
cairo_rectangle (cr, x, y, l, w);
cairo_new_sub_path (cr); cairo_rectangle (cr, l+x, y, -l*(1-num), w);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source (cr, pat); cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, 0,0,0,0); cairo_fill (cr);
cairo_pattern_destroy (pat);

http://ompldr.org/tN252MQ

note the above is just a chunk of code, not a fully functional lua script

Last edited by mrpeachy (2011-03-04 21:57:56)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

Re: My Conky Config

mrpeachy wrote:

your desktop looks great (not that i would be bias in any way)
as to your question
something like this where you set colors
CODE
that should work w smile

Thank you sir. I'll implement it into your system. big_smile You all are definitely busy bees. I wish I knew more about LUA, but sadly my intro to comp sci class has only taught me a few things: How to use conky and how to program a scribblr. So I'll continue to mess with conky until my eyes fall out. Again, thank you all for what you're doing and keep on keeping on.

Last edited by dogmatictea (2011-03-05 00:03:37)

--Doesn't matter how you comment
##Just make it count.

1,965

Re: My Conky Config

mobilediesel wrote:
Sector11 wrote:

I plan on having a coffee with my friends on 22/12/2012!

Here's a little info I found on the Mayan calendar: http://failblog.org/2011/03/02/epic-fai … ag-mayans/

big_smile

Mobile - you're one bad dude!  lol  I like that!

1,966

Re: My Conky Config

mrpeachy wrote:

thanks to sector11 for asking about printing the previous and next month days I found some problems with the calendar scrip and fixed them big_smile

like this
http://ompldr.org/tN25yYg

WoW!!!!  That was fast!  And a BIG Thank You!

Re: My Conky Config

I might as well get comfy in these forums, because it looks like I have some troubleshooting to do. Haha. I tried the code to make it red and I'm getting no where. (Maybe I'm just oblivious when it comes to lua, but I'm trying. Haha) I decided to give it a test run just in case it didn't work out and I changed the changedate to 05032011 (my os.date)  I still end up getting a white ring. I think it's the placement of that code that is causing an issue. I went to the top and found a circlewriting section and placed it at the end of that section "where it says:
end
end
" and I get a segmentation failure. So then I moved on and put it between the two ends and it's still white. Finally I put it at the beginning of the two ends and nothing happened. I checked to see if placing it anywhere else would make sense and I couldn't find a spot. I'm starting to think I don't know where a good spot is. Here's where I left off. (You may want to fiddle with that changedate because I'm in Korea.)

--yearclock by mrpeachy 2010 version3, fixed 17 bug
require 'cairo'

function string:split(delimiter)
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 circlewriting(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
range=finish
deg=(finish-start)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start+(deg*(i-1))))+var1
interval2=degrads*(start+(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, tred, tgreen, tblue, talpha);
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2)
cairo_show_text (cr, (texttable[i]))
cairo_rotate (cr, -interval2)
cairo_move_to (cr,0,0)
cairo_set_source_rgba (cr, 0, 0, 0, 0)
cairo_line_to (cr,hx0,hy0)
cairo_stroke (cr)
--########################################--
-------------red on 12/21/2012--------------
nowdate=os.date("%d%m%Y") --days,month,year
changedate=05032011
if tonumber(nowdate)==changedate then
cairo_set_source_rgba (cr,1,0,0,1)--red
else
cairo_set_source_rgba (cr,1,1,1,1)--white
end
--########################################--
end
end

function date_to_words()------------------------------------------------------------------------------------------
date=os.date("%d")
datecut=string.gsub(date, ".", "%1|")
datetable=string.split(datecut, "|")
        
        if datetable[1]=="1" then
            datetens=""
            datespacer=""
            if datetable[2]=="0" then
            dateunit="tenth"
            elseif datetable[2]=="1" then
            dateunit="eleventh"
            elseif datetable[2]=="2" then
            dateunit="twelfth"
            elseif datetable[2]=="3" then
            dateunit="thirteenth"
            elseif datetable[2]=="4" then
            dateunit="fourteenth"
            elseif datetable[2]=="5" then
            dateunit="fifteenth"
            elseif datetable[2]=="6" then
            dateunit="sixteenth"
            elseif datetable[2]=="7" then
            fisrtdigit="seventeenth"
            elseif datetable[2]=="8" then
            dateunit="eighteenth"
            elseif datetable[2]=="9" then
            dateunit="nineteenth"
            end
        end 
          
        if datetable[1]=="0" or datetable[1]>"1" then
            datespacer=" "
            if datetable[1]=="2" then
            datetens="twenty"
            elseif datetable[1]=="3" then
            datetens="thirty"
            elseif datetable[1]=="0" then
            datetens=""
            end 
            if datetable[2]=="1" then
            dateunit="first"
            elseif datetable[2]=="2" then
            dateunit="second"
            elseif datetable[2]=="3" then
            dateunit="third"
            elseif datetable[2]=="4" then
            dateunit="fourth"
            elseif datetable[2]=="5" then
            dateunit="fifth"
            elseif datetable[2]=="6" then
            dateunit="sixth"
            elseif datetable[2]=="7" then
            dateunit="seventh"
            elseif datetable[2]=="8" then
            dateunit="eighth"
            elseif datetable[2]=="9" then
            dateunit="nineth"
            elseif datetable[2]=="0" then
            dateunit=""
            datespacer=""
            end
        end
        if datetable[2]=="0" then
            datetens=""
            datespacer=""
            if datetable[1]=="2" then
            dateunit="twentieth"
            elseif datetable[1]=="3" then
            dateunit="thirtieth"
            end
        end    
    return ((datetens) .. (datespacer) .. (dateunit))
end--end of function--------------------------------------------------------------------------------------

function number_to_words(text)
text=tonumber(text)
textlength=tonumber(string.len(text))
textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
--for NUMBERS from 1 to 999
--for 1 digit number----------
if textlength==1 then
    if tonumber(texttable[1])==1 then
    firstdigit="one"
    elseif tonumber(texttable[1])==2 then
    firstdigit="two"
    elseif tonumber(texttable[1])==3 then
    firstdigit="three"
    elseif tonumber(texttable[1])==4 then
    firstdigit="four"
    elseif tonumber(texttable[1])==5 then
    firstdigit="five"
    elseif tonumber(texttable[1])==6 then
    firstdigit="six"
    elseif tonumber(texttable[1])==7 then
    firstdigit="seven"
    elseif tonumber(texttable[1])==8 then
    firstdigit="eight"
    elseif tonumber(texttable[1])==9 then
    firstdigit="nine"
    elseif tonumber(texttable[1])==0 then
    firstdigit="zero"
    end
return (firstdigit)
end
--for 2 digit number------------------
if textlength==2 then
    if tonumber(texttable[1])==1 then
        seconddigit=""
        spacer=""
        if tonumber(texttable[2])==0 then
        firstdigit="ten"
        elseif tonumber(texttable[2])==1 then
        firstdigit="eleven"
        elseif tonumber(texttable[2])==2 then
        firstdigit="twelve"
        elseif tonumber(texttable[2])==3 then
        firstdigit="thirteen"
        elseif tonumber(texttable[2])==4 then
        firstdigit="fourteen"
        elseif tonumber(texttable[2])==5 then
        firstdigit="fifteen"
        elseif tonumber(texttable[2])==6 then
        firstdigit="sixteen"
        elseif tonumber(texttable[2])==7 then
        fisrtdigit="seventeen"
        elseif tonumber(texttable[2])==8 then
        firstdigit="eighteen"
        elseif tonumber(texttable[2])==9 then
        firstdigit="nineteen"
        end
    end   
    if tonumber(texttable[1])>1 then
        spacer=" "
        if tonumber(texttable[1])==2 then
        seconddigit="twenty"
        elseif tonumber(texttable[1])==3 then
        seconddigit="thirty"
        elseif tonumber(texttable[1])==4 then
        seconddigit="fourty"
        elseif tonumber(texttable[1])==5 then
        seconddigit="fifty"
        elseif tonumber(texttable[1])==6 then
        seconddigit="sixty"
        elseif tonumber(texttable[1])==7 then
        seconddigit="seventy"
        elseif tonumber(texttable[1])==8 then
        seconddigit="eighty"
        elseif tonumber(texttable[1])==9 then
        seconddigit="ninety"
        end
    
        if tonumber(texttable[2])==1 then
        firstdigit="one"
        elseif tonumber(texttable[2])==2 then
        firstdigit="two"
        elseif tonumber(texttable[2])==3 then
        firstdigit="three"
        elseif tonumber(texttable[2])==4 then
        firstdigit="four"
        elseif tonumber(texttable[2])==5 then
        firstdigit="five"
        elseif tonumber(texttable[2])==6 then
        firstdigit="six"
        elseif tonumber(texttable[2])==7 then
        firstdigit="seven"
        elseif tonumber(texttable[2])==8 then
        firstdigit="eight"
        elseif tonumber(texttable[2])==9 then
        firstdigit="nine"
        elseif tonumber(texttable[2])==0 then
        firstdigit=""
        spacer=""
        end
     end
return ((seconddigit) .. (spacer) .. (firstdigit))
end

--for 3 digit numbers-----------------------------
if textlength==3 then
    if tonumber(texttable[2])==0 and tonumber(texttable[3])==0 then space="" end
    if tonumber(texttable[2])>0 or tonumber(texttable[3])>0 then space=" and " end
    if tonumber(texttable[2])==0 and tonumber(texttable[3])>0 then spacer="" end
    
    if tonumber(texttable[1])==1 then
    thirddigit="one hundred"
    elseif tonumber(texttable[1])==2 then
    thirddigit="two hundred"
    elseif tonumber(texttable[1])==3 then
    thirddigit="three hundred"
    elseif tonumber(texttable[1])==4 then
    thirddigit="four hundred"
    elseif tonumber(texttable[1])==5 then
    thirddigit="five hundred"
    elseif tonumber(texttable[1])==6 then
    thirddigit="six hundred"
    elseif tonumber(texttable[1])==7 then
    thirddigit="seven hundred"
    elseif tonumber(texttable[1])==8 then
    thirddigit="eight hundred"
    elseif tonumber(texttable[1])==9 then
    thirddigit="nine hundred"
    end
    if tonumber(texttable[2])==0 or tonumber(texttable[2])>1 then
        if tonumber(texttable[3])==1 then
        firstdigit="one"
        elseif tonumber(texttable[3])==2 then
        firstdigit="two"
        elseif tonumber(texttable[3])==3 then
        firstdigit="three"
        elseif tonumber(texttable[3])==4 then
        firstdigit="four"
        elseif tonumber(texttable[3])==5 then
        firstdigit="five"
        elseif tonumber(texttable[3])==6 then
        firstdigit="six"
        elseif tonumber(texttable[3])==7 then
        firstdigit="seven"
        elseif tonumber(texttable[3])==8 then
        firstdigit="eight"
        elseif tonumber(texttable[3])==9 then
        firstdigit="nine"
        elseif tonumber(texttable[3])==0 then
        firstdigit=""
        spacer=""
        end 
    end
    if tonumber(texttable[2])==1 then
        seconddigit=""
        spacer=""  
        if tonumber(texttable[3])==0 then
        firstdigit="ten"
        elseif tonumber(texttable[3])==1 then
        firstdigit="eleven"
        elseif tonumber(texttable[3])==2 then
        firstdigit="twelve"
        elseif tonumber(texttable[3])==3 then
        firstdigit="thirteen"
        elseif tonumber(texttable[3])==4 then
        firstdigit="fourteen"
        elseif tonumber(texttable[3])==5 then
        firstdigit="fifteen"
        elseif tonumber(texttable[3])==6 then
        firstdigit="sixteen"
        elseif tonumber(texttable[3])==7 then
        firstdigit="seventeen"
        elseif tonumber(texttable[3])==8 then
        firstdigit="eighteen"
        elseif tonumber(texttable[3])==9 then
        firstdigit="nineteen"
        end
    end
    if tonumber(texttable[2])>1 then
        spacer=" "    
        if tonumber(texttable[2])==2 then
        seconddigit="twenty"
        elseif tonumber(texttable[2])==3 then
        seconddigit="thirty"
        elseif tonumber(texttable[2])==4 then
        seconddigit="fourty"
        elseif tonumber(texttable[2])==5 then
        seconddigit="fifty"
        elseif tonumber(texttable[2])==6 then
        seconddigit="sixty"
        elseif tonumber(texttable[2])==7 then
        seconddigit="seventy"
        elseif tonumber(texttable[2])==8 then
        seconddigit="eighty"
        elseif tonumber(texttable[2])==9 then
        seconddigit="ninety"
        elseif tonumber(texttable[2])==0 then
        seconddigit=""
        end
    end
return ((thirddigit) .. (space) .. (seconddigit) .. (spacer) .. (firstdigit))
end
end--of function

function conky_draw_fig()
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 updates=tonumber(conky_parse('${updates}'))
if updates > 5 then
--##########################################
cairo_set_line_width (cr,1)
hx0=200
hy0=200
radius=40
--############################################
--months of the year---------------------------------------------------------------------------------------------------
mnrad1=radius
mnrad2=mnrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
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} );
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
yeardays=31+febdaynum+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
jan=31*24*60*60
feb=jan+(febdaynum*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec }
--circle indicator lines
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
--indicator
doy=tonumber(os.date("%j"))
yrsecs=((doy-1)*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mnrad3=mnrad2+10
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+mnrad2*(math.sin(arc))
mny1=0-mnrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--circlewriting
--######################################################################--
--------------------patch for 17 bug--------------------------------------
year2d=os.date('%y')
if year2d==17 then
text1=((string.upper(os.date('%B'))) .. " TWO THOUSAND AND SEVENTEEN")
else
text1=((string.upper(os.date('%B'))) .. " TWO THOUSAND AND " .. string.upper(number_to_words(year2d)))
end
--######################################################################
--text must be in quotes
text=text1
--font name must be in quotes
font="mono"
fontsize=10
radius=mnrad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/yearsec)*((yrsecs))+4)
slen2=string.len(text)
finish=start+270
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end of months around year-------------------------------------------------------------------------------------------------------------------------------
--##########################################################################################
--days around month----------------------------------------------------------------------
drad1=mnrad3
drad2=drad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,drad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,drad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
monthnum=(tonumber(os.date('%m')))
monthdays = { 31, febdaynum, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--drawin circle indicator lines
for i=1,monthdays[monthnum] do
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx1=0+drad1*(math.sin(arc))
dy1=0-drad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx2=0+drad2*(math.sin(arc))
dy2=0-drad2*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
end
--indicator
daynumsec=(tonumber(os.date('%d'))*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
monthnumsec=(monthdays[monthnum])*24*60*60
drad3=drad2+10
arc=(2*math.pi/360)*((360/monthnumsec)*(daynumsec))
dx1=0+drad2*(math.sin(arc))
dy1=0-drad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))+4)
dx2=0+drad3*(math.sin(arc))
dy2=0-drad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))-4)
dx3=0+drad3*(math.sin(arc))
dy3=0-drad3*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx3,hy0+dy3)
cairo_stroke (cr)
--circlewriting
--########################################--
-------------patch for 17 bug---------------
days=tonumber(os.date("%d"))
if days==17 then text1=((string.upper(os.date('%A'))) .. " THE SEVENTEENTH")
else
text1=((string.upper(os.date('%A'))) .. " THE " .. string.upper(date_to_words()))
end
--########################################--
--text must be in quotes
text=text1
--font name must be in quotes
font="mono"
fontsize=10
radius=drad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/monthnumsec)*(daynumsec)+4)
slen1=string.len(text)
finish=start+(7.5*slen1)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end of days around month-------------------------------------------------------------------------------------------------------
--####################################################################################################################################
--hours around day ---------------------------------------------------------------------------------------------------------------------
hrad1=drad3
hrad2=hrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw eings
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
--draw ring indicator lines
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
--indicator
hrsec=(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
--mns=mn+sc
hrad3=hrad2+10
arc=((2*math.pi/360)*((360/(24*60*60)*hrsec)))
hx1=0+hrad2*(math.sin(arc))
hy1=0-hrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--circlewriting
hrnum=tonumber(os.date('%H'))
if hrnum==1 then hour="HOUR"
else hour="HOURS" end
--########################################--
-------------patch for 17 bug---------------
if hrnum==17 then text4="SEVENTEEN HOURS"
else
text4=((string.upper(number_to_words(hrnum))) .. " " .. hour)
end
--########################################--
--text must be in quotes
text=text4
--font name must be in quotes
font="mono"
fontsize=10
radius=hrad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/(24*60*60))*(hrsec)+4)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end of hours around day----------------------------------------------------------------------------------------------------
--##############################################################################################################################
--minutes around hour--------------------------------------------------------------------------------------------------------------
mrad1=hrad3
mrad2=mrad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,mrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mrad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+mrad1*(math.sin(arc))
my1=0-mrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+mrad2*(math.sin(arc))
my2=0-mrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
--indicator
minsec=(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mrad3=mrad2+10
arc=((2*math.pi/360)*((360/(60*60)*minsec)))
mx1=0+mrad2*(math.sin(arc))
my1=0-mrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)-4)
mx2=0+mrad3*(math.sin(arc))
my2=0-mrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)+4)
mx3=0+mrad3*(math.sin(arc))
my3=0-mrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--circlewriting
min=tonumber(os.date('%M'))
if min==1 then minute="MINUTE"
else minute="MINUTES" end
--########################################--
-------------patch for 17 bug---------------
if min==17 then text4="SEVENTEEN MINUTES"
else
text4=((string.upper(number_to_words(min))) .. " " .. minute)
end
--########################################--
text=text4
--font name must be in quotes
font="mono"
fontsize=10
radius=mrad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/(60*60))*(minsec)+4)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end minutes around hour--------------------------------------------------------------------------------------
--seconds of minute-------------------------------------------------------------------------------------------
srad1=mrad3
srad2=srad1+10
br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
--indicator
sec=(tonumber(os.date('%S')))
srad3=srad2+10
arc=((2*math.pi/360)*((360/(60)*sec)))
sx1=0+srad2*(math.sin(arc))
sy1=0-srad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--circlewriting
--circlewriting variable
sec=tonumber(os.date('%S'))
if sec==1 then second="SECOND"
else second="SECONDS" end
--########################################--
-------------patch for 17 bug---------------
if sec==17 then text3="SEVENTEEN SECONDS"
else
text3=(string.upper(number_to_words(sec)) .. " " .. second)
end
--########################################--
--text must be in quotes
text=text3
--font name must be in quotes
font="mono"
fontsize=10
radius=srad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/60)*((sec))+4)
slen3=string.len(text)
finish=start+(slen3*5)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end seconds of minute-----------------------------------------------------------------------------------------------------------------------------
--end of calendar---------------------------------------------------------------------------------------------------
end--of if updates>5
end--of main function

Last edited by dogmatictea (2011-03-05 00:34:15)

--Doesn't matter how you comment
##Just make it count.

1,968

Re: My Conky Config

dogmatictea wrote:

I might as well get comfy in these forums, because it looks like I have some troubleshooting to do. Haha. I tried the code to make it red and I'm getting no where. (Maybe I'm just oblivious when it comes to lua, but I'm trying. Haha) I decided to give it a test run just in case it didn't work out and I changed the changedate to 05032011 (my os.date)  I still end up getting a white ring. I think it's the placement of that code that is causing an issue. I went to the top and found a circlewriting section and placed it at the end of that section "where it says:
end
end
" and I get a segmentation failure. So then I moved on and put it between the two ends and it's still white. Finally I put it at the beginning of the two ends and nothing happened. I checked to see if placing it anywhere else would make sense and I couldn't find a spot. I'm starting to think I don't know where a good spot is. Here's where I left off. (You may want to fiddle with that changedate because I'm in Korea.)

function circlewriting(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
range=finish
deg=(finish-start)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start+(deg*(i-1))))+var1
interval2=degrads*(start+(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
--########################################--
-------------red on 12/21/2012--------------
nowdate=os.date("%d%m%Y") --days,month,year
changedate=05032011
if tonumber(nowdate)==changedate then
cairo_set_source_rgba (cr,1,0,0,1)--red
else
cairo_set_source_rgba (cr,1,1,1,1)--white
end
--########################################--
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval2)
end
end

isnt today 04032011 ? ah just read where you are smile

anyway...that should take care of the text (replace the existing circlewriting function wit the above)... the white lines are, unfortunately set for color in many places throughout the script -- seems to be working
http://ompldr.org/tN254bw
wherever you see "cairo_set_source_rgba (cr,1,1,1,1)"

Last edited by mrpeachy (2011-03-05 00:56:10)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

1,969

Re: My Conky Config

ok, here is version x of myanclock smile
now all the lines are colored by the same line
it has the color switching mechanism in 2 places, one in the circlewriting function and the second at the beginning of the main function

--yearclock by mrpeachy 2010 version3, fixed 17 bug
require 'cairo'

function string:split(delimiter)
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 circlewriting(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
range=finish
deg=(finish-start)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start+(deg*(i-1))))+var1
interval2=degrads*(start+(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
--########################################--
-------------red on 12/21/2012--------------
nowdate=os.date("%d%m%Y") --days,month,year
changedate=04032011
if tonumber(nowdate)==changedate then
cairo_set_source_rgba (cr,1,0,0,1)--red
else
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)--color set in script
end
--########################################--

cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval2)
end
end

function date_to_words()------------------------------------------------------------------------------------------
date=os.date("%d")
datecut=string.gsub(date, ".", "%1|")
datetable=string.split(datecut, "|")
        
        if datetable[1]=="1" then
            datetens=""
            datespacer=""
            if datetable[2]=="0" then
            dateunit="tenth"
            elseif datetable[2]=="1" then
            dateunit="eleventh"
            elseif datetable[2]=="2" then
            dateunit="twelfth"
            elseif datetable[2]=="3" then
            dateunit="thirteenth"
            elseif datetable[2]=="4" then
            dateunit="fourteenth"
            elseif datetable[2]=="5" then
            dateunit="fifteenth"
            elseif datetable[2]=="6" then
            dateunit="sixteenth"
            elseif datetable[2]=="7" then
            fisrtdigit="seventeenth"
            elseif datetable[2]=="8" then
            dateunit="eighteenth"
            elseif datetable[2]=="9" then
            dateunit="nineteenth"
            end
        end 
          
        if datetable[1]=="0" or datetable[1]>"1" then
            datespacer=" "
            if datetable[1]=="2" then
            datetens="twenty"
            elseif datetable[1]=="3" then
            datetens="thirty"
            elseif datetable[1]=="0" then
            datetens=""
            end 
            if datetable[2]=="1" then
            dateunit="first"
            elseif datetable[2]=="2" then
            dateunit="second"
            elseif datetable[2]=="3" then
            dateunit="third"
            elseif datetable[2]=="4" then
            dateunit="fourth"
            elseif datetable[2]=="5" then
            dateunit="fifth"
            elseif datetable[2]=="6" then
            dateunit="sixth"
            elseif datetable[2]=="7" then
            dateunit="seventh"
            elseif datetable[2]=="8" then
            dateunit="eighth"
            elseif datetable[2]=="9" then
            dateunit="nineth"
            elseif datetable[2]=="0" then
            dateunit=""
            datespacer=""
            end
        end
        if datetable[2]=="0" then
            datetens=""
            datespacer=""
            if datetable[1]=="2" then
            dateunit="twentieth"
            elseif datetable[1]=="3" then
            dateunit="thirtieth"
            end
        end    
    return ((datetens) .. (datespacer) .. (dateunit))
end--end of function--------------------------------------------------------------------------------------

function number_to_words(text)
text=tonumber(text)
textlength=tonumber(string.len(text))
textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
--for NUMBERS from 1 to 999
--for 1 digit number----------
if textlength==1 then
    if tonumber(texttable[1])==1 then
    firstdigit="one"
    elseif tonumber(texttable[1])==2 then
    firstdigit="two"
    elseif tonumber(texttable[1])==3 then
    firstdigit="three"
    elseif tonumber(texttable[1])==4 then
    firstdigit="four"
    elseif tonumber(texttable[1])==5 then
    firstdigit="five"
    elseif tonumber(texttable[1])==6 then
    firstdigit="six"
    elseif tonumber(texttable[1])==7 then
    firstdigit="seven"
    elseif tonumber(texttable[1])==8 then
    firstdigit="eight"
    elseif tonumber(texttable[1])==9 then
    firstdigit="nine"
    elseif tonumber(texttable[1])==0 then
    firstdigit="zero"
    end
return (firstdigit)
end
--for 2 digit number------------------
if textlength==2 then
    if tonumber(texttable[1])==1 then
        seconddigit=""
        spacer=""
        if tonumber(texttable[2])==0 then
        firstdigit="ten"
        elseif tonumber(texttable[2])==1 then
        firstdigit="eleven"
        elseif tonumber(texttable[2])==2 then
        firstdigit="twelve"
        elseif tonumber(texttable[2])==3 then
        firstdigit="thirteen"
        elseif tonumber(texttable[2])==4 then
        firstdigit="fourteen"
        elseif tonumber(texttable[2])==5 then
        firstdigit="fifteen"
        elseif tonumber(texttable[2])==6 then
        firstdigit="sixteen"
        elseif tonumber(texttable[2])==7 then
        fisrtdigit="seventeen"
        elseif tonumber(texttable[2])==8 then
        firstdigit="eighteen"
        elseif tonumber(texttable[2])==9 then
        firstdigit="nineteen"
        end
    end   
    if tonumber(texttable[1])>1 then
        spacer=" "
        if tonumber(texttable[1])==2 then
        seconddigit="twenty"
        elseif tonumber(texttable[1])==3 then
        seconddigit="thirty"
        elseif tonumber(texttable[1])==4 then
        seconddigit="fourty"
        elseif tonumber(texttable[1])==5 then
        seconddigit="fifty"
        elseif tonumber(texttable[1])==6 then
        seconddigit="sixty"
        elseif tonumber(texttable[1])==7 then
        seconddigit="seventy"
        elseif tonumber(texttable[1])==8 then
        seconddigit="eighty"
        elseif tonumber(texttable[1])==9 then
        seconddigit="ninety"
        end
    
        if tonumber(texttable[2])==1 then
        firstdigit="one"
        elseif tonumber(texttable[2])==2 then
        firstdigit="two"
        elseif tonumber(texttable[2])==3 then
        firstdigit="three"
        elseif tonumber(texttable[2])==4 then
        firstdigit="four"
        elseif tonumber(texttable[2])==5 then
        firstdigit="five"
        elseif tonumber(texttable[2])==6 then
        firstdigit="six"
        elseif tonumber(texttable[2])==7 then
        firstdigit="seven"
        elseif tonumber(texttable[2])==8 then
        firstdigit="eight"
        elseif tonumber(texttable[2])==9 then
        firstdigit="nine"
        elseif tonumber(texttable[2])==0 then
        firstdigit=""
        spacer=""
        end
     end
return ((seconddigit) .. (spacer) .. (firstdigit))
end

--for 3 digit numbers-----------------------------
if textlength==3 then
    if tonumber(texttable[2])==0 and tonumber(texttable[3])==0 then space="" end
    if tonumber(texttable[2])>0 or tonumber(texttable[3])>0 then space=" and " end
    if tonumber(texttable[2])==0 and tonumber(texttable[3])>0 then spacer="" end
    
    if tonumber(texttable[1])==1 then
    thirddigit="one hundred"
    elseif tonumber(texttable[1])==2 then
    thirddigit="two hundred"
    elseif tonumber(texttable[1])==3 then
    thirddigit="three hundred"
    elseif tonumber(texttable[1])==4 then
    thirddigit="four hundred"
    elseif tonumber(texttable[1])==5 then
    thirddigit="five hundred"
    elseif tonumber(texttable[1])==6 then
    thirddigit="six hundred"
    elseif tonumber(texttable[1])==7 then
    thirddigit="seven hundred"
    elseif tonumber(texttable[1])==8 then
    thirddigit="eight hundred"
    elseif tonumber(texttable[1])==9 then
    thirddigit="nine hundred"
    end
    if tonumber(texttable[2])==0 or tonumber(texttable[2])>1 then
        if tonumber(texttable[3])==1 then
        firstdigit="one"
        elseif tonumber(texttable[3])==2 then
        firstdigit="two"
        elseif tonumber(texttable[3])==3 then
        firstdigit="three"
        elseif tonumber(texttable[3])==4 then
        firstdigit="four"
        elseif tonumber(texttable[3])==5 then
        firstdigit="five"
        elseif tonumber(texttable[3])==6 then
        firstdigit="six"
        elseif tonumber(texttable[3])==7 then
        firstdigit="seven"
        elseif tonumber(texttable[3])==8 then
        firstdigit="eight"
        elseif tonumber(texttable[3])==9 then
        firstdigit="nine"
        elseif tonumber(texttable[3])==0 then
        firstdigit=""
        spacer=""
        end 
    end
    if tonumber(texttable[2])==1 then
        seconddigit=""
        spacer=""  
        if tonumber(texttable[3])==0 then
        firstdigit="ten"
        elseif tonumber(texttable[3])==1 then
        firstdigit="eleven"
        elseif tonumber(texttable[3])==2 then
        firstdigit="twelve"
        elseif tonumber(texttable[3])==3 then
        firstdigit="thirteen"
        elseif tonumber(texttable[3])==4 then
        firstdigit="fourteen"
        elseif tonumber(texttable[3])==5 then
        firstdigit="fifteen"
        elseif tonumber(texttable[3])==6 then
        firstdigit="sixteen"
        elseif tonumber(texttable[3])==7 then
        firstdigit="seventeen"
        elseif tonumber(texttable[3])==8 then
        firstdigit="eighteen"
        elseif tonumber(texttable[3])==9 then
        firstdigit="nineteen"
        end
    end
    if tonumber(texttable[2])>1 then
        spacer=" "    
        if tonumber(texttable[2])==2 then
        seconddigit="twenty"
        elseif tonumber(texttable[2])==3 then
        seconddigit="thirty"
        elseif tonumber(texttable[2])==4 then
        seconddigit="fourty"
        elseif tonumber(texttable[2])==5 then
        seconddigit="fifty"
        elseif tonumber(texttable[2])==6 then
        seconddigit="sixty"
        elseif tonumber(texttable[2])==7 then
        seconddigit="seventy"
        elseif tonumber(texttable[2])==8 then
        seconddigit="eighty"
        elseif tonumber(texttable[2])==9 then
        seconddigit="ninety"
        elseif tonumber(texttable[2])==0 then
        seconddigit=""
        end
    end
return ((thirddigit) .. (space) .. (seconddigit) .. (spacer) .. (firstdigit))
end
end--of function

function conky_draw_fig()
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 updates=tonumber(conky_parse('${updates}'))
if updates > 5 then
--##########################################
cairo_set_line_width (cr,1)
hx0=200
hy0=200
radius=40
--line color
--########################################--
-------------red on 12/21/2012--------------
nowdate=os.date("%d%m%Y") --days,month,year
changedate=04032011
if tonumber(nowdate)==changedate then
br1,bg1,bb1,ba1=1,0,0,1
else
br1,bg1,bb1,ba1=1,1,1,1
end
--############################################
--months of the year---------------------------------------------------------------------------------------------------
mnrad1=radius
mnrad2=mnrad1+10
--br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,mnrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mnrad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
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} );
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
yeardays=31+febdaynum+31+30+31+30+31+31+30+31+30+31
yearsec=(yeardays*24*60*60)
jan=31*24*60*60
feb=jan+(febdaynum*24*60*60)
mar=feb+(31*24*60*60)
apr=mar+(30*24*60*60)
may=apr+(31*24*60*60)
jun=may+(30*24*60*60)
jul=jun+(31*24*60*60)
aug=jul+(31*24*60*60)
sep=aug+(30*24*60*60)
oct=sep+(31*24*60*60)
nov=oct+(30*24*60*60)
dec=nov+(31*24*60*60)
secdays = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec }
--circle indicator lines
for i=1,12 do
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx1=0+mnrad1*(math.sin(arc))
mny1=0-mnrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/yearsec)*(secdays[i])))
mnx2=0+mnrad2*(math.sin(arc))
mny2=0-mnrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
end
--indicator
doy=tonumber(os.date("%j"))
yrsecs=((doy-1)*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mnrad3=mnrad2+10
arc=(2*math.pi/360)*((360/yearsec)*(yrsecs))
mnx1=0+mnrad2*(math.sin(arc))
mny1=0-mnrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))+4)
mnx2=0+mnrad3*(math.sin(arc))
mny2=0-mnrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/yearsec)*((yrsecs))-4)
mnx3=0+mnrad3*(math.sin(arc))
mny3=0-mnrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx2,hy0+mny2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mnx1,hy0+mny1)
cairo_line_to (cr,hx0+mnx3,hy0+mny3)
cairo_stroke (cr)
--circlewriting
--######################################################################--
--------------------patch for 17 bug--------------------------------------
year2d=os.date('%y')
if year2d==17 then
text1=((string.upper(os.date('%B'))) .. " TWO THOUSAND AND SEVENTEEN")
else
text1=((string.upper(os.date('%B'))) .. " TWO THOUSAND AND " .. string.upper(number_to_words(year2d)))
end
--######################################################################
--text must be in quotes
text=text1
--font name must be in quotes
font="mono"
fontsize=10
radius=mnrad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/yearsec)*((yrsecs))+4)
slen2=string.len(text)
finish=start+270
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end of months around year-------------------------------------------------------------------------------------------------------------------------------
--##########################################################################################
--days around month----------------------------------------------------------------------
drad1=mnrad3
drad2=drad1+10
--br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,drad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,drad2,0,2*math.pi)
cairo_stroke (cr)
--calculations
monthnum=(tonumber(os.date('%m')))
monthdays = { 31, febdaynum, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--drawin circle indicator lines
for i=1,monthdays[monthnum] do
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx1=0+drad1*(math.sin(arc))
dy1=0-drad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/monthdays[monthnum])*(i)))
dx2=0+drad2*(math.sin(arc))
dy2=0-drad2*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
end
--indicator
daynumsec=(tonumber(os.date('%d'))*24*60*60)+(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
monthnumsec=(monthdays[monthnum])*24*60*60
drad3=drad2+10
arc=(2*math.pi/360)*((360/monthnumsec)*(daynumsec))
dx1=0+drad2*(math.sin(arc))
dy1=0-drad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))+4)
dx2=0+drad3*(math.sin(arc))
dy2=0-drad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/monthnumsec)*((daynumsec))-4)
dx3=0+drad3*(math.sin(arc))
dy3=0-drad3*(math.cos(arc))
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx2,hy0+dy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+dx1,hy0+dy1)
cairo_line_to (cr,hx0+dx3,hy0+dy3)
cairo_stroke (cr)
--circlewriting
--########################################--
-------------patch for 17 bug---------------
days=tonumber(os.date("%d"))
if days==17 then text1=((string.upper(os.date('%A'))) .. " THE SEVENTEENTH")
else
text1=((string.upper(os.date('%A'))) .. " THE " .. string.upper(date_to_words()))
end
--########################################--
--text must be in quotes
text=text1
--font name must be in quotes
font="mono"
fontsize=10
radius=drad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/monthnumsec)*(daynumsec)+4)
slen1=string.len(text)
finish=start+(7.5*slen1)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end of days around month-------------------------------------------------------------------------------------------------------
--####################################################################################################################################
--hours around day ---------------------------------------------------------------------------------------------------------------------
hrad1=drad3
hrad2=hrad1+10
--br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw eings
cairo_arc (cr,hx0,hy0,hrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,hrad2,0,2*math.pi)
cairo_stroke (cr)
--draw ring indicator lines
for i=1,24 do
arc=((2*math.pi/360)*((360/24)*i))
hx1=0+hrad1*(math.sin(arc))
hy1=0-hrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/24)*i))
hx2=0+hrad2*(math.sin(arc))
hy2=0-hrad2*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
end
--indicator
hrsec=(tonumber(os.date('%H'))*60*60)+(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
--mns=mn+sc
hrad3=hrad2+10
arc=((2*math.pi/360)*((360/(24*60*60)*hrsec)))
hx1=0+hrad2*(math.sin(arc))
hy1=0-hrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)-4)
hx2=0+hrad3*(math.sin(arc))
hy2=0-hrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(24*60*60))*(hrsec)+4)
hx3=0+hrad3*(math.sin(arc))
hy3=0-hrad3*(math.cos(arc))
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx2,hy0+hy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+hx1,hy0+hy1)
cairo_line_to (cr,hx0+hx3,hy0+hy3)
cairo_stroke (cr)
--circlewriting
hrnum=tonumber(os.date('%H'))
if hrnum==1 then hour="HOUR"
else hour="HOURS" end
--########################################--
-------------patch for 17 bug---------------
if hrnum==17 then text4="SEVENTEEN HOURS"
else
text4=((string.upper(number_to_words(hrnum))) .. " " .. hour)
end
--########################################--
--text must be in quotes
text=text4
--font name must be in quotes
font="mono"
fontsize=10
radius=hrad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/(24*60*60))*(hrsec)+4)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end of hours around day----------------------------------------------------------------------------------------------------
--##############################################################################################################################
--minutes around hour--------------------------------------------------------------------------------------------------------------
mrad1=hrad3
mrad2=mrad1+10
--br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,mrad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,mrad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
mx1=0+mrad1*(math.sin(arc))
my1=0-mrad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
mx2=0+mrad2*(math.sin(arc))
my2=0-mrad2*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
end
--indicator
minsec=(tonumber(os.date('%M'))*60)+(tonumber(os.date('%S')))
mrad3=mrad2+10
arc=((2*math.pi/360)*((360/(60*60)*minsec)))
mx1=0+mrad2*(math.sin(arc))
my1=0-mrad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)-4)
mx2=0+mrad3*(math.sin(arc))
my2=0-mrad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/(60*60))*(minsec)+4)
mx3=0+mrad3*(math.sin(arc))
my3=0-mrad3*(math.cos(arc))
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx2,hy0+my2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+mx1,hy0+my1)
cairo_line_to (cr,hx0+mx3,hy0+my3)
cairo_stroke (cr)
--circlewriting
min=tonumber(os.date('%M'))
if min==1 then minute="MINUTE"
else minute="MINUTES" end
--########################################--
-------------patch for 17 bug---------------
if min==17 then text4="SEVENTEEN MINUTES"
else
text4=((string.upper(number_to_words(min))) .. " " .. minute)
end
--########################################--
text=text4
--font name must be in quotes
font="mono"
fontsize=10
radius=mrad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/(60*60))*(minsec)+4)
slen4=string.len(text)
finish=start+(slen4*5)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end minutes around hour--------------------------------------------------------------------------------------
--seconds of minute-------------------------------------------------------------------------------------------
srad1=mrad3
srad2=srad1+10
--br1,bg1,bb1,ba1=1,1,1,1
cairo_set_source_rgba (cr,br1,bg1,bb1,ba1)
--draw circles
cairo_arc (cr,hx0,hy0,srad1,0,2*math.pi)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad2,0,2*math.pi)
cairo_stroke (cr)
--draw circle indicator lines
for i=1,60 do
arc=((2*math.pi/360)*((360/60)*i))
sx1=0+srad1*(math.sin(arc))
sy1=0-srad1*(math.cos(arc))
arc=((2*math.pi/360)*((360/60)*i))
sx2=0+srad2*(math.sin(arc))
sy2=0-srad2*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
end
--indicator
sec=(tonumber(os.date('%S')))
srad3=srad2+10
arc=((2*math.pi/360)*((360/(60)*sec)))
sx1=0+srad2*(math.sin(arc))
sy1=0-srad2*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))-4)
sx2=0+srad3*(math.sin(arc))
sy2=0-srad3*(math.cos(arc))
arc=(2*math.pi/360)*((360/60)*((sec))+4)
sx3=0+srad3*(math.sin(arc))
sy3=0-srad3*(math.cos(arc))
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx2,hy0+sy2)
cairo_stroke (cr)
cairo_move_to (cr,hx0+sx1,hy0+sy1)
cairo_line_to (cr,hx0+sx3,hy0+sy3)
cairo_stroke (cr)
cairo_arc (cr,hx0,hy0,srad3,0,2*math.pi)
cairo_stroke (cr)
--circlewriting
--circlewriting variable
sec=tonumber(os.date('%S'))
if sec==1 then second="SECOND"
else second="SECONDS" end
--########################################--
-------------patch for 17 bug---------------
if sec==17 then text3="SEVENTEEN SECONDS"
else
text3=(string.upper(number_to_words(sec)) .. " " .. second)
end
--########################################--
--text must be in quotes
text=text3
--font name must be in quotes
font="mono"
fontsize=10
radius=srad2+1
positionx=hx0
positiony=hy0
colorred=1
colorgreen=1
colorblue=1
coloralpha=1
--to set start and finish values for circlewriting, if the text will cross 0 degrees then you must calculate for 360+finish degrees
--eg if you want to go from 270 to 90, then you will input 270 to 450.  Finish has to be greater than start.
start=((360/60)*((sec))+4)
slen3=string.len(text)
finish=start+(slen3*5)
letterposition=0
circlewriting(cr, text, font, fontsize, radius, positionx, positiony, colorred, colorgreen, colorblue, coloralpha, start, finish, letterposition)
--end seconds of minute-----------------------------------------------------------------------------------------------------------------------------
--end of calendar---------------------------------------------------------------------------------------------------
end--of if updates>5
end--of main function

Last edited by mrpeachy (2011-03-05 01:05:11)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

1,970

Re: My Conky Config

more from me
some gradient bars
http://ompldr.org/tN254dg
- cpu
- memperc,
- fs_used_perc /
- fs_used_perc /home
- demo bar

plug them into your conky smile
you can change colors and sizes, positions etc

--lua calendar script by mrpeachy Feb 2011
require 'cairo'

function gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
num=num/100
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 1, sbr,sbg,sbb,sba);
cairo_pattern_add_color_stop_rgba (pat, 0.5, mbr,mbg,mbb,mba);
cairo_pattern_add_color_stop_rgba (pat, 0, ebr,ebg,ebb,eba);
cairo_rectangle (cr, x, y, l, w);
cairo_set_source (cr, pat);
cairo_fill (cr)
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 0, sir,sig,sib,sia);
cairo_pattern_add_color_stop_rgba (pat, 0.5, mir,mig,mib,mia);
cairo_pattern_add_color_stop_rgba (pat, 1, eir,eig,eib,eia);
cairo_rectangle (cr, x, y, l, w);
cairo_new_sub_path (cr); cairo_rectangle (cr, l+x, y, -l*(1-num), w);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source (cr, pat); cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, 0,0,0,0); cairo_fill (cr);
cairo_pattern_destroy (pat);
end--function
--------------------------------------------------------------------------------
function conky_draw_fig()
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 updates=tonumber(conky_parse('${updates}'))
--####################################################################################################
if updates>5 then -- starts the display
--####################################################################################################
--###############################################
--SETTINGS FOR BAR 1#############################
num=conky_parse("${cpu}")
--position and size
x,y=50,50
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 2#############################
num=conky_parse("${memperc}")
--position and size
x,y=50,100
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 3#############################
num=conky_parse("${fs_used_perc /}")
--position and size
x,y=50,150
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 4#############################
num=conky_parse("${fs_used_perc /home}")
--position and size
x,y=50,200
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 5#############################
num=100--conky_parse("${cpu}") -- demonstration bar to show 100%
--position and size
x,y=50,250
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
end--end if 5
end--end main function

Last edited by mrpeachy (2011-03-05 01:14:20)

It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.

Re: My Conky Config

mrpeachy wrote:

ok, here is version x of myanclock smile
now all the lines are colored by the same line
it has the color switching mechanism in 2 places, one in the circlewriting function and the second at the beginning of the main function
CODE

You, sir, are a wizard. I'm going to spend the rest of my time before lunch crafting a red version of the libra scale in the center of it. Looks like I'm going to frequent these forums more than I thought.. and I like it. Desktop link!:

http://i9.photobucket.com/albums/a81/JO … shot-3.png

Everything went better than expected.

--Doesn't matter how you comment
##Just make it count.

1,972

Re: My Conky Config

dogmatictea I see that you like the mac look sad lost anther good #!er to it.

Last edited by crunchy (2011-03-05 02:13:20)

registered Linux user: #533379
registered #! user: #6769
Whenever someone calls me a computer 'nerd' or a 'Unix-based-system'
all I can think is: You just wait. In a couple of years. I'll be your IT. Then where will you be!

Re: My Conky Config

crunchy wrote:

dogmatictea I see that you like the mac look sad lost anther good #!er to it.

I will admit, the mac look has caught my eye. Honestly though, it's not the mac that I like. It's the idea of a dock in general. I wasn't even possessed to get a dock when I saw the mac dock. It wasn't until I installed rocketdock on my sister's vista that I decided it was time to give docks a try.

edit: one more thing. I thought it would work, but it's posing some trouble

${if_match ${time %D}=03/07/11} ${image /home/dogmatictea/.ubulogos/sign07_librared.png -p 148,144 -s 100x94}${else}${image /home/dogmatictea/.ubulogos/sign07_libra.png -p 148,144 -s 100x94}${endif}

I was attempting to make it red on a certain day (then I'd change it to the 2012 date). The issue is that it is only showing red. I'm trying different time code and different time values for it to equal to, but nothing happens and it continues to stay red. I'm starting to wonder if you could even do an if_match statement with time.

edit2: it was a simple "me being dumb mistake" I tested it. it works. here's the final product.

${if_match "${time %d%m%Y}" > "21122012"} ${image /home/dogmatictea/.ubulogos/sign07_librared.png -p 148,144 -s 100x94}${else}${image /home/dogmatictea/.ubulogos/sign07_libra.png -p 148,144 -s 100x94}${endif}

Last edited by dogmatictea (2011-03-05 03:25:05)

--Doesn't matter how you comment
##Just make it count.

1,974

Re: My Conky Config

@dogmatictea I might try that doc. if I can make it look less like mac. I don't really like the mac look quite as much. I like the #! look (black and white) so much more.

registered Linux user: #533379
registered #! user: #6769
Whenever someone calls me a computer 'nerd' or a 'Unix-based-system'
all I can think is: You just wait. In a couple of years. I'll be your IT. Then where will you be!

1,975

Re: My Conky Config

added gradient rings to the gradient bars script like so
http://ompldr.org/tN285ag

--gradient bars and rings by mrpeachy march 2011
--currently only good for conky variables that return % values
require 'cairo'

function gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
num=num/100
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 1, sbr,sbg,sbb,sba);
cairo_pattern_add_color_stop_rgba (pat, 0.5, mbr,mbg,mbb,mba);
cairo_pattern_add_color_stop_rgba (pat, 0, ebr,ebg,ebb,eba);
cairo_rectangle (cr, x, y, l, w);
cairo_set_source (cr, pat);
cairo_fill (cr)
pat = cairo_pattern_create_linear (x, y, x+l, y);
cairo_pattern_add_color_stop_rgba (pat, 0, sir,sig,sib,sia);
cairo_pattern_add_color_stop_rgba (pat, 0.5, mir,mig,mib,mia);
cairo_pattern_add_color_stop_rgba (pat, 1, eir,eig,eib,eia);
cairo_rectangle (cr, x, y, l, w);
cairo_new_sub_path (cr); cairo_rectangle (cr, l+x, y, -l*(1-num), w);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source (cr, pat); cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, 0,0,0,0); cairo_fill (cr);
cairo_pattern_destroy (pat);
end--function
function gcircle (num,x,y,radius,width,sangle,fangle,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia,overlap)
red={}
green={}
blue={}
alpha={}
for i=1,100 do
if i<51 then
red[i]=((mir-sir)*(i/50))+sir
green[i]=((mig-sig)*(i/50))+sig
blue[i]=((mib-sib)*(i/50))+sib
alpha[i]=((mia-sia)*(i/50))+sia
end
if i>50 then
red[i]=((eir-mir)*((i-50)/50))+mir
green[i]=((eig-mig)*((i-50)/50))+mig
blue[i]=((eib-mib)*((i-50)/50))+mib
alpha[i]=((eia-mia)*((i-50)/50))+mia
end
end
bred={}
bgreen={}
bblue={}
balpha={}
for i=1,100 do
if i<51 then
bred[i]=((mbr-sbr)*(i/50))+sbr
bgreen[i]=((mbg-sbg)*(i/50))+sbg
bblue[i]=((mbb-sbb)*(i/50))+sbb
balpha[i]=((mba-sba)*(i/50))+sba
end
if i>50 then
bred[i]=((ebr-mbr)*((i-50)/50))+mbr
bgreen[i]=((ebg-mbg)*((i-50)/50))+mbg
bblue[i]=((ebb-mbb)*((i-50)/50))+mbb
balpha[i]=((eba-mba)*((i-50)/50))+mba
end
end
cva=math.pi/180
cvsa=sangle*cva
cvfa=fangle*cva
adj=360/(fangle-sangle)*overlap
zt=cva*90
diff=(fangle-sangle)/100
for i=1,100 do
cairo_set_line_width (cr, width)
cairo_set_source_rgba (cr, bred[i], bgreen[i], bblue[i], balpha[i])
cairo_arc (cr,x,y,radius,cvsa+(cva*(diff*(i-adj)))-zt,cvsa+(cva*(diff*i))-zt)
cairo_stroke (cr)
end
for i=1,tonumber(num) do
cairo_set_line_width (cr, width)
cairo_set_source_rgba (cr, red[i], green[i], blue[i], alpha[i])
cairo_arc (cr,x,y,radius,cvsa+(cva*(diff*(i-adj)))-zt,cvsa+(cva*(diff*i))-zt)
cairo_stroke (cr)
end
end--function
--------------------------------------------------------------------------------
function conky_draw_fig()
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 updates=tonumber(conky_parse('${updates}'))
--####################################################################################################
if updates>5 then -- starts the display
--####################################################################################################
--###############################################
--SETTINGS FOR BAR 1#############################
num=conky_parse("${cpu}")
--position and size
x,y=50,50
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 2#############################
num=conky_parse("${memperc}")
--position and size
x,y=50,100
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 3#############################
num=conky_parse("${fs_used_perc /}")
--position and size
x,y=50,150
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 4#############################
num=conky_parse("${fs_used_perc /home}")
--position and size
x,y=50,200
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################
--SETTINGS FOR BAR 5#############################
num=100--conky_parse("${cpu}") -- demonstration bar to show 100%
--position and size
x,y=50,250
l,w=300,5
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.3,0.3,0.3,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.9,0.9,0.9,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--call drawing function #####################################################################################
gbar(x,y,l,w,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia)
--###########################################################################################################
--copy and paste above section for more bars ####
--###############################################

--################################################
--SETTINGS FOR RING 1 ############################
--################################################
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.9,0.9,0.9,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.3,0.3,0.3,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--settings #########################################
--conky value
num=conky_parse("${cpu}")
--line width
width=5
--circle radius
radius=60
--position
x,y=100,400
--start and end angles for ring
sangle,fangle=0,360
--if you see line artefacts in the circle drawn
--then increase this number in increments of 0.01 until they disappear
--otherwise set 1
overlap=1.09
--call drawing function ############################################################################################################################
gcircle (num,x,y,radius,width,sangle,fangle,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia,overlap)
--###########################################################################################################
--copy and paste above section for more rings ####
--################################################

--################################################
--SETTINGS FOR RING 2 ############################
--################################################
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.9,0.9,0.9,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.3,0.3,0.3,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--settings #########################################
--conky value
num=conky_parse("${memperc}")
--line width
width=5
--circle radius
radius=60
--position
x,y=250,400
--start and end angles for ring
sangle,fangle=0,360
--if you see line artefacts in the circle drawn
--then increase this number in increments of 0.01 until they disappear
--otherwise set 1
overlap=1.09
--call drawing function ############################################################################################################################
gcircle (num,x,y,radius,width,sangle,fangle,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia,overlap)
--###########################################################################################################
--copy and paste above section for more rings ####
--################################################

--################################################
--SETTINGS FOR RING 3 ############################
--################################################
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.9,0.9,0.9,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.3,0.3,0.3,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--settings #########################################
--conky value
num=conky_parse("${fs_used_perc /}")
--line width
width=5
--circle radius
radius=60
--position
x,y=400,400
--start and end angles for ring
sangle,fangle=0,360
--if you see line artefacts in the circle drawn
--then increase this number in increments of 0.01 until they disappear
--otherwise set 1
overlap=1.09
--call drawing function ############################################################################################################################
gcircle (num,x,y,radius,width,sangle,fangle,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia,overlap)
--###########################################################################################################
--copy and paste above section for more rings ####
--################################################

--################################################
--SETTINGS FOR RING 4 ############################
--################################################
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.9,0.9,0.9,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.3,0.3,0.3,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--settings #########################################
--conky value
num=conky_parse("${fs_used_perc /home}")
--line width
width=5
--circle radius
radius=60
--position
x,y=550,400
--start and end angles for ring
sangle,fangle=0,360
--if you see line artefacts in the circle drawn
--then increase this number in increments of 0.01 until they disappear
--otherwise set 1
overlap=1.09
--call drawing function ############################################################################################################################
gcircle (num,x,y,radius,width,sangle,fangle,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia,overlap)
--###########################################################################################################
--copy and paste above section for more rings ####
--################################################

--################################################
--SETTINGS FOR RING 5 ############################
--################################################
--background gradient ############################
--start color
sbr,sbg,sbb,sba=0.9,0.9,0.9,1
--middle color
mbr,mbg,mbb,mba=0.6,0.6,0.6,1
--end color
ebr,ebg,ebb,eba=0.3,0.3,0.3,1
--indicator gradient ##############################
--start color
sir,sig,sib,sia=0,1,0,1
--middle color
mir,mig,mib,mia=1,1,0,1
--end color
eir,eig,eib,eia=1,0,0,1
--settings #########################################
--conky value
num=100--demonstration ring
--line width
width=5
--circle radius
radius=60
--position
x,y=700,400
--start and end angles for ring
sangle,fangle=0,360
--if you see line artefacts in the circle drawn
--then increase this number in increments of 0.01 until they disappear
--otherwise set 1
overlap=1.09
--call drawing function ############################################################################################################################
gcircle (num,x,y,radius,width,sangle,fangle,sbr,sbg,sbb,sba,mbr,mbg,mbb,mba,ebr,ebg,ebb,eba,sir,sig,sib,sia,mir,mig,mib,mia,eir,eig,eib,eia,overlap)
--###########################################################################################################
--copy and paste above section for more rings ####
--################################################

--###############################################################
end--end if 5
end--end main function
It's hard to find something if you don't know what you're looking for.
I have a blog, it's mostly about conky and lua stuff... go here.