SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#3326 2012-10-16 13:18:42

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

Help fund CrunchBang, donate to the project!

#3327 2012-10-16 16:40:05

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 459

Re: Conky v1.9 Thread

Last edited by lionhead (2012-10-16 16:44:55)

Offline

#3328 2012-10-16 18:52:09

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

 lua_load ~/Conky/LUA/isometric_bars.lua
 lua_draw_hook_pre draw_shape

TEXT
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.3}



       ${fs_free_perc /}%${goto 125}${fs_free_perc /home}%${goto 195}${fs_free_perc /media/5}%${goto 250}${memfree}









       ${fs_used_perc /}%${goto 125}${fs_used_perc /home}%${goto 195}${fs_used_perc /media/5}%${goto 265}${memperc}%














       ${cpu cpu0}%${goto 125}${cpu cpu1}%${goto 195}${cpu cpu2}%${goto 265}${cpu cpu3}%

Last edited by Sector11 (2012-10-16 18:57:38)

Offline

#3329 2012-10-16 19:25:15

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

function settings()
 local settings_table = {
     {    
        -- ROOT
        conkyobject=conky_parse('${fs_used_perc /}'),
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        etc
        etc
      }
}
return settings_table
end--of settings function

Last edited by mrpeachy (2012-10-16 19:38:37)

Offline

#3330 2012-10-16 21:10:34

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

 --[[
 ###############################################################################
 ###   Part 1 - Define the LUA module                                        ###
 ###############################################################################
 --]]
 -- mrpeachy_bar3d.module

 local modname = ...
 local M = {}
 _G[modname] = M
 package.loaded[modname] = M

 --[[
 ###############################################################################
 ###                          Part 2 - SETTINGS                              ###
 ###                all ??? must have sub-table inside settings              ###
 ###            with an additional comma at the end of every line            ###
 ###############################################################################
 --]]

 local settings_table = {
     {
    -- ROOT
    conkyobject=conky_parse('${fs_used_perc /}'),
    linethick=0.5,
    width=40,
    height=150,
    linered=1.0,
    linegreen=0.0,
    lineblue=0.0,
    linealpha=1.0,
    facered=0.0,
    facegreen=0.0,
    faceblue=1.0,
    facealpha=0.3,
    across=50,
    down=200,
    --text formatting
    title="Root",
    font="White Rabbit",
    fontsize=14,
    txtred=0.5,
    txtgreen=1.0,
    txtblue=0.0,
    txtalpha=1.0,
    txtacross=50,
    txtdown=220,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l"
    direction="r",

    -- HOME
    conkyobject=conky_parse('${fs_used_perc /home}'),
    linethick=3.0,
    width=40,
    height=150,
    linered=1.0,
    linegreen=1.0,
    lineblue=1.0,
    linealpha=1.0,
    facered=0,
    facegreen=0,
    faceblue=1,
    facealpha=1.0,
    across=120,
    down=200,
    --text formatting
    title="Home",
    font="White Rabbit",
    fontsize=14,
    txtred=1.0,
    txtgreen=0.1,
    txtblue=0.1,
    txtalpha=0.5,
    txtacross=120,
    txtdown=220,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l"
    direction="r",

    -- MEDIA/5
    conkyobject=conky_parse('${fs_used_perc /media/5}'),
    linethick=0.25,
    width=40,
    height=150,
    linered=1.0,
    linegreen=1.0,
    lineblue=1.0,
    linealpha=0.5,
    facered=0.5,
    facegreen=0.5,
    faceblue=0.5,
    facealpha=1.0,
    across=190,
    down=200,
    --text formatting
    title="M/5",
    font="White Rabbit",
    fontsize=14,
    txtred=1,
    txtgreen=1,
    txtblue=0,
    txtalpha=1,
    txtacross=190,
    txtdown=220,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l"
    direction="l",

    -- MEMORY
    conkyobject=conky_parse('${memperc}'),
    linethick=0.5,
    width=40,
    height=150,
    linered=0.1,
    linegreen=0.1,
    lineblue=0.1,
    linealpha=0,
    facered=0.9,
    facegreen=0.5,
    faceblue=0.0,
    facealpha=1.0,
    across=260,
    down=200,
    --text formatting
    title="Memory",
    font="White Rabbit",
    fontsize=14,
    txtred=1,
    txtgreen=1,
    txtblue=0,
    txtalpha=1,
    txtacross=250,
    txtdown=220,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l",
    direction="l",

    -- CPU O (Average of all)
    conkyobject=conky_parse('${cpu cpu0}'),
    linethick=0.5,
    width=40,
    height=150,
    linered=0.1,
    linegreen=0.1,
    lineblue=0.1,
    linealpha=1,
    facered=0.0,
    facegreen=0.0,
    faceblue=0.0,
    facealpha=1.0,
    across=50,
    down=400,
    --text formatting
    title="CPU 0",
    font="White Rabbit",
    fontsize=14,
    txtred=1,
    txtgreen=1,
    txtblue=0,
    txtalpha=1,
    txtacross=30,
    txtdown=420,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l",
    direction="r",

    -- CPU 1
    conkyobject=conky_parse('${cpu cpu1}'),
    linethick=0.5,
    width=40,
    height=150,
    linered=0.1,
    linegreen=0.1,
    lineblue=0.1,
    linealpha=1,
    facered=1.0,
    facegreen=0.0,
    faceblue=0.0,
    facealpha=1.0,
    across=120,
    down=400,
    --text formatting
    title="CPU1",
    font="White Rabbit",
    fontsize=14,
    txtred=1,
    txtgreen=1,
    txtblue=0,
    txtalpha=1,
    txtacross=120,
    txtdown=420,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l"
    direction="r",

    -- CPU 2
    conkyobject=conky_parse('${cpu cpu2}'),
    linethick=0.5,
    width=40,
    height=150,
    linered=0.1,
    linegreen=0.1,
    lineblue=0.1,
    linealpha=1,
    facered=1.0,
    facegreen=0.0,
    faceblue=0.0,
    facealpha=1.0,
    across=190,
    down=400,
    --text formatting
    title="CPU2",
    font="White Rabbit",
    fontsize=14,
    txtred=1,
    txtgreen=1,
    txtblue=0,
    txtalpha=1,
    txtacross=190,
    txtdown=420,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l",
    direction="l",

    -- CPU 3
    conkyobject=conky_parse('${cpu cpu3}'),
    linethick=0.5,
    width=40,
    height=150,
    linered=0.1,
    linegreen=0.1,
    lineblue=0.1,
    linealpha=1.0,
    facered=1.0,
    facegreen=0.0,
    faceblue=0.0,
    facealpha=1.0,
    across=260,
    down=400,
    --text formatting
    title="CPU3",
    font="White Rabbit",
    fontsize=14,
    txtred=1,
    txtgreen=1,
    txtblue=0,
    txtalpha=1,
    txtacross=260,
    txtdown=420,
    --1 for framelines, 0 for none
    framelines=1,
    --face direction "r" or "l"
    direction="l",

      },
 }

 --[[
 ###############################################################################
 ###                           END OF SETTINGS                               ###
 ###############################################################################
 ###                         Part 3 - Code Here                              ###
 ###############################################################################
 --]]

 function M.bar3d(t)
 end



 --[[
 ###############################################################################
 ###                            MODULE MAIN LOOP                             ###
 ###############################################################################
 --]]
 function M.main()
         for i in pairs(settings_table) do
             M.bar3d(settings_table[i])
         end
 end

Offline

#3331 2012-10-17 04:30:52

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

function settings()
 local settings_table = {
     {    
        -- ROOT
        conkyobject=conky_parse('${fs_used_perc /}'),
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        etc
        etc
      }
}
return settings_table
end--of settings function

Offline

#3332 2012-10-17 06:23:51

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

Last edited by mrpeachy (2012-10-17 06:28:03)

Offline

#3333 2012-10-17 11:57:25

holden
#! Member
Registered: 2012-06-23
Posts: 74

Re: Conky v1.9 Thread

Hi.

Sorry for being a pest, but what i would like is a conky config that puts only time and weather on my desktop. preferably a nice looking one, since i-m lost in all the conky configs.

Thanks guys!


'Sometimes you just have to pee in the sink' - Charles Bukowski

Offline

#3334 2012-10-17 16:10:26

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

 -- mrpeachy_bar3d.module
 --[[ the post: http://crunchbanglinux.org/forums/post/55927/#p55927
 this one was easy (or i thought it was going to be)
 http://omploader.org/tM2x0bg
 Going to be a work in progress until i set up all the variables properly... and get my titles right smile
 UPDATE- now you can change line thickness without messing it up.  Getting the lines right has made things alot less easy smile
 also you can set font, font size and title position
    -- end the post
 isometric bars by mrpeachy (2010)
 --]]
 
 local modname = ...
 local M = {}
 _G[modname] = M
 package.loaded[modname] = M
  
 

function M.bar3d(conkyobject, linethick, width, barheight, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
    --line 1 settings end
    local a_num1=tonumber(conkyobject) or 0
    local a_num=(height/100)*a_num1
    --indicator
    if direction==nil then direction="r" end
    if direction=="r" then
        isoadjust=width*-0.5
    elseif direction=="l" then
        isoadjust=width*0.5
    end
    --point 1 - bottom left
    x1,y1=0,0
    --point 2 - bottom right
    x2,y2=x1+width,y1
    --point 3 - middle left
    x3,y3=x1,-a_num
    --point 4 - middle right
    x4,y4=x2,y3
    --point 5 - iso left
    x5,y5=x1+isoadjust,y1+(width*-0.5)
    --point 6 - iso right
    x6,y6=x5+width,y5
    --point 7 - top left
    x7,y7=x5,y5-a_num
    --point 8 - top right
    x8,y8=x7+width,y7
    --##################################
    cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
    cairo_set_line_width (cr,linethick)
    if framelines == 1 then
        --back lines
        cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
        cairo_save(cr)
        cairo_translate (cr, across, down)
        cairo_move_to (cr,x5,y5)
        cairo_line_to (cr,x5,y5-height)
        cairo_line_to (cr,x6,y6-height)
        cairo_line_to (cr,x6,y6)
        cairo_close_path (cr)
        cairo_stroke (cr)
        cairo_restore (cr)
    end
    cairo_save (cr)
    cairo_translate (cr, across, down)
    --bottom
    cairo_move_to (cr,x1,y1)
    cairo_line_to (cr,x2,y2)
    cairo_line_to (cr,x6,y6)
    cairo_line_to (cr,x5,y5)
    cairo_close_path (cr)
    cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
    cairo_fill_preserve (cr)
    cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
    cairo_stroke (cr)
    --back
    cairo_move_to (cr,x7,y7)
    cairo_line_to (cr,x5,y5)
    cairo_line_to (cr,x6,y6)
    cairo_line_to (cr,x8,y8)
    cairo_close_path (cr)
    cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
    cairo_fill_preserve (cr)
    cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
    cairo_stroke (cr)
    --iso side left
    cairo_move_to (cr,x7,y7)
    cairo_line_to (cr,x3,y3)
    cairo_line_to (cr,x1,y1)
    cairo_line_to (cr,x5,y5)
    cairo_close_path (cr)
    cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
    cairo_fill_preserve (cr)
    cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
    cairo_stroke (cr)
    --iso side right
    cairo_move_to (cr,x8,y8)
    cairo_line_to (cr,x4,y4)
    cairo_line_to (cr,x2,y2)
    cairo_line_to (cr,x6,y6)
    cairo_close_path (cr)
    cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
    cairo_fill_preserve (cr)
    cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
    cairo_stroke (cr)
    --top
    cairo_move_to (cr,x3,y3)
    cairo_line_to (cr,x7,y7)
    cairo_line_to (cr,x8,y8)
    cairo_line_to (cr,x4,y4)
    cairo_close_path (cr)
    cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
    cairo_fill_preserve (cr)
    cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
    cairo_stroke (cr)
    --front
    cairo_move_to (cr,x1,y1)
    cairo_line_to (cr,x2,y2)
    cairo_line_to (cr,x4,y4)
    cairo_line_to (cr,x3,y3)
    cairo_close_path (cr)
    cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
    cairo_fill_preserve (cr)
    cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
    cairo_stroke (cr)
    cairo_restore (cr)

    if framelines == 1 then
        --frame lines
        cairo_save (cr)
        cairo_translate (cr, across, down)
        cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
        --front
        cairo_move_to (cr,x1,y1)
        cairo_line_to (cr,x1,y1-height)
        cairo_line_to (cr,x2,y2-height)
        cairo_line_to (cr,x2,y2)
        cairo_close_path (cr)
        cairo_stroke (cr)
        --top
        cairo_move_to (cr,x1,y1-height)
        cairo_line_to (cr,x5,y5-height)
        cairo_line_to (cr,x6,y6-height)
        cairo_line_to (cr,x2,y2-height)
        cairo_close_path (cr)
        cairo_stroke (cr)
        cairo_restore (cr)
    end--if framelines
    --title
    cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, fontsize);
    cairo_set_source_rgba (cr, (txtred or linered),(txtgreen or linegreen),(txtblue or lineblue),(txtalpha or linealpha));
    cairo_move_to (cr, txtacross, txtdown)
    cairo_show_text (cr, title)
    cairo_stroke (cr)
end--isometric drawing function

function M.main ()
    -- ROOT
    conkyobject=conky_parse('${fs_used_perc /}')
    linethick=0.5 --1.25  --1.5
    width=40
    height=150
    linered=0.1
    linegreen=0.1
    lineblue=0.1
    linealpha=0
    facered=0
    facegreen=0
    faceblue=1
    facealpha=1.0
    across=50
    down=200
    title="Root"
    font="White Rabbit"
    fontsize=14
    txtacross=50
    txtdown=220
    --1 for framelines, 0 for none
    framelines=1
    M.bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown)

    -- HOME
    conkyobject=conky_parse('${fs_used_perc /home}')
    linethick=0.5 --1.25  --1.5
    width=40
    height=150
    linered=0.1
    linegreen=0.1
    lineblue=0.1
    linealpha=0
    facered=0
    facegreen=0
    faceblue=1
    facealpha=1.0
    across=120
    down=200
    title="Home"
    font="White Rabbit"
    fontsize=14
    txtacross=120
    txtdown=220
    --1 for framelines, 0 for none
    framelines=1
    M.bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown)
    facered=0
    facegreen=0
    faceblue=1
    
    -- MEMORY
    conkyobject=conky_parse('${memperc}')
    linethick=0.5 --1.25  --1.5
    width=40
    height=150
    linered=0.1
    linegreen=0.1
    lineblue=0.1
    linealpha=0
    facered=0.9
    facegreen=0.5
    faceblue=0.0
    facealpha=1.0
    across=260
    down=200
    title="Memory"
    font="White Rabbit"
    fontsize=14
    txtacross=250
    txtdown=220
    --1 for framelines, 0 for none
    framelines=1
    M.bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown)

    -- CPU O (Average of all)
    conkyobject=conky_parse('${cpu cpu0}')
    linethick=0.5 --1.25  --1.5
    width=40   --ancho de barra
    height=150 --altura de barra
    linered=0.1
    linegreen=0.1
    lineblue=0.1
    linealpha=1
    facered=0.0
    facegreen=0.0
    faceblue=0.0
    facealpha=1.0
    across=50  -- barra
    down=400    -- barra
    title="CPU 0"
    font="White Rabbit"
    fontsize=14
    txtacross=30 -- texto
    txtdown=420   -- texto
    --1 for framelines, 0 for none
    framelines=1
    M.bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown)
end

Last edited by dk75 (2012-10-17 16:12:44)

Offline

#3335 2012-10-17 16:52:27

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,572

Re: Conky v1.9 Thread

background yes
use_xft yes
xftfont Droid Sans Mono:bold:pixelsize=11
xftalpha 1.0
update_interval 600
total_run_times 0

### Window
own_window yes
own_window_colour CEC5AD
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# ARGB
#own_window_argb_visual no
#own_window_argb_value 0

###
default_bar_size 240 6
double_buffer yes
minimum_size 300 6
maximum_width 300
draw_shades no
draw_outline no
draw_borders no
stippled_borders 1
draw_graph_borders yes
border_width 2
border_inner_margin 4
border_outer_margin 0

# Default colors and also border colors
default_color D6D6D6
default_shade_color FFFFFF
default_outline_color 020200

color0 000000
color1 FFFFFF
color2 FF0000 #red
color3 0000FF #blue
color4 00FF00 #green
color5 FFFF00 #yellow
color6 A020F0 #purple
color7 0ECB0E
color8 FFFF00
color9 F40E00

alignment tr
# alignment top_middle
gap_x 12
gap_y 36

if_up_strictness address
max_specials 40000
max_user_text 40000
text_buffer_size 40000
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale yes
use_spacer right
short_units yes
pad_percents 1
top_name_width 14
imlib_cache_size 512

# semi-transparent background
lua_load $HOME/conky/transbg.lua
lua_draw_hook_pre draw_bg 10 0 0 0 0 0x040404 0.66

# stuff after 'TEXT' will be formatted on screen
TEXT
${font Aller:bold:pixelsize=16}${offset 8}${time %e %b %Y}${alignr 8}${time %k:%M}${voffset 16}${font}
${alignc}${execpi 3600 $HOME/bin/accuweather.sh 97206}${voffset 8}
${goto 24}Forecast:${voffset 18}${execi 600 bash $HOME/conky/accuweather/accuw_USA_script}
${goto 24}${font conkyweather:size=22}${execi 600  sed -n '6p' $HOME/conky/accuweather/images}${font}${goto 72}${voffset -18}${execpi 1800 sed -n '1p' $HOME/conky/accuweather/days}:
${goto 72}${execpi 1800 sed -n '2p' $HOME/conky/accuweather/messages|fold -w30}
${goto 72}High: ${execpi 1800 sed -n '1p' $HOME/conky/accuweather/temperatures}F  Low: ${execpi 1800 sed -n '2p' $HOME/conky/accuweather/temperatures}F
${voffset 8}
${goto 24}${font conkyweather:size=22}${execi 600  sed -n '7p' $HOME/conky/accuweather/images}${font}${goto 72}${voffset -18}${execpi 1800 sed -n '2p' $HOME/conky/accuweather/days}:
${goto 72}${execpi 1800 sed -n '5p' $HOME/conky/accuweather/messages|fold -w30}
${goto 72}High: ${execpi 1800 sed -n '3p' $HOME/conky/accuweather/temperatures}F  Low: ${execpi 1800 sed -n '4p' $HOME/conky/accuweather/temperatures}F
${voffset 8}
${goto 24}${font conkyweather:size=22}${execi 600  sed -n '8p' $HOME/conky/accuweather/images}${font}${goto 72}${voffset -18}${execpi 1800 sed -n '3p' $HOME/conky/accuweather/days}:
${goto 72}${execpi 1800 sed -n '8p' $HOME/conky/accuweather/messages|fold -w30}
${goto 72}High: ${execpi 1800 sed -n '5p' $HOME/conky/accuweather/temperatures}F  Low: ${execpi 1800 sed -n '6p' $HOME/conky/accuweather/temperatures}F
${voffset 8}
${goto 24}${font conkyweather:size=22}${execi 600  sed -n '9p' $HOME/conky/accuweather/images}${font}${goto 72}${voffset -18}${execpi 1800 sed -n '4p' $HOME/conky/accuweather/days}:
${goto 72}${execpi 1800 sed -n '11p' $HOME/conky/accuweather/messages|fold -w30}
${goto 72}High: ${execpi 1800 sed -n '7p' $HOME/conky/accuweather/temperatures}F  Low: ${execpi 1800 sed -n '8p' $HOME/conky/accuweather/temperatures}F
${voffset 8}
${goto 24}${font conkyweather:size=22}${execi 600  sed -n '10p' $HOME/conky/accuweather/images}${font}${goto 72}${voffset -18}${execpi 1800 sed -n '5p' $HOME/conky/accuweather/days}:
${goto 72}${execpi 1800 sed -n '14p' $HOME/conky/accuweather/messages|fold -w30}
${goto 72}High: ${execpi 1800 sed -n '9p' $HOME/conky/accuweather/temperatures}F  Low: ${execpi 1800 sed -n '10p' $HOME/conky/accuweather/temperatures}F
${voffset 8}

Last edited by PackRat (2012-10-17 16:56:28)


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#3336 2012-10-17 19:27:26

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 105
Website

Re: Conky v1.9 Thread

Offline

#3337 2012-10-17 20:18:20

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

17 Oct 12 | 17:58:13 ~
         $ now
WEATHER:
     Now: Mostly Cloudy, 19C
   Today: 0-0 C                
Tomorrow: 0-0 C                
  17 Oct 12 | 17:58:16 ~
         $

Last edited by Sector11 (2012-10-17 21:07:42)

Offline

#3338 2012-10-17 20:53:30

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

#!/bin/sh
#(c) Michael Seiler 2007
# locationcode is zip code in usa
#

METRIC=0 #Should be 0 or 1; 0 for F, 1 for C

if [ -z $1 ]; then
    echo
    echo "USAGE: accuweather.sh <locationcode>"
    echo
    exit 0;
fi

curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'

Offline

#3339 2012-10-17 20:57:53

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Offline

#3340 2012-10-17 21:56:37

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

Offline

#3341 2012-10-17 22:08:07

schwim
#! Die Hard
From: Interweb's #1 Devotee
Registered: 2012-10-11
Posts: 1,031
Website

Re: Conky v1.9 Thread

Offline

#3342 2012-10-17 22:22:12

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

${goto 10}${cpugraph cpu1 20,100}\
${goto 10}${cpugraph cpu2 20,100}\
${goto 10}${cpugraph cpu3 20,100}\
${goto 10}${cpugraph cpu0 20,100}

Last edited by Sector11 (2012-10-17 22:26:40)

Offline

#3343 2012-10-17 22:37:28

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

@dk75 - we will just have to have a difference of opinion smile

the changes you have made to the script are not insignificant and have taken care of many of the points that i raised
ie using non standard conky objects and mimicking execi behavior.

however there is always going to be someone who wants to do something that the script hasn't anticipated
being able to manipulate commands and do calculations within an active function will be the best way to catch these one off situations
otherwise you have to go make changes to the working code of the script, which may be beyond the ability of the average user to do

say for example someone wants to display their network downspeed on a logarithmic scale... in the example where the setup is in a function you can simply write a few lines of code and calculations to do it, then send the output to the bar function.

Offline

#3344 2012-10-18 00:56:40

lwfitz
#! Die Hard
From: Monrovia, CA
Registered: 2012-01-19
Posts: 886
Website

Re: Conky v1.9 Thread

Offline

#3345 2012-10-18 01:43:07

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 105
Website

Re: Conky v1.9 Thread

wow, thank you all for the compliments, it's a lot of different scripts, 2 lua scripts, 2 gmail parsers, and conkyForecast, conkyTranmission, etc., so I'll make a tar archive and post it somewhere. I'm glad you all like it, it took me close to a week to make it, and it's my first time trying to write a lua script, let alone 2, so it was a work of love, (I'm a complete conky addict, have make more standard conky configs than i can count).

Edit, just the conky on the right
this is the conkyrc file for the right side

######################
# - Conky settings - #
######################
background no
update_interval .2
cpu_avg_samples .2
net_avg_samples .2
temperature_unit celsius
total_run_times 0
 
double_buffer yes
#no_buffers yes
 
text_buffer_size 10240
imlib_cache_size 10240
format_human_readable yes

minimum_size 330 1000
maximum_width 350

gap_x 25
gap_y 40
#####################
# - Text settings - #
#####################
use_xft yes
xftfont Santana:size=8
xftalpha .8
 
uppercase no

# Text alignment, other possible values are commented
#alignment middle_left
#alignment middle_middle
#alignment middle_right
#alignment top_middle
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment bottom_middle

######################
# - Color settings - #
######################
color0 c3c3c3 #mid gray
color1 FF0000 #red
color2 09FF00 #bright green
color3 007EFF #bright blue
color4 E3E3E3 #very light gray
color5 FF8600 #an orange shade
color6 CA8718 #a dust like color
color7 FFE500 #a darker yellow color
color8 C3FF00 #lime green
color9 00FCFF #sky blue
default_color c3c3c3
#############################
# - Window specifications - #
#############################
own_window yes
own_window_transparent yes
own_window_type override
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

border_inner_margin 0
border_outer_margin 0

#########################
# - Graphics settings - #
#########################
draw_shades no
draw_outline no
draw_borders no
stippled_borders 0
draw_graph_borders no
show_graph_scale yes
show_graph_range no
short_units yes

#########################################
# - Load Lua for bargraphs (required) - #
# - Set the path to your script here. - #
#########################################
lua_load ~/mcrings-1/scripts/graph.lua
lua_draw_hook_pre main_graph
lua_load ~/mcrings-1/scripts/rings.lua
lua_draw_hook_post main_rings
TEXT
${font Santana:size=10,weight:bold}${color4}SYSTEM ${hr 2}
${offset 5}${font Santana:size=10,weight:bold}${color4}Linux: ${font Santana:size=10,weight:normal}${execi 2600 cat /etc/issue.net}${alignr 4}${font Santana:size=10,weight:bold}${color4}Kernel: ${font Santana:size=10,weight:normal}${color4} $kernel
${offset 5}${font Santana:size=10,weight:bold}Hostname: ${font Santana:size=10,weight:normal}${color4}$nodename${color4}${font Santana:size=10,weight:bold}${alignr}Uptime: ${font Santana:size=10,weight:normal}${color4}$uptime
${offset 5}${font Santana:size=10,weight:bold}${color4}System Updates:${alignr}${font Santana:size=10,weight:normal}You have ${execi 600 aptitude search "~U" | wc -l | tail} updates to be installed
# Showing CPU Graph
${voffset 55}${goto 140}${font Santana:size=10,weight:bold}${color4}CPU:${font Santana:size=10}  ${execi 1000 cat /proc/cpuinfo | egrep -m 1 'model name' | sed -e 's/model name.*: //' | cut -c41-47} ${exec cat /proc/cpuinfo | egrep -m 1 'model name' | sed -e 's/model name.*: //' | cut -c1-5} ${exec cat /proc/cpuinfo | egrep -m 1 'model name' | sed -e 's/model name.*: //' | cut -c10-13}-${exec cat /proc/cpuinfo | egrep -m 1 'model name' | sed -e 's/model name.*: //' | cut -c19-20} ${exec cat /proc/cpuinfo | egrep -m 1 'model name' | sed -e 's/model name.*: //' | cut -c34-36}
# Showing TOP 5 Resource-consumers
${goto 59}${font Santana:size=11,weight:bold}${voffset -12}${cpu}${font Santana:size=10}%${goto 90}${voffset 1}${hr}
${voffset -6}${goto 90}CPU Use:${goto 160}Name:${goto 270}%Used
${goto 90}${voffset -10}${hr}
${voffset -3}${goto 130}|${goto 140}1:${goto 160}${font Santana:size=10,weight:normal}${color4}${top name 1}${goto 270}${top cpu 1}%
${goto 130}|${goto 140}2:${goto 160}${font Santana:size=10,weight:normal}${color4}${top name 2}${goto 270}${top cpu 2}%
${goto 130}|${goto 140}3:${goto 160}${font Santana:size=10,weight:normal}${color4}${top name 3}${goto 270}${top cpu 3}%
${voffset 20}${goto 60}Ram${goto 265}Volume
${goto 40}Total: ${memmax}${voffset 10}${goto 90}${hr}
${voffset -6}${goto 90}Ram Use:${goto 160}Name:${goto 270}%Used
${goto 90}${voffset -10}${hr}
${goto 50}Used: ${mem used}${voffset -3}${goto 130}|${goto 140}1:${goto 160}${font Santana:size=10,weight:normal}${color4}${top_mem name 1}${goto 270}${top_mem mem 1}%
${goto 130}|${goto 140}2:${goto 160}${font Santana:size=10,weight:normal}${color4}${top_mem name 2}${goto 270}${top_mem mem 2}%
${goto 130}|${goto 140}3:${goto 160}${font Santana:size=10,weight:normal}${color4}${top_mem name 3}${goto 270}${top_mem mem 3}%
${voffset 5}${goto 60}${color EF5A29}CPU Temp: ${execi 30 sensors | grep "Core 0" | cut -d "+" -f2 | cut -c1-4}°c       Motherboard Temp:  ${exec sensors | grep 'temp3' | cut -c15-20}c
${color EF5A29}${goto 58}HDD Temps:     SDa: ${exec hddtemp /dev/sda -n --unit=C}°c     SDb: ${exec hddtemp /dev/sdb -n --unit=C}°c     SDc: ${exec hddtemp /dev/sdc -n --unit=C}°c${color}
${goto 75}${color 2A95B4}CPU Fan: ${exec sensors | grep "fan1:" | sed 's/fan1/CPU Fan/' | cut -c16-24}${offset 20}Case Fan: ${exec sensors | grep "fan2:" | sed 's/fan2/Case Fan/' | cut -c17-26}$color
${goto 75}Root${goto 160}LShared${goto 245}Linux-Files
${voffset 30}${goto 80}${fs_size /}${goto 170}${fs_size /home/mclovin/LShared}${goto 260}${fs_size /home/mclovin/Linux-Files}
${voffset 20}${goto 112}Media${goto 205}Videos
${voffset 27}${goto 120}${fs_size /home/mclovin/Media}${goto 215}${fs_size /home/mclovin/Videos}
# Network data (my desktop have only LAN). ETHERNET ring is mostly useless but looks pretty, main info is in the graphs
# |--ETH0
${if_up eth0}
${voffset 45}${offset 60}${gw_iface}${voffset 13}${offset 10}${font Santana:size=10,weight:bold}${color4}NETWORK
${font Santana:size=10}${voffset 6}${goto 190}Router IP:${alignr}${gw_ip}
${font Santana:size=10}${voffset -3}${goto 75}-Down: ${downspeedf}${goto 190}${font Santana:size=10}Local IP:${alignr}${addr eth0}
${voffset -3}${goto 75}-Up: ${upspeedf}${goto 190}Public IP: ${alignr}${execi 300 wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'}
${voffset -5}             
${goto 25}${color4}${font Santana:size=9,weight:bold}Upload: ${goto 110}${font Santana:size=9,weight:bold}Speed: ${font Santana:size=9,weight:normal}$color4${upspeedf eth0}${goto 205}${font Santana:size=9,weight:bold}Total Uploaded:${font Santana:size=9,weight:normal} ${totalup eth0}
${voffset 50}${goto 25}${color4}${font Santana:size=9,weight:bold}Download: ${goto 110}Speed :${font Santana:size=9,weight:normal}$color4${downspeedf eth0}${goto 205}${font Santana:size=9,weight:bold}Total Downloaded:${font Santana:size=9,weight:normal} ${totaldown eth0}
# |--ETH1
${else}${if_up eth1}
${voffset -36}${offset 60}${gw_iface}${voffset 13}${offset 10}${font Santana:size=10,weight:bold}${color4}NETWORK
${voffset 12}${goto 130}${font Santana:size=10}Local IP:${alignr}${addr eth1}
${voffset 3}${goto 130}Public IP: ${alignr}${execi 300 wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'}
${voffset -5}             
${goto 25}${color4}${font Santana:size=9,weight:bold}Upload: ${goto 110}${font Santana:size=9,weight:bold}Speed: ${font Santana:size=9,weight:normal}$color4${upspeedf eth1}${goto 205}${font Santana:size=9,weight:bold}Total Uploaded:${font Santana:size=9,weight:normal} ${totalup eth1}
${offset 15}${upspeedgraph eth0 40,330 2A95B4 3BD3FF 100 -l -t}
${goto 25}${color4}${font Santana:size=9,weight:bold}Download: ${goto 110}Speed :${font Santana:size=9,weight:normal}$color4${downspeedf eth1}${goto 205}${font Santana:size=9,weight:bold}Total Downloaded:${font Santana:size=9,weight:normal} ${totaldown eth1}
${offset 15}${downspeedgraph eth1 40,330 2A95B4 3BD3FF 100 -l -t}
# |--ETH2
${else}${if_up eth2}
${voffset -36}${offset 60}${gw_iface}${voffset 13}${offset 10}${font Santana:size=10,weight:bold}${color4}NETWORK
${voffset 12}${goto 130}${font Santana:size=10}Local IP:${alignr}${addr eth2}
${voffset 3}${goto 130}Public IP: ${alignr}${execi 300 wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'}
${voffset -5}             
${goto 25}${color4}${font Santana:size=9,weight:bold}Upload: ${goto 110}${font Santana:size=9,weight:bold}Speed: ${font Santana:size=9,weight:normal}$color4${upspeedf eth2}${goto 205}${font Santana:size=9,weight:bold}Total Uploaded:${font Santana:size=9,weight:normal} ${totalup eth2}
${offset 15}${upspeedgraph eth0 40,330 2A95B4 3BD3FF 100 -l -t}
${goto 25}${color4}${font Santana:size=9,weight:bold}Download: ${goto 110}Speed :${font Santana:size=9,weight:normal}$color4${downspeedf eth2}${goto 205}${font Santana:size=9,weight:bold}Total Downloaded:${font Santana:size=9,weight:normal} ${totaldown eth2}
${offset 15}${downspeedgraph eth2 40,330 2A95B4 3BD3FF 100 -l -t}${endif}${endif}${endif}
${voffset 50}
${if_running rhythmbox}${voffset -1}   ${font Santana:size=10,weight:bold}Rhythmbox ${hr 2}$font
Status:$alignr${exec conkyRhythmbox --datatype=ST}
Artist:$alignr${scroll 70 ${exec conkyRhythmbox --datatype=AR}}
Title:$alignr${scroll 70 ${exec conkyRhythmbox --datatype=TI}}
Album:$alignr${scroll 70 ${exec conkyRhythmbox --datatype=AL}}
Position:${alignr}${exec conkyRhythmbox --datatype=PT}/${exec conkyRhythmbox --datatype=LE} - ${exec conkyRhythmbox --datatype=PP}%$font
${execibar 1 conkyRhythmbox --datatype=PP}
${else}${if_running clementine}${voffset -1}   ${font Santana:size=10,weight:bold}Clementine ${hr 2}$font
Status:$alignr${exec conkyClementine --datatype=ST}
Artist:$alignr${scroll 70 ${exec conkyClementine --datatype=AR}}
Title:$alignr${scroll 70 ${exec conkyClementine --datatype=TI}}
Album:$alignr${scroll 70 ${exec conkyClementine --datatype=AL}}
Position:${alignr}${exec conkyClementine --datatype=PT}/${exec conkyClementine --datatype=LE} - ${exec conkyClementine --datatype=PP}%$font
${execibar 1 conkyClementine --datatype=PP}
${execi 4 cp "`conkyClementine --datatype=CA | sed -e 's/\\\//g'`" ~/.album}${image ~/.album -p 60,860 -s 150x140 -n}
${else}${if_running banshee-1}${voffset -1}   ${font Santana:size=10,weight:bold}Banshee ${hr 2}$font
Status:$alignr${exec conkyBanshee --datatype=ST}
Artist:$alignr${scroll 70 ${exec conkyBanshee --datatype=AR}}
Title:$alignr${scroll 70 ${exec conkyBanshee --datatype=TI}}
Album:$alignr${scroll 70 ${exec conkyBanshee --datatype=AL}}
Position:${alignr}${exec conkyBanshee --datatype=PT}/${exec conkyBanshee --datatype=LE} - ${exec conkyBanshee --datatype=PP}%$font
${color 2A95B4}${execibar 1 conkyBanshee --datatype=PP}${color}
${execi 4 cp "`conkyBanshee --datatype=CA | sed -e 's/\\\//g'`" ~/.album}${image ~/.album -p 60,860 -s 150x140 -n}
${else}${endif}${endif}${endif}

and this is the lua graph script that goes with it

--[[ GRAPH widget
This is a modified graph widget originally built off of scripts found at the site below, modified by me (McLovin). Anyone may use, or modify this script any way, just please give credit to the original authors, (wlourf and McLovin)
    http://u-scripts.blogspot.com/2010/10/graph-widget.html
    
To call the script in a conky, use, before TEXT
    lua_load /path/to/the/script/graph.lua
    lua_draw_hook_pre main_graph
and add one line (blank or not) after TEXT


Parameters are :
3 parameters are mandatory
name        - the name of the conky variable to display,
              for example for {$cpu cpu0}, just write name="cpu"
arg            - the argument of the above variable,
              for example for {$cpu cpu1}, just write arg="cpu1"
                arg can be a numerical value if name=""
max            - the maximum value the above variable can reach,
              for example for {$cpu cpu1}, just write max=100 or less or more
    
Optional parameters:
x,y         - coordinates of the bottom-left corner of the graph,
              relative to the top-left corner of the conky window 
              default =  bottom-left corner of the conky window
width       - width of the graph, default = 100 pixels
height      - height of the graph, default = 20 pixels
nb_values   - number of values to display in the graph, default=width 
              i.e. 1 pixel for 1 value
autoscale   - if set to true, calculate the max valeu of the y axis and
              doesn't use the max parameter above, default=false
skew_x      - skew graph around x axis, défaut = 0
skew_y      - skew graph around y axis, défaut = 0
angle        - angle of rotation of the graph in degress, default = 0
              i.e. a horizontal graph)
inverse     - if set to true, graph are draw from right to left, default=false
background  - if set to false, background is not drawn, default=true
foreground  - if set to false, foreground is not drawn, default=true
              foreground = plain graph
bg_bd_size  - size of the border of the background, default=0=no border
fg_bd_size  - size of the border of the foreground, default=0=no border


Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table : 
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table : 
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table : 
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}

bg_colour    - colour table for background,
              default = {{0,0x000000,.5},{1,0xFFFFFF,.5}}
fg_colour    - colour table for foreground,
              default = {{0,0x00FFFF,1},{1,0x0000FF,1}}
bg_bd_colour- colour table for background border,
              default = {{1,0xFFFFFF,1}}              
fg_bd_colour- colour table for foreground border,
              default = {{1,0xFFFF00,1}}              

bg_orientation, bg_bd_orientation, fg_orientation, fg_bd_orientation,
            - "orientation" defines the starting point of the gradient,
              default="nn"
              there are 8 available starting points : 
              "nw","nn","ne","ee","se","ss","sw","ww"
              (n for north, w for west ...)
              theses 8 points are the 4 corners + the 4 middles of graph
              so a gradient "nn" will go from "nn" to "ss"
              a gradient "nw" will go from "nw" to "se"

draw_me     - if set to false, graph is not drawn (default = true)
              it can be used with a conky string, if the string returns 1, the graph is drawn :
              example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
              
                  text is parsed inside the function, not in the array of settings
v1.0 © McLovin Oct. 15, 2012
--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation version 3 (GPLv3)
--     
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--     
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
--      MA 02110-1301, USA.        

]]

require 'cairo'

function set_settings()
    graph_settings={
        { --quad graph
        name="cpu",
        arg="cpu1",
        max=100,
        x=140,
        y=135,
        autoscale=true,
        width=220,
        height=75,
        nb_values=100,
        fg_bd_size=0.5,
        --bg_colour = {{0,0x007AF6,0.5},{1,0xFFFFFF,0.5}},
        fg_bd_colour = { {0,0xFFA209,1},{0.5,0xFFA209,1},{1,0xFFA209,1}},
        foreground=false
        },
        {
        name="cpu",
        arg="cpu2",
        max=100,
        x=140,
        y=135,
        autoscale=true,
        width=220,
        height=75,
        nb_values=100,
        fg_bd_size=0.5,
        --bg_bd_size=2,
        --bg_bd_colour = { {0,0x0000ff,1},{1,0xfffff,1}},
        fg_bd_colour = { {0,0xF6000F,1},{0.5,0xF6000F,1},{1,0xF6000F,1}},
        foreground=false,
        background=false,
        },
        {
        name="cpu",
        arg="cpu3",
        max=100,
        x=140,
        y=135,
        autoscale=true,
        width=220,
        height=75,
        nb_values=100,
        fg_bd_size=0.5,
        --bg_bd_size=2,
        --bg_bd_colour = { {0,0x0000ff,1},{1,0xfffff,1}},
        fg_bd_colour = { {0,0x00F615,1},{0.5,0x00F615,1},{1,0x00F615,1}},
        foreground=false,
        background=false,
        },        {
        name="cpu",
        arg="cpu4",
        max=100,
        x=140,
        y=135,
        autoscale=true,
        width=220,
        height=75,
        nb_values=100,
        fg_bd_size=0.5,
        --bg_bd_size=2,
        --bg_bd_colour = { {0,0x0000ff,1},{1,0xfffff,1}},
        fg_bd_colour = { {0,0x2A95B4,1},{0.5,0x2A95B4,1},{1,0x2A95B4,1}},
        foreground=false,
        background=false,
        },

        --ethernet graphs
            {
        name="upspeedf",
        arg="eth0",
        max=60,
            x=10,
        y=670,
        autoscale=true,
        width=330,
        height=40,
        --bg_colour = {{0,0x30EC17,0.5},{1,0xFFFFFF,0.5}},
        fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0x2A95B4,1}},
        },
        {
        name="downspeedf",
        arg="eth0",
        max=60,
            x=10,
        y=750,
        autoscale=true,
        width=330,
        height=40,
        --bg_colour = {{0,0x30EC17,0.5},{1,0xFFFFFF,0.5}},
        fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0x2A95B4,1}},
        },                                                                            }
end


function check_settings(t)
    --tables are check only when conky start
    if t.name==nil and t.arg==nil then 
        print ("No input values ... use parameters 'name'" .. 
            " with 'arg' or only parameter 'arg' ") 
        return 1
    end

    if t.max==nil then
        print ("No maximum value defined, use 'max'")
        print ("for name=" .. t.name .. " with arg=" .. t.arg)
        return 1
    end
    if t.name==nil then t.name="" end
    if t.arg==nil then t.arg="" end
    return 0
end

function conky_main_graph()

    if conky_window == nil then return end
        
    local w=conky_window.width
    local h=conky_window.height
    local cs=cairo_xlib_surface_create(conky_window.display, 
            conky_window.drawable, conky_window.visual, w, h)
    cr=cairo_create(cs)

    updates=tonumber(conky_parse('${updates}'))
    --start drawing after "updates_gap" updates
    --prevent segmentation error for cpu
    updates_gap=5
    if updates==1 then    
        set_settings()
        
        flagOK=0
        for i in pairs(graph_settings) do
            if graph_settings[i].width==nil then graph_settings[i].width=100 end
            if graph_settings[i].nb_values==nil then  
                graph_settings[i].nb_values= graph_settings[i].width
            end
            --create an empty table to store values
            graph_settings[i]["values"]={}
            --beginning point
            graph_settings[i].beg = graph_settings[i].nb_values
            --graph_settings[i].beg = 0
            for j =1, graph_settings[i].nb_values do
                graph_settings[i].values[j]=0
            end
            graph_settings[i].flag_init=true
            flagOK=flagOK + check_settings(graph_settings[i])

        end
    end

    if flagOK>0 then 
        --abort script if error in one of the tables
        print ("ERROR : Check the graph_setting table")
        return
    end

    --drawing process
    if updates > updates_gap then
        for i in pairs(graph_settings) do
            if graph_settings[i].draw_me==true then graph_settings[i].draw_me = nil end
            if (graph_settings[i].draw_me==nil or conky_parse(tostring(graph_settings[i].draw_me)) == "1") then 
                local nb_values=graph_settings[i].nb_values
                graph_settings[i].automax=0
                for j =1, nb_values do
                    if graph_settings[i].values[j+1]==nil then 
                        graph_settings[i].values[j+1]=0 
                    end
                
                    graph_settings[i].values[j]=graph_settings[i].values[j+1]
                    if j==nb_values then
                        --store value
                        if graph_settings[i].name=="" then
                            value=graph_settings[i].arg
                        else
                            value=tonumber(conky_parse('${' .. 
                                graph_settings[i].name .. " " ..
                                graph_settings[i].arg ..'}'))
                        end
                        graph_settings[i].values[nb_values]=value
                    end
                    graph_settings[i].automax=math.max(graph_settings[i].automax,
                                                       graph_settings[i].values[j])
                    --should stop weird glitches at beginning when no values reported yet for upspeed or diskio
                    if graph_settings[i].automax == 0 then graph_settings[i].automax = 1 end 
                end
                   draw_graph(graph_settings[i])
            end
        end
    end

    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    updates=nil
    updates_gap=nil
end


function draw_graph(t)
    --drawing function

    local function rgb_to_r_g_b(colour)
        return ((colour[2] / 0x10000) % 0x100) / 255., ((colour[2] / 0x100) % 0x100) / 255., (colour[2] % 0x100) / 255., colour[3]
    end
 
    local function linear_orientation(o,w,h)
        --set gradient for bg and bg border
        local p
        if o=="nn" then
            p={w/2,h,w/2,0}
        elseif o=="ne" then
            p={w,h,0,0}
        elseif o=="ww" then
            p={0,h/2,w,h/2}
        elseif o=="se" then
            p={w,0,0,h}
        elseif o=="ss" then
            p={w/2,0,w/2,h}
        elseif o=="ee" then
            p={w,h/2,0,h/2}        
        elseif o=="sw" then
            p={0,0,w,h}
        elseif o=="nw" then
            p={0,h,w,0}
        end
        return p
    end

    local function linear_orientation_inv(o,w,h)
        --set gradient for fg and fg border
        local p
        if o=="ss" then
            p={w/2,h,w/2,0}
        elseif o=="sw" then
            p={w,h,0,0}
        elseif o=="ee" then
            p={0,h/2,w,h/2}
        elseif o=="nw" then
            p={w,0,0,h}
        elseif o=="nn" then
            p={w/2,0,w/2,h}
        elseif o=="ww" then
            p={w,h/2,0,h/2}        
        elseif o=="ne" then
            p={0,0,w,h}
        elseif o=="se" then
            p={0,h,w,0}
        end
        return p
    end


    --set default values
    
    --cancel drawing if not needed
    if t.draw_me~=nil and conky_parse(tostring(t.draw_me)) ~= "1" then 
        return
    end
    

    
    if t.height==nil    then t.height=20 end
    --checked in previous part : width and nb_values
        
    if t.background==nil    then t.background=true end
    if t.bg_bd_size==nil    then t.bg_bd_size=0 end
    if t.x==nil             then t.x=t.bg_bd_size end
    if t.y==nil             then t.y=conky_window.height -t.bg_bd_size end
    if t.bg_colour==nil     then t.bg_colour={{0,0x000000,.0},{1,0xFFFFFF,.0}} end
    if t.bg_bd_colour==nil     then t.bg_bd_colour={{1,0xFFFFFF,0}} end
    
    if t.foreground==nil    then t.foreground=true end
    if t.fg_colour==nil     then t.fg_colour={{0,0x00FFFF,1},{1,0x0000FF,1}} end
    
    if t.fg_bd_size==nil    then t.fg_bd_size=0 end    
    if t.fg_bd_colour==nil  then t.fg_bd_colour={{1,0xFFFF00,1}} end
    
    if t.autoscale==nil     then t.autoscale=false end
    if t.inverse==nil       then t.inverse=false end
    if t.angle==nil         then t.angle=0 end
    
    if t.bg_bd_orientation==nil then t.bg_bd_orientation="nn" end
    if t.bg_orientation==nil then t.bg_orientation="nn" end
    if t.fg_bd_orientation==nil then t.fg_bd_orientation="nn" end
    if t.fg_orientation==nil then t.fg_orientation="nn" end

    --check colours tables
    for i=1, #t.fg_colour do    
        if #t.fg_colour[i]~=3 then 
            print ("error in fg_colour table")
            t.fg_colour[i]={1,0x0000FF,1} 
        end
    end
    
    for i=1, #t.fg_bd_colour do    
        if #t.fg_bd_colour[i]~=3 then 
            print ("error in fg_bd_colour table")
            t.fg_bd_colour[i]={1,0x00FF00,1} 
        end
    end
    
    for i=1, #t.bg_colour do    
        if #t.bg_colour[i]~=3 then 
            print ("error in background color table")
            t.bg_colour[i]={1,0xFFFFFF,0.0} 
        end
    end    

    for i=1, #t.bg_bd_colour do    
        if #t.bg_bd_colour[i]~=3 then 
            print ("error in background border color table")
            t.bg_bd_colour[i]={1,0xFFFFFF,0} 
        end
    end    

    --calculate skew parameters if needed
    if t.flag_init then
        if t.skew_x == nil then 
            t.skew_x=0 
        else
            t.skew_x = math.pi*t.skew_x/180    
        end
        if t.skew_y == nil then 
            t.skew_y=0
        else
            t.skew_y = math.pi*t.skew_y/180    
        end
        t.flag_init=false
    end

    cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
    cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND)

    local matrix0 = cairo_matrix_t:create()
    tolua.takeownership(matrix0)
    cairo_save(cr)
    cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
    cairo_transform(cr,matrix0)
    
       local ratio=t.width/t.nb_values

    cairo_translate(cr,t.x,t.y)
    cairo_rotate(cr,t.angle*math.pi/180)
    cairo_scale(cr,1,-1)

    --background
    if t.background then
        local pts=linear_orientation(t.bg_orientation,t.width,t.height)
        local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
        for i=1, #t.bg_colour do
            --print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
            cairo_pattern_add_color_stop_rgba (pat, t.bg_colour[i][1], rgb_to_r_g_b(t.bg_colour[i]))
        end
        cairo_set_source (cr, pat)
        cairo_rectangle(cr,0,0,t.width,t.height)    
        cairo_fill(cr)    
        cairo_pattern_destroy(pat)
    end
    
    --autoscale
    cairo_save(cr)
    if t.autoscale then
        t.max= t.automax*1.1
    end
    
    local scale_x = t.width/(t.nb_values-1)
    local scale_y = t.height/t.max
    
    --define first point of the graph
    if updates-updates_gap <t.nb_values then 
        t.beg = t.beg - 1
        --next line prevent segmentation error when conky window is redraw 
        --quicly when another window "fly" over it
        if t.beg<0 then t.beg=0 end
    else
        t.beg=0
    end
    if t.inverse then cairo_scale(cr,-1,1)
    cairo_translate(cr,-t.width,0) end

    --graph foreground
    if t.foreground then
        local pts_fg=linear_orientation_inv(t.fg_orientation,t.width,t.height)
        local pat = cairo_pattern_create_linear (pts_fg[1],pts_fg[2],pts_fg[3],pts_fg[4])
        for i=1,#t.fg_colour,1 do
            cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_colour[i][1], rgb_to_r_g_b(t.fg_colour[i]))
        end
        cairo_set_source (cr, pat)

        cairo_move_to(cr,t.beg*scale_x,0)
        cairo_line_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
        for i=t.beg, t.nb_values-1 do
            cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)        
        end
        cairo_line_to(cr,(t.nb_values-1)*scale_x,0)
        cairo_close_path(cr)
        cairo_fill(cr)
        cairo_pattern_destroy(pat)
    end

    --graph_border
    if t.fg_bd_size>0 then
        local pts=linear_orientation_inv(t.fg_bd_orientation,t.width,t.height)
        local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
        for i=1,#t.fg_bd_colour,1 do
            cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_bd_colour[i][1], rgb_to_r_g_b(t.fg_bd_colour[i]))
        end
        cairo_set_source (cr, pat)
        cairo_move_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
        for i=t.beg, t.nb_values-1 do
            cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)        
        end
        cairo_set_line_width(cr,t.fg_bd_size)
        cairo_stroke(cr)
        cairo_pattern_destroy(pat)
    end
    cairo_restore(cr)

    --background border
    if t.bg_bd_size>0 then
        local pts=linear_orientation(t.bg_bd_orientation,t.width,t.height)
        local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
        for i=1, #t.bg_bd_colour do
            --print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
            cairo_pattern_add_color_stop_rgba (pat, t.bg_bd_colour[i][1], rgb_to_r_g_b(t.bg_bd_colour[i]))
        end
        cairo_set_source (cr, pat)
        cairo_rectangle(cr,0,0,t.width,t.height)    
        cairo_set_line_width(cr,t.bg_bd_size)
        cairo_stroke(cr)
        cairo_pattern_destroy(pat)    
    end    

    cairo_restore(cr)

end

and this is the lus rings code for it

--[[ RINGS with SECTORS widget
This is a modified sector rings widget originally built off of scripts found at the site below, modified by me (McLovin). Anyone may use, or modify script any way, just please give credit to the original authors, (wlourf and McLovin)
    http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
    
To call the script in a conky, use, before TEXT
    lua_load /path/to/the/script/rings.lua
    lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT


Parameters are :
3 parameters are mandatory
name        - the name of the conky variable to display,
              for example for {$cpu cpu0}, just write name="cpu"
arg            - the argument of the above variable,
              for example for {$cpu cpu0}, just write arg="cpu0"
                arg can be a numerical value if name=""
max            - the maximum value the above variable can reach,
              for example for {$cpu cpu0}, just write max=100
    
Optional parameters:
xc,yc        - coordinates of the center of the ring,
              default = middle of the conky window
radius        - external radius of the ring, in pixels,
              default = quarter of the width of the conky window
thickness    - thickness of the ring, in pixels, default = 10 pixels
start_angle    - starting angle of the ring, in degrees, value can be negative,
              default = 0 degree
end_angle    - ending angle of the ring, in degrees,
              value must be greater than start_angle, default = 360 degrees
sectors        - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap            - the way to close a sector, available values are
                "p" for parallel , default value 
                "r" for radial (follow the radius)
inverse_arc    - if set to true, arc will be anticlockwise, default=false
border_size    - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector    - if set to true, each sector will be completely filled,
              default=false, this parameter is inoperate if sectors=1
background    - if set to false, background will not be drawn, default=true
foreground    - if set to false, foreground will not be drawn, default=true

Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table : 
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table : 
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table : 
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}

bg_colour1    - colour table for background,
              default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1    - colour table for foreground,
              default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1    - colour table for border,
              default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}              

Seconds tables for radials gradients :
bg_colour2    - second colour table for background, default = no second colour
fg_colour2    - second colour table for foreground, default = no second colour
bd_colour2    - second colour table for border, default = no second colour

v1.0 © McLovin Oct. 15, 2012
--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation version 3 (GPLv3)
--     
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--     
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
--      MA 02110-1301, USA.    
]]


require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={

    {
    name="cpu",
    arg="cpu4",
    max=100,
    xc=70,
    yc=127,
    radius=60,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=70,
    xtp=72,
    ytp=187, 
    caption='% Core 4',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
    {
    name="cpu",
    arg="cpu3",
    max=100,
    xc=70,
    yc=127,
    radius=50,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=60,
    xtp=72,
    ytp=177, 
    caption='% Core 3',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
    {
    name="cpu",
    arg="cpu2",
    max=100,
    xc=70,
    yc=127,
    radius=40,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=50,
    xtp=72,
    ytp=167, 
    caption='% Core 2',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
    {
    name="cpu",
    arg="cpu1",
    max=100,
    xc=70,
    yc=127,
    radius=30,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=40,
    xtp=72,
    ytp=157, 
    caption='% Core 1',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
    
    {
    name="memperc",
    arg="",
    max=100,
    xc=70,
    yc=240,
    radius=50,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=40,
    xtp=72,
    ytp=290, 
    caption='%',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
        {
    name="loadavg",
    arg="1",
    max=5,
    xc=180,
    yc=240,
    radius=50,
    thickness=8,
    start_angle=-90,
    end_angle=90,
    sectors=40,
    xtp=158,
    ytp=235, 
    caption=' - Load',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0XFF0000,0},{0.5,0xFF0000,1}, {1,0xFF0000,0}},
    },
        {
    name="loadavg",
    arg="2",
    max=5,
    xc=180,
    yc=240,
    radius=42,
    thickness=8,
    start_angle=-90,
    end_angle=90,
    sectors=30,
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0XFF0000,0},{0.5,0xFF0000,1}, {1,0xFF0000,0}},
    },
        {
    name="loadavg",
    arg="3",
    max=5,
    xc=180,
    yc=240,
    radius=34,
    thickness=8,
    start_angle=-90,
    end_angle=90,
    sectors=20,
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0XFF0000,0},{0.5,0xFF0000,1}, {1,0xFF0000,0}},
    },
    {
    name="",
    arg=conky_parse("${mixer}"),
    max=100,
    xc=285,
    yc=240,
    radius=50,
    thickness=8,
    start_angle=-90,
    end_angle=90,
    sectors=40,
    xtp=280,
    ytp=235, 
    caption='',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0XFF0000,0},{0.5,0xFF0000,1}, {1,0xFF0000,0}},
    },

    {
    name="fs_used_perc",
    arg="/",
    max=100,
    xc=90,
    yc=390,
    radius=30,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=30,
    xtp=92,
    ytp=422, 
    caption='% used',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
        {
    name="fs_free_perc",
    arg="/",
    max=100,
    xc=90,
    yc=390,
    radius=22,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=20,
    xtp=92,
    ytp=412, 
    caption='% free',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    },
    
    {
    name="fs_used_perc",
    arg="/home/mclovin/LShared",
    max=100,
    xc=180,
    yc=390,
    radius=30,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=30,
    xtp=182,
    ytp=422, 
    caption='% used',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
        {
    name="fs_free_perc",
    arg="/home/mclovin/LShared",
    max=100,
    xc=180,
    yc=390,
    radius=22,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=20,
    xtp=182,
    ytp=412, 
    caption='% free',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    },

        {
    name="fs_used_perc",
    arg="/home/mclovin/Linux-Files",
    max=100,
    xc=270,
    yc=390,
    radius=30,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=30,
    xtp=272,
    ytp=422, 
    caption='% used',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
        {
    name="fs_free_perc",
    arg="/home/mclovin/Linux-Files",
    max=100,
    xc=270,
    yc=390,
    radius=22,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=20,
    xtp=272,
    ytp=412, 
    caption='% free',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    },
    
        {
    name="fs_used_perc",
    arg="/home/mclovin/Media",
    max=100,
    xc=130,
    yc=465,
    radius=30,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=30,
    xtp=132,
    ytp=497, 
    caption='% used',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
        {
    name="fs_free_perc",
    arg="/home/mclovin/Media",
    max=100,
    xc=130,
    yc=465,
    radius=22,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=20,
    xtp=132,
    ytp=487, 
    caption='% free',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    },
        {
    name="fs_used_perc",
    arg="/home/mclovin/Videos",
    max=100,
    xc=225,
    yc=465,
    radius=30,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=30,
    xtp=227,
    ytp=497, 
    caption='% used',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0.75}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
        {
    name="fs_free_perc",
    arg="/home/mclovin/Videos",
    max=100,
    xc=225,
    yc=465,
    radius=22,
    thickness=7,
    start_angle=-180,
    end_angle=90,
    sectors=20,
    xtp=227,
    ytp=487, 
    caption='% free',
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    },
    {
    name="downspeedf",
    arg="eth0",
    max=300,
    xc=70,
    yc=550,
    radius=44,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=40,
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
    {
    name="upspeedf",
    arg="eth0",
    max=300,
    xc=70,
    yc=550,
    radius=54,
    thickness=8,
    start_angle=-180,
    end_angle=90,
    sectors=50,
    bg_colour1={{0,0xFFFFFF,0},{0.5,0xFFFFFF,0.3}, {1,0xFFFFFF,0}},
    fg_colour1={{0,0X2A95B4,0},{0.5,0x2A95B4,1}, {1,0x2A95B4,0}},
    fg_colour2={{0,0X2A95B4,0},{0.5,0xFF0000,1}, {1,0x2A95B4,0}},
    },
    
            
}
--END OF PARAMETERS HERE
--main function
function draw_ring(cr, t)
    local function rgba_to_r_g_b_a(tcolour)
        local colour,alpha=tcolour[2],tcolour[3]
        return ((colour / 0x10000) % 0x100) / 255., 
            ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
    end
            
    local function calc_delta(tcol1,tcol2)

      --calculate deltas P R G B A to table_colour 1
        for x = 1, #tcol1 do
            tcol1[x].dA    = 0
            tcol1[x].dP = 0
             tcol1[x].dR = 0
            tcol1[x].dG = 0
            tcol1[x].dB = 0
            if tcol2~=nil and #tcol1 == #tcol2 then
                local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
                local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
                tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
                 tcol1[x].dR = (r2-r1)/t.sectors
                tcol1[x].dG = (g2-g1)/t.sectors
                tcol1[x].dB = (b2-b1)/t.sectors
                tcol1[x].dA = (a2-a1)/t.sectors                        
            end
        end        
        return tcol1
    end

    --check values
    
    local function setup(t)
        if t.name==nil and t.arg==nil then 
            print ("No input values ... use parameters 'name'" +
                " with 'arg' or only parameter 'arg' ") 
            return    
        end
        if t.max==nil then
            print ("No maximum value defined, use 'max'")
            print ("for name=" .. t.name)
            print ("with arg=" .. t.arg)
            return
        end
        if t.name==nil then t.name="" end
        if t.arg==nil then t.arg="" end

        if t.xc==nil then t.xc=conky_window.width/2 end
        if t.yc==nil then t.yc=conky_window.height/2 end
        if t.caption == nil then t.caption ='' end
        if t.thickness ==nil then t.thickness = 10 end
        if t.radius ==nil then t.radius =conky_window.width/4 end
        if t.start_angle==nil then t.start_angle =0 end
        if t.end_angle==nil then t.end_angle=360 end
        if t.bg_colour1==nil then 
            t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
        end
        if t.fg_colour1==nil then
            t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
        end
        if t.bd_colour1==nil then
            t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
        end
        if t.sectors==nil then t.sectors=10 end
        if t.gap_sectors==nil then t.gap_sectors=1 end 
        if t.fill_sector==nil then t.fill_sector=false end
        if t.sectors==1 then t.fill_sector=false end
        if t.border_size==nil then t.border_size=0 end
        if t.cap==nil then t.cap="p" end
        --some checks
        if t.thickness>t.radius then t.thickness=t.radius*0.1 end
        t.int_radius = t.radius-t.thickness

        --check colors tables 
        for i=1, #t.bg_colour1 do 
            if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
        end
        for i=1, #t.fg_colour1 do 
            if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
        end
        for i=1, #t.bd_colour1 do 
            if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
        end
    
        if t.bg_colour2~=nil then
            for i=1, #t.bg_colour2 do 
                if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
            end
        end
        if t.fg_colour2~=nil then
            for i=1, #t.fg_colour2 do 
                if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
            end
        end
        if t.bd_colour2~=nil then
            for i=1, #t.bd_colour2 do 
                if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
            end
        end     
        
        if t.start_angle>=t.end_angle then
         local tmp_angle=t.end_angle
         t.end_angle= t.start_angle
         t.start_angle = tmp_angle
         -- print ("inversed angles")
            if t.end_angle-t.start_angle>360 and t.start_angle>0 then
                t.end_angle=360+t.start_angle
                print ("reduce angles")
            end
        
            if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
                t.end_angle=360+t.start_angle
                print ("reduce angles")
            end
        
            if t.int_radius<0 then t.int_radius =0 end
            if t.int_radius>t.radius then
                local tmp_radius=t.radius
                t.radius=t.int_radius
                t.int_radius=tmp_radius
                print ("inversed radius")
            end
            if t.int_radius==t.radius then
                t.int_radius=0
                print ("int radius set to 0")
            end 
        end
        
        t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
        t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
        t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
    end
    
    if t.draw_me == true then t.draw_me = nil end
    if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end    
    --initialize table
    setup(t)
    

    --initialize cairo context
    cairo_save(cr)
    
    --get value
    local value = 0
    if t.name ~="" then
        value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
    else
        value = tonumber(t.arg)
    end
    if value==nil then value =0 end

if t.xtp ~=nil then 
cairo_select_font_face (cr, "Santana", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr,9)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_move_to (cr,t.xtp,t.ytp)
cairo_show_text (cr,value)cairo_show_text (cr,t.caption)
cairo_stroke (cr)    
end
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)

    --initialize sectors
    --angle of a sector :
    local angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
    --value of a sector : 
    local valueA = t.max/t.sectors
    --first angle of a sector : 
    local lastAngle = t.start_angle*math.pi/180


    local function draw_sector(type_arc,angle0,angle,valpc, idx)
     
        --this function draws a portion of arc
         --type of arc, angle0 = strating angle, angle= angle of sector,
         --valpc = percentage inside the sector, idx = sctor number #
         local tcolor
         if type_arc=="bg" then         --background
             if valpc==1 then return end
             tcolor=t.bg_colour1
         elseif type_arc=="fg" then    --foreground
             if valpc==0 then return end
             tcolor=t.fg_colour1
         elseif type_arc=="bd" then    --border
             tcolor=t.bd_colour1
         end 

        --angles equivalents to gap_sector
        local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
        local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))

        --angles of arcs
        local ext_angle=(angle-ext_delta*2)*valpc
        local int_angle=(angle-int_delta*2)*valpc

        --define colours to use for this sector
        if #tcolor==1 then 
            --plain color
            local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
            cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
                                    vG+tcolor[1].dG*idx,
                                    vB+tcolor[1].dB*idx,
                                    vA+tcolor[1].dA*idx    )
        else
            --radient color
            local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
            for i=1, #tcolor do
                local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
                cairo_pattern_add_color_stop_rgba (pat, 
                                    vP+tcolor[i].dP*idx,
                                    vR+tcolor[i].dR*idx,
                                    vG+tcolor[i].dG*idx,
                                    vB+tcolor[i].dB*idx,
                                    vA+tcolor[i].dA*idx    )
            end
            cairo_set_source (cr, pat)
            cairo_pattern_destroy(pat)
        end

        --start drawing
         cairo_save(cr)
        --x axis is parrallel to start of sector
        cairo_rotate(cr,angle0-math.pi/2)

        local ri,re = t.int_radius ,t.radius

        --point A 
        local angle_a
    
        if t.cap == "p" then 
            angle_a = int_delta
            if t.inverse_arc and type_arc ~="bg" then
                angle_a = angle-int_angle-int_delta
            end
            if not(t.inverse_arc) and type_arc =="bg" then
                angle_a = int_delta+int_angle
            end
        else --t.cap=="r"
            angle_a = ext_delta
            if t.inverse_arc and type_arc~="bg" then
                angle_a = angle-ext_angle-ext_delta
            end
            if not(t.inverse_arc) and type_arc=="bg" then
                angle_a = ext_delta+ext_angle
            end
        end
        local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)


        --point B
        local angle_b = ext_delta
        if t.cap == "p" then 
            if t.inverse_arc and type_arc ~="bg" then
                angle_b = angle-ext_angle-ext_delta
            end
            if not(t.inverse_arc) and type_arc=="bg" then
                angle_b = ext_delta+ext_angle
            end
        else
            if t.inverse_arc and type_arc ~="bg" then
                angle_b = angle-ext_angle-ext_delta
            end
            if not(t.inverse_arc) and type_arc=="bg" then
                angle_b = ext_delta+ext_angle
            end
        end
        local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)

        -- EXTERNAL ARC B --> C
        local b0,b1
        if t.inverse_arc then
            if type_arc=="bg" then
                b0,b1= ext_delta, angle-ext_delta-ext_angle
            else
                b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
            end
        else
            if type_arc=="bg" then
                b0,b1= ext_delta+ext_angle, angle-ext_delta
            else
                b0,b1= ext_delta, ext_angle+ext_delta
            end
        end
        
        ---POINT D
        local angle_c, angle_d
        if t.cap == "p" then 
            angle_d = angle-int_delta
            if t.inverse_arc and type_arc=="bg" then
                angle_d = angle-int_delta-int_angle    
            end
            if not(t.inverse_arc) and type_arc~="bg" then
                angle_d=int_delta+int_angle
            end
        else
            angle_d = angle-ext_delta
            if t.inverse_arc and type_arc=="bg" then
                angle_d =angle-ext_delta-ext_angle
            end
            if not(t.inverse_arc) and type_arc~="bg" then
                angle_d = ext_angle+ext_delta
            end
        end
        local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
        
        -- INTERNAL ARC D --> A
        local d0,d1
        if t.cap=="p" then    
            if t.inverse_arc then    
                if type_arc=="bg" then
                    d0,d1= angle-int_delta-int_angle,int_delta
                else
                    d0,d1= angle-int_delta, angle- int_angle-int_delta
                end
            else
                if type_arc=="bg" then
                    d0,d1= angle-int_delta, int_delta+int_angle
                else
                    d0,d1= int_delta+int_angle, int_delta
                end
            end
        else
            if t.inverse_arc then    
                if type_arc=="bg" then    
                    d0,d1= angle-ext_delta-ext_angle,ext_delta
                else
                    d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
                end
            else
                if type_arc=="bg" then    
                    d0,d1= angle-ext_delta,ext_delta+ext_angle
                else    
                    d0,d1= ext_angle+ext_delta, ext_delta
                end
            end            
        end
        --draw sector
        cairo_move_to(cr,ax,ay)
        cairo_line_to(cr,bx,by)
        cairo_arc(cr,0,0,re,b0,b1)
        cairo_line_to(cr,dx,dy) 
        cairo_arc_negative(cr,0,0,ri,d0,d1)
         cairo_close_path (cr);

        --stroke or fill sector
         if type_arc=="bd" then
             cairo_set_line_width(cr,t.border_size)
             cairo_stroke(cr)
         else
             cairo_fill(cr)
         end
         cairo_restore(cr)
     end
    --draw sectors
    
    local n0,n1,n2 = 1,t.sectors,1
    if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
    local index = 0
    for i = n0,n1,n2 do 
        index = index +1
        local valueZ=1
        local cstA, cstB = (i-1),i
        if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
        
        if value>valueA *cstA and value<valueA*cstB then
            if not t.fill_sector then
                valueZ = (value-valueA*cstA)/valueA
            end
        else
            if value<valueA*cstB then valueZ=0 end
        end
        
        local start_angle= lastAngle+(i-1)*angleA
        if t.foreground ~= false then 
            draw_sector("fg",start_angle,angleA,valueZ, index)
        end
        if t.background ~= false then 
            draw_sector("bg",start_angle,angleA,valueZ, i)
        end
        if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
    end
    cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
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)
    if tonumber(conky_parse('${updates}'))>5 then
        for i in pairs(rings_settings) do
            draw_ring(cr,rings_settings[i])
        end
    end
    cairo_surface_destroy(cs)
        cairo_destroy(cr)    
end    

I'll post the entire thing once i make the tar, I have to remove personal info like gmail mogin info and some other things and write up a read me file so people know what to change for their own system.

Last edited by McLovin (2012-10-18 01:57:56)

Offline

#3346 2012-10-18 01:48:17

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,165
Website

Re: Conky v1.9 Thread

^ Code post please...

Edit - I see that you did say you would... Thanks!

Excellent work!  Well done.

Last edited by VastOne (2012-10-18 01:49:10)

Offline

#3347 2012-10-18 02:09:51

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,572

Re: Conky v1.9 Thread


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#3348 2012-10-18 06:08:20

lwfitz
#! Die Hard
From: Monrovia, CA
Registered: 2012-01-19
Posts: 886
Website

Re: Conky v1.9 Thread

Offline

#3349 2012-10-18 08:09:32

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

 -- mrpeachy_bar3d.module
 --[[ the post: http://crunchbanglinux.org/forums/post/55927/#p55927
 this one was easy (or i thought it was going to be)
 http://omploader.org/tM2x0bg
 Going to be a work in progress until i set up all the variables properly... and get my titles right smile
 UPDATE- now you can change line thickness without messing it up.  Getting the lines right has made things alot less easy smile
 also you can set font, font size and title position
    -- end the post
 isometric bars by mrpeachy (2010)
 --]]
 
 -- mod done by dk75 in october 2012
 
 local modname = ...
 local M = {}
 _G[modname] = M
 package.loaded[modname] = M
 
 
 
 --[[
 ###############################################################################
 ###                              SETTINGS                                   ###
 ###############################################################################
 --]]
 local settings_table = {
     {    
        -- ROOT
        object='${fs_used_perc /}',
        conkyobject=true,
        value=0,
        maxvalue=100,
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        linecolor=0xffffff,
        linealpha=0.8,
        facecolor=0x0000ff,
        facealpha=0.5,
        across=50,
        down=200,
        title="Root",
        font="White Rabbit",
        fontsize=14,
        txtcolor=0xffffff,
        txtacross=50,
        txtdown=220,
        --1 for framelines, 0 for none
        framelines=true,
        direction="right",
      },

     {    
        -- HOME
        object='${fs_used_perc /home}',
        conkyobject=true,
        value=0,
        maxvalue=100,
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        linecolor=0xffffff,
        linealpha=0.8,
        facecolor=0x0000ff,
        facealpha=0.5,
        across=120,
        down=200,
        title="Home",
        font="White Rabbit",
        fontsize=14,
        txtcolor=0xffffff,
        txtacross=120,
        txtdown=220,
        --1 for framelines, 0 for none
        framelines=true,
        direction="left",
      },

     {    
        -- CPU O (Average of all)
        object='${cpu cpu0}',
        conkyobject=true,
        value=0,
        maxvalue=100,
        scale='log',            -- possible values: nil or 'linear' (linear scale), 'log' (logaritmic scale), 'inv' (inverse logaritmic scale)
        linethick=0.5, --1.25  --1.5
        width=40,   --ancho de barra
        height=150, --altura de barra
        linecolor=0xffffff,
        linealpha=0.8,
        facecolor=0x000000,
        facealpha=0.5,
        across=50,  -- barra
        down=400,    -- barra
        title="CPU 0",
        font="White Rabbit",
        fontsize=14,
        txtcolor=0xffffff,
        txtacross=50, -- texto
        txtdown=420,   -- texto
        --1 for framelines, 0 for none
        framelines=true,
        direction="right",
      },

     {    
        -- MEMORY
        object='${memperc}',
        conkyobject=true,
        value=0,
        maxvalue=100,
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        linecolor=0xffffff,
        linealpha=0.8,
        facecolor=0xc88f00,
        facealpha=0.5,
        across=120,
        down=400,
        title="Memory",
        font="White Rabbit",
        fontsize=14,
        txtcolor=0x000000,
        txtacross=120,
        txtdown=420,
        --1 for framelines, 0 for none
        framelines=true,
        direction="left",
      },

     {    
        -- /dev/sda temperature
        object="ncat localhost 7634 |mawk -F'|' '{print $4}'",
        conkyobject=false,
        interval=15,
        value=0,
        maxvalue=100,
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        linecolor=0xffffff,
        linealpha=0.8,
        facecolor=0xc80000,
        facealpha=0.5,
        across=240,
        down=200,
        title="HDD0 °C",
        font="White Rabbit",
        fontsize=14,
        txtcolor=0x8c0000,
        txtacross=240,
        txtdown=220,
        --1 for framelines, 0 for none
        framelines=true,
        direction="right",
      },

     {    
        -- /dev/sdb temperature
        object="ncat localhost 7634 |mawk -F'|' '{print $9}'",
        conkyobject=false,
        interval=15,
        value=0,
        maxvalue=100,
        linethick=0.5, --1.25  --1.5
        width=40,
        height=150,
        linecolor=0xffffff,
        linealpha=0.8,
        facecolor=0xc80000,
        facealpha=0.5,
        across=320,
        down=200,
        title="HDD1 °C",
        font="White Rabbit",
        fontsize=14,
        txtcolor=0x8c0000,
        txtacross=320,
        txtdown=220,
        --1 for framelines, 0 for none
        framelines=true,
        direction="left",
      },
 }
 --[[
 ###############################################################################
 ###                           END OF SETTINGS                               ###
 ###############################################################################
 --]]
 
 
 
 --[[
 ###############################################################################
 ###                              INITIALIZE                                 ###
 ###############################################################################
 --]]
 M.color = one4all_cairo.rgb2rgba
 M.exec = one4all_main.os_capture
 local i = nil
 for i in pairs(settings_table) do
     local t = settings_table[i]
    --indicator
    if t.direction==nil or t.direction=="right" then t.direction=tonumber(t.width*-0.5)
    elseif t.direction=="left" then t.direction=tonumber(t.width*0.5) end
    if not tonumber(t.interval) then t.interval=1 end
    --point 1 - bottom left
    t.x1, t.y1 = 0, 0
    --point 2 - bottom right
    t.x2, t.y2 = t.x1+t.width, t.y1
    --point 3 - middle left
    t.x3, t.y3 = nil, nil
    --point 4 - middle ritght
    t.x4, t.y4 = nil, nil
    --point 5 - iso left
    t.x5, t.y5 = t.x1+t.direction, t.y1+(t.width*-0.5)
    --point 6 - iso right
    t.x6, t.y6 = t.x5+t.width, t.y5
    --point 7 - top left
    t.x7, t.y7 =  nil, nil
    --point 8 - top right
    t.x8, t.y8 =  nil, nil
 end
 --[[
 ###############################################################################
 --]]
 
 
 
 function M.draw_box(x1, y1, x2, y2, x3, y3, x4, y4, color, alpha, across, down, colorfill, alphafill)
    cairo_save(cr)
    cairo_translate(cr, across, down)
    cairo_move_to(cr, x1, y1)
    cairo_line_to(cr, x2, y2)
    cairo_line_to(cr, x3, y3)
    cairo_line_to(cr, x4, y4)
    cairo_close_path(cr)
    if colorfill and alphafill then
        cairo_set_source_rgba (cr, M.color(colorfill, alphafill));
        cairo_fill_preserve (cr)
    end
    cairo_set_source_rgba(cr, M.color(color, alpha));
    cairo_stroke(cr)
    cairo_restore(cr)
 end
 
 function M.execi(object, interval)
     if (tonumber(conky_parse('${updates}')) % interval) == 0 then return M.exec(object, raw)
     else return nil end
 end
 
 function M.parser(t)
     local object_value=nil
     if t.conkyobject then object_value = tonumber(conky_parse(t.object))
     else object_value = tonumber(M.execi(t.object, t.interval)) end
     if object_value then t.value=object_value end
 end
 
 function M.scale(t)
     local value=nil
     if t.scale=="log" then value = (t.height/math.log(t.maxvalue))*math.log(t.value)
     elseif t.log=="inv" then value = (t.height/math.exp(t.maxvalue))*math.exp(t.value)
     else value = (t.height/t.maxvalue)*t.value end
     if not value or value<=0 or value ~= value then value=0 end
     return value
 end
  
 function M.bar3d(t)
    --point 3 - middle left
    t.x3, t.y3 = t.x1, -M.scale(t)
    --point 4 - middle ritght
    t.x4, t.y4 = t.x2, t.y3
    --point 7 - top left
    t.x7, t.y7 = t.x5, t.y5-M.scale(t)
    --point 8 - top right
    t.x8, t.y8 = t.x7+t.width, t.y7
    --##################################
    cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
    cairo_set_line_width (cr,t.linethick)
    if t.framelines then
        --back lines
        M.draw_box(t.x5, t.y5, t.x5, t.y5-t.height, t.x6, t.y6-t.height, t.x6, t.y6, t.linecolor, t.linealpha, t.across, t.down)
    end
    --bottom
    M.draw_box(t.x1, t.y1, t.x2, t.y2, t.x6, t.y6, t.x5, t.y5, t.linecolor, t.linealpha, t.across, t.down, t.facecolor, t.facealpha)
    --back
    M.draw_box(t.x7, t.y7, t.x5, t.y5, t.x6, t.y6, t.x8, t.y8, t.linecolor, t.linealpha, t.across, t.down, t.facecolor, t.facealpha)
    --iso side left
    M.draw_box(t.x7, t.y7, t.x3, t.y3, t.x1, t.y1, t.x5, t.y5, t.linecolor, t.linealpha, t.across, t.down, t.facecolor, t.facealpha)
    --iso side right
    M.draw_box(t.x8, t.y8, t.x4, t.y4, t.x2, t.y2, t.x6, t.y6, t.linecolor, t.linealpha, t.across, t.down, t.facecolor, t.facealpha)
    --top
    M.draw_box(t.x3, t.y3, t.x7, t.y7, t.x8, t.y8, t.x4, t.y4, t.linecolor, t.linealpha, t.across, t.down, t.facecolor, t.facealpha)
    --front
    M.draw_box(t.x1, t.y1, t.x2, t.y2, t.x4, t.y4, t.x3, t.y3, t.linecolor, t.linealpha, t.across, t.down, t.facecolor, t.facealpha)
    
    if t.framelines then
        --frame lines
        --front
        M.draw_box(t.x1, t.y1, t.x1, t.y1-t.height, t.x2, t.y2-t.height, t.x2, t.y2, t.linecolor, t.linealpha, t.across, t.down)
        --top
        M.draw_box(t.x1, t.y1-t.height, t.x5, t.y5-t.height, t.x6, t.y6-t.height, t.x2, t.y2-t.height, t.linecolor, t.linealpha, t.across, t.down)
    end--if framelines
    --title
    cairo_select_font_face (cr, t.font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, t.fontsize);
    cairo_set_source_rgba (cr, M.color(t.txtcolor or t.linecolor, t.txtalpha or t.linealpha));
    cairo_move_to (cr, t.txtacross, t.txtdown)
    cairo_show_text (cr, t.title)
    cairo_stroke (cr)
end--isometric drawing function
 
 
 
 --[[
 ###############################################################################
 ###                            MODULE MAIN LOOP                             ###
 ###############################################################################
 --]]
 function M.main()
         for i in pairs(settings_table) do
             M.parser(settings_table[i])
             M.bar3d(settings_table[i])
         end
 end

Offline

Help fund CrunchBang, donate to the project!

#3350 2012-10-18 16:52:40

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 105
Website

Re: Conky v1.9 Thread

Hey mrpeachy, I was looking at your iso graph lua, and its giving me an idea, I was wondering if maybe there was a way to use the direct conky variable calls that you're using in it on other types of lua scripts, such as a ring.lua? I've been trying to get a diskio call to work in a lua script for a little while, and have tried everything I can think of, conky_parse, exec, and anything else I could think of, and just cannot seem to get it to work, but the way you're calling on the conky variable in your iso script, I think it would work with no issues, wondering what your thought on it are.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo