901

Re: My Conky Config

nice peachy

I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Re: My Conky Config

I like it, you should post a video of it in action.

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: My Conky Config

you can see it working here:

http://blip.tv/file/3244145

only the cpu bar does much though smile

also is there some option i need to change in recordmydesktop to stop it greying everything out?
or is there a better recording utility?

Last edited by mrpeachy (2010-02-20 17:33:07)

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

904

Re: My Conky Config

io vorrei avviare chrome al posto di firefox con super+w, come posso fare?

905

Re: My Conky Config

You make super+ space
Preferences
Openbox config
Edit rc.xml

then you find this part of code and replace firfox by the command to launch the browser you want.

<keybind key="W-w">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>Web Browser</name>
        </startupnotify>
        <command>firefox</command>
      </action>
    </keybind>

906

Re: My Conky Config

thanks! and sorry for my english.

Re: My Conky Config

UPDATE
Below is the lua code for vertical and horizontal graphs with gradients
http://imgur.com/uBDf0l.jpg
the setup for this lua is more involved if you want gradientsthan if you dont, so the non gradient version is also posted

--[[bargraph by mrpeachy (2010)  if you want more that 1 graph from this script then there are some things to change.  
I have done my best to provide adequate instructions through the script  setup begins at line 165]]

require 'cairo'

function background(cr, width, height, length, thick, hori, vert, bgr, bgg, bgb, bga, horv, outline, olr, olg, olb, ola, olt)

if width < 0 then
hori1=hori+(thick/2)-(length*width)
hori2=(width*length)-((thick)+width)
elseif width > 0 then
hori1=hori-(thick/2)
hori2=(width*length)+(thick-width)
end

if horv==1 and outline==0 then
    if bars == 3 then
    verti=vert-height
    bghigh=height*2
    elseif bars == 2 then
    verti=vert
    bghigh=height
    elseif bars == 1 then
    verti=vert
    bghigh=-1*height
    end
--background
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
else
end

if horv==2 and outline==0 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end
if horv==3 and outline==0 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end

if horv==1 and outline==1 then
    if bars == 3 then
    verti=vert-height
    bghigh=height*2
    elseif bars == 2 then
    verti=vert
    bghigh=height
    elseif bars == 1 then
    verti=vert
    bghigh=-1*height
    end
--background
cairo_set_line_width (cr, olt)
cairo_set_source_rgba (cr, olr, olg, olb, ola)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_stroke (cr)
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
else
end

if horv==2 and outline==1 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_line_width (cr, olt)
cairo_set_source_rgba (cr, olr, olg, olb, ola)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_stroke (cr)
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end
if horv==3 and outline==1 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_line_width (cr, olt)
cairo_set_source_rgba (cr, olr, olg, olb, ola)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_stroke (cr)
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end
end


function linedraw(cr, num, inum, length, hori, vert, width, height, thick, bars, horv, red, green, blue, alpha)
modnum=(num*(height/100))
if width < 0 then
hori1=hori-(length*width)
else
hori1=hori
end
if bars == 3 then
verti=vert+modnum
barh=-1*(2*modnum)
elseif bars == 1 then
verti=vert
barh=-1*modnum
elseif bars == 2 then
verti=vert+modnum
barh=-1*modnum
end
if horv == 1 then
cairo_set_source_rgba (cr, red, green, blue, alpha)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1+(width*(inum-1)), verti)
cairo_rel_line_to (cr, 0, barh)
cairo_stroke (cr)

else if horv == 2 and bars==1 then
cairo_set_source_rgba (cr, red, green, blue, alpha)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1, verti+(width*(inum-1)))
cairo_rel_line_to (cr, barh, 0)
cairo_stroke (cr)
else if horv == 2 and bars==2 then
verti=vert
barh=-1*modnum
cairo_set_source_rgba (cr, red, green, blue, alpha)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1-height, verti+(width*(inum-1)))
cairo_rel_line_to (cr, -barh, 0)
cairo_stroke (cr)
else if horv == 3 and bars==1 then
cairo_set_source_rgba (cr, red, green, blue, alpha)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1, (length*width)-width+verti-(width*(inum-1)))
cairo_rel_line_to (cr, barh, 0)
cairo_stroke (cr)
else if horv == 3 and bars==2 then
verti=vert
barh=-1*modnum
cairo_set_source_rgba (cr, red, green, blue, alpha)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1-height, (length*width)-width+verti-(width*(inum-1)))
cairo_rel_line_to (cr, -barh, 0)
cairo_stroke (cr)
end
end
end
end
end
end

function conky_draw_graph()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates==1 then 
--------TABLE SETUP--------------
--to have more than 1 bar of this type running you will need to add more table sets to this section

length_cpugraph=100 --this is how long you want your graph to be
cpugraph={} --this is the table that will hold your graph data
cpured={} -- these tables hold the data for the color and alphga gradients
cpugreen={}
cpublue={}
cpualpha={}
        
--tables must be setup in the space above----
-------END TABLE SETUP-----------------------  
    end
    if updates> 3 then
--graph settings entered below---------------    
    
--START OF BAR GRAPH SETUP-----------START OF BAR GRAPH SETUP-----------START OF BAR GRAPH SETUP-----------START OF BAR GRAPH SETUP---------
----------------------------------------------------------------
--You will need one bar graph setup for each table set you used
----------------------------------------------------------------
length=length_cpugraph --from table setup
--a positive width below will produce a right to left graph, a negative width will produce a left to right graph
width=2 --for vertical graph this number should be positive
--position of graph below
hori=200
vert=100
--height of graph below
height=100
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=2
--color 1 and alpha 1 for graph bar
linered=1
linegreen=0
lineblue=0
linealpha=0
--color 2 and alpha 2 for graph bar
linered2=1
linegreen2=0
lineblue2=0
linealpha2=1
--bars setting below, 1=bars up, 2=bars down, 3=bars up and down
bars=3 --enter 1 or 2 if you want vertical bars (not functional yet for 3)
--for a horizontal graph enter 1 below, for vertical going up enter 2, vertical going down enter 3.
horv=1
--background color setup
bgred=0.5
bggreen=0.3
bgblue=0.2
--below enter 0 for no background
bgalpha=0
--below enter 0 for no outline, 1 for an outline
outline=0
--set ouline thickness
olthick=1
--set color and alpha for outline
olred=0
olgreen=0
olblue=1
olalpha=1
--call background function
background(cr, width, height, length, thick, hori, vert, bgred, bggreen, bgblue, bgalpha, horv, outline, olred, olgreen, olblue, olalpha, olthick)
----------------------------------------------------------------------------------------------------------------------------------------------------
--do not edit the below 4 lines
rd=(linered-linered2)/length
gd=(linegreen-linegreen2)/length
bd=(lineblue-lineblue2)/length
ad=(linealpha-linealpha2)/length
----------------------------------------------------------------------------------------------------------------------------------------------------
--CALCULATIONS -- you will have to edit this section and change all the instances 
--of cpugraph, cpured, cpugreen etc, to whatever names you used in the table setup section
--you could cut this section to a blank document and do a find and replace.
for i = 1, tonumber(length) do
if cpugraph[i+1]==nil then cpugraph[i+1]=0 end
cpugraph[i]=cpugraph[i+1]    
if i==length then
cpugraph[length]=tonumber(conky_parse('${cpu}'))
end
for i = 1, tonumber(length) do
cpured[i]=linered-(rd*i)
end
for i = 1, tonumber(length) do
cpugreen[i]=linegreen-(gd*i)
end
for i = 1, tonumber(length) do
cpublue[i]=lineblue-(bd*i)
end
for i = 1, tonumber(length) do
cpualpha[i]=linealpha-(ad*i)
end
--END OF CALCULATIONS
--------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------
--ENTER TABLE NAMES BELOW---------------------------------------------------------
---------------------------------------------------------------------------------
table1=cpugraph[i]  --format should be nameoftable[i]
table2=cpured[i] --table that contains red data
table3=cpugreen[i]--table that contains green data
table4=cpublue[i]--table that contains blue data
table5=cpualpha[i]--table that contains alpha data
--call line drawing function
linedraw(cr, table1, i, length, hori, vert, width, height, thick, bars, horv, table2, table3, table4, table5)
end    
cairo_destroy(cr)
cairo_surface_destroy(cs)
--END OF FUNCTION SETUP------------END OF FUNCTION SETUP------------END OF FUNCTION SETUP---------END OF FUNCTION SETUP------------------------


--graph settings entered above----------------------------------------------------------------------------------------
end
end

here is the graph drawing function capable of drawing vertical as well as horizontal graphs

http://imgur.com/qkfjtl.jpg

Lua.script

--[[bargraph by mrpeachy (2010)  if you want more that 1 graph from this script then there are some things to change.  
I have done my best to provide adequate instructions through the script  setup begins at line 165]]

require 'cairo'

function background(cr, width, height, length, thick, hori, vert, bgr, bgg, bgb, bga, horv, outline, olr, olg, olb, ola, olt)

if width < 0 then
hori1=hori+(thick/2)-(length*width)
hori2=(width*length)-((thick)+width)
elseif width > 0 then
hori1=hori-(thick/2)
hori2=(width*length)+(thick-width)
end

if horv==1 and outline==0 then
    if bars == 3 then
    verti=vert-height
    bghigh=height*2
    elseif bars == 2 then
    verti=vert
    bghigh=height
    elseif bars == 1 then
    verti=vert
    bghigh=-1*height
    end
--background
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
else
end

if horv==2 and outline==0 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end
if horv==3 and outline==0 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end

if horv==1 and outline==1 then
    if bars == 3 then
    verti=vert-height
    bghigh=height*2
    elseif bars == 2 then
    verti=vert
    bghigh=height
    elseif bars == 1 then
    verti=vert
    bghigh=-1*height
    end
--background
cairo_set_line_width (cr, olt)
cairo_set_source_rgba (cr, olr, olg, olb, ola)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_stroke (cr)
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
else
end

if horv==2 and outline==1 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_line_width (cr, olt)
cairo_set_source_rgba (cr, olr, olg, olb, ola)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_stroke (cr)
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end
if horv==3 and outline==1 then
--background
--cairo_translate (cr, hori, vert)
hori1=hori-height
hori2=height
verti=(vert)-(width/2)
bghigh=length*width
cairo_set_line_width (cr, olt)
cairo_set_source_rgba (cr, olr, olg, olb, ola)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_stroke (cr)
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--cairo_translate (cr, -hori, -vert)
else
end
end


function linedraw(cr, num, inum, length, hori, vert, width, height, thick, dotr, dotg, dotb, dota, bars, horv)
modnum=(num*(height/100))
if width < 0 then
hori1=hori-(length*width)
else
hori1=hori
end
if bars == 3 then
verti=vert+modnum
barh=-1*(2*modnum)
elseif bars == 1 then
verti=vert
barh=-1*modnum
elseif bars == 2 then
verti=vert+modnum
barh=-1*modnum
end
if horv == 1 then
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1+(width*(inum-1)), verti)
cairo_rel_line_to (cr, 0, barh)
cairo_stroke (cr)
else if horv == 2 then
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1, verti+(width*(inum-1)))
cairo_rel_line_to (cr, barh, 0)
cairo_stroke (cr)
else
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1, (length*width)-width+verti-(width*(inum-1)))
cairo_rel_line_to (cr, barh, 0)
cairo_stroke (cr)
end
end
end

function conky_draw_graph()
    if conky_window == nil then return end
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    cr = cairo_create(cs)
    local updates=tonumber(conky_parse('${updates}'))
    if updates==1 then 
--------TABLE SETUP--------------
--to have more than 1 bar of this type running you will need to add tables

        length_cpugraph=300 --this is how long you want your graph to be
        cpugraph={} --this is the table that will hold your graph data
        
        --another example could be
        
        --length_memgraph=100
        --memgraph={}
        
        
        
        
--tables must be setup in the space above----
-------END TABLE SETUP-----------------------  
    end
    if updates> 3 then
--graph settings entered below---------------    
    
--START OF BAR GRAPH SETUP-----------START OF BAR GRAPH SETUP-----------START OF BAR GRAPH SETUP-----------START OF BAR GRAPH SETUP---------
length=length_cpugraph --from table setup
--a positive width below will produce a right to left graph, a negative width will produce a left to right graph
width=2 --for vertical graph this number should be positive
--position of graph below
hori=250
vert=100
--height of graph below
height=50
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=2
--graph bar color and alpha below
linered=1
linegreen=1
lineblue=1
linealpha=1
--bars setting below, 1=bars up, 2=bars down, 3=bars up and down
bars=1 --enter 1 if you want vertical bars (not functional yet for options 2 or 3)
--for a horizontal graph enter 1 below, for vertical going up enter 2, vertical going down enter 3.
horv=3
--background color setup
bgred=1
bggreen=1
bgblue=1
--below enter 0 for no background
bgalpha=0
--below enter 0 for no outline, 1 for an outline
outline=1
--set ouline thickness
olthick=1
--set color and alpha for outline
olred=1
olgreen=1
olblue=1
olalpha=1
--call background function
background(cr, width, height, length, thick, hori, vert, bgred, bggreen, bgblue, bgalpha, horv, outline, olred, olgreen, olblue, olalpha, olthick)
--CALCULATIONS -- you will have to edit this section and change all the instances of cpugraph and length_cpugraph to whatever names you used in the table setup section
      for i = 1, tonumber(length_cpugraph) do
            if cpugraph[i+1]==nil then cpugraph[i+1]=0 end
            cpugraph[i]=cpugraph[i+1]    
            if i==length_cpugraph then
                cpugraph[length_cpugraph]=tonumber(conky_parse('${cpu}'))
            end
--END OF CALCULATIONS
---------------------------------------------------------------------------------
--ENTER TABLE NAME BELOW---------------------------------------------------------
---------------------------------------------------------------------------------
table=cpugraph[i]  --format should be nameoftable[i]
--call line drawing function
linedraw(cr, table, i, length, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha, bars, horv)
end    
cairo_destroy(cr)
cairo_surface_destroy(cs)
--END OF FUNCTION SETUP------------END OF FUNCTION SETUP------------END OF FUNCTION SETUP---------END OF FUNCTION SETUP------------------------




--graph settings entered above----------------------------------------------------------------------------------------
end
end

in conky you will need

lua_load ~path~/bargraphtest.lua
lua_draw_hook_pre draw_graph
TEXT

This isnt the easiest script to set up, particularly if you want multiple graphs from the script.  but the script contains instructions on how to do it.


PREVIOUS VERSION
displays cpu usage as both positive and negative at each point

http://omploader.org/tM21qaA
you can change the direction that the graph moves in, colors, bar thickness and spacing, have gridlines on or off and graph height.

you can now edit a setting to get either bars up only, bars down only or bars up and down
http://omploader.org/tM21rcA
these are 2 seperate scrrenshots edited together.  To get more than one of these graphs at the same time you would have to duplicate most of the draw_graph function within that function.

Other than that I think i have everything set up correctly

--[[bargraph by mrpeachy (2010)]]
require 'cairo'

function background(cr, width, height, length, thick, hori, vert, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla)

if width < 0 then
hori1=hori+(thick/2)-(length*width)
hori2=(width*length)-((thick)+width)
elseif width > 0 then
hori1=hori-(thick/2)
hori2=(width*length)+(thick-width)
end

if bars == 3 then
verti=vert-height
bghigh=height*2
elseif bars == 2 then
verti=vert
bghigh=height
elseif bars == 1 then
verti=vert
bghigh=-1*height
end

--background
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)

--gridlines
if gridlines == 1 and bars == 3 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert-height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
elseif gridlines == 1 and bars == 1 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert-height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
elseif gridlines == 1 and bars == 2 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
end
end

function linedraw(cr, num, inum, length, hori, vert, width, height, thick, dotr, dotg, dotb, dota, bars)
modnum=(num*(height/100))
if width < 0 then
hori1=hori-(length*width)
else
hori1=hori
end
if bars == 3 then
verti=vert+modnum
barh=-1*(2*modnum)
elseif bars == 1 then
verti=vert
barh=-1*modnum
elseif bars == 2 then
verti=vert+modnum
barh=-1*modnum
end
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_set_line_width (cr, thick) 
cairo_move_to (cr, hori1+(width*(inum-1)), verti)
cairo_rel_line_to (cr, 0, barh)
cairo_stroke (cr)
end

function conky_draw_graph()
    if conky_window == nil then return end
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    cr = cairo_create(cs)
    local updates=tonumber(conky_parse('${updates}'))
    if updates==1 then     
        len_t=100
        t1={}   
    end
    if updates> 3 then
--bar graph setup
--to change the direction of the graph
--a positive width will produce a right to left graph
--a negative width will produce a left to right graph
width=2
hori=10
vert=200
height=100
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=1
linered=0
linegreen=1
lineblue=1
linealpha=1
--bars setting below, 1=bars up, 2=bars down, 3=bars up and down
bars=2
--background setup
bgr=0
bgg=0
bgb=1
--below enter 0 for no background
bga=0.5
--bewlo enter 1 for gridlines, 0 for none
gridlines=1
glthick=1  
glr=1
glg=1
glb=1
gla=0.8
--call background function
background(cr, width, height, len_t, thick, hori, vert, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla)

--CALCULATIONS
      for i = 1, tonumber(len_t) do
            if t1[i+1]==nil then t1[i+1]=0 end
            t1[i]=t1[i+1]    
            if i==len_t then
                t1[len_t]=tonumber(conky_parse('${cpu}'))
            end
--END OF CALCULATIONS

--call line drawing function
linedraw(cr, t1[i], i, len_t, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha, bars)
end    
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
end

Last edited by mrpeachy (2010-08-22 17:36:53)

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

Re: My Conky Config

This one is proving a little more difficult
http://omploader.org/tM21wdQ

the problem is that the line chart part is always one cycle behind on displaying the cpu data, i compensated by adding a cpu bar on the side (it also covers up the fact that the furthest right plot point is always 0)... but still
i have a fuzzy understanding of the issue at work, but too fuzzy to try and explain them big_smile

here it is in action (a bit jumpy in this clip, I was having some slow down issues)
http://blip.tv/file/3249631

heres the code... but this is a work in progress smile

--[[linegraph by mrpeachy (2010)]]
require 'cairo'
function background(cr, width, height, length, thick, hori, vert, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla)
hori1=hori+(width*2)
hori2=(width*length)-width
--background
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, vert, hori2, height)
cairo_fill (cr)
--gridlines
if gridlines == 1 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
end
end

function linedraw(cr, num, numnow, number2, number3, inum, length, hori, vert, width, height, thick, dotr, dotg, dotb, dota)
num1=(num*(height/100))
number=(numnow*(height/100))
numb=(number2*(height/100))
numb2=(number3*(height/100))
cairo_translate (cr, hori, vert)
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_move_to (cr, width*(inum+1), height-numb)
cairo_line_to (cr, width*(inum+2), height-numb2)
cairo_stroke (cr)
cairo_translate (cr, -hori, -vert)

cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_rectangle (cr, hori+(length*width), vert+height, width, -height)
cairo_stroke (cr)

cairo_set_source_rgba (cr, bgr, bgg, bgb, 1)
cairo_rectangle (cr, hori+(length*width), vert+height, width, -height)
cairo_fill (cr)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_rectangle (cr, hori+(length*width), vert+height, width, -num1)
cairo_fill (cr)


end


function conky_draw_graph()
    if conky_window == nil then return end
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    cr = cairo_create(cs)
    local updates=tonumber(conky_parse('${updates}'))
    if updates==1 then     
        len_t=30
        t1={}   
    end
    if updates> 3 then
--bar graph setup
width=20
hori=20
vert=200
height=100
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=1
linered=0
linegreen=0
lineblue=0
linealpha=1
--background setup
bgr=1
bgg=1
bgb=1
--below enter 0 for no background
bga=1
--bewlo enter 1 for gridlines, 0 for none
gridlines=0
glthick=1  
glr=1
glg=1
glb=1
gla=0.8
--call background function
background(cr, width, height, len_t, thick, hori, vert, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla)

--CALCULATIONS
      for i = 1, tonumber(len_t) do
            if t1[i+1]==nil then t1[i+1]=0 end
            t1[i]=t1[i+1]    
            if i==len_t then
                t1[len_t]=tonumber(conky_parse('${cpu}'))
            end
--END OF CALCULATIONS

--call line drawing function
number3=t1[i+2]
if number3==nil then number3=0 end
cpu=tonumber(conky_parse('${cpu}'))
linedraw(cr, cpu, t1[i], t1[i+1], number3, i, len_t, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha)
--print (t1[i+3])
end    
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
end

Last edited by mrpeachy (2010-02-23 04:48:41)

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

Re: My Conky Config

the line graph was giving me problems for a while now but I've had a breakthrough and now its working.
http://omploader.org/tM25jcA

this is what I was aiming for, inspired by a electroencephalogram output

see it in action here
http://blip.tv/file/3259598

code needs to be prettied up and settings need to be set, so I wont post code just yet smile
UPDATE - things are cleaned up and i have set up the script to give a similar kind of output choices as my bargraph above:
http://omploader.org/tM25keQ
either the zig zag up and down,
only up
or only down.

and here is the code:

--[[linegraph/electroencephalogram lua script by mrpeachy 2010]]
require 'cairo'
function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end

function linedraw(cr, tablestring, length, hori, vert, width, height, thick, dotr, dotg, dotb, dota, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla, bars)
cpus=tablestring
tablecpu=string.split(cpus, '%p')

if width < 0 then
hori1=hori-(length*width)
hori2=(width*length)-width
hori3=hori-(length*width)-width
elseif width > 0 then
hori1=hori+width
hori2=(width*length)-width
hori3=hori
end

if bars == 3 then
verti=vert-height
bghigh=height*2
elseif bars == 2 then
verti=vert
bghigh=height
elseif bars == 1 then
verti=vert
bghigh=-1*height
end
--background
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--gridlines

if gridlines == 1 and bars == 3 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert-height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
elseif gridlines == 1 and bars == 1 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert-height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
elseif gridlines == 1 and bars == 2 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
end

if bars==3 then
for i = 1,length-1 do
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_translate (cr, hori3, vert)
cairo_move_to (cr, width*i,  -tablecpu[i])
cairo_line_to (cr, width*(i+0.5), tablecpu[i])
cairo_line_to (cr, width*(i+1),-tablecpu[i+1])
--cairo_line_to (cr, width*(i+1.5), tablecpu[i+1])
cairo_stroke (cr)
cairo_translate (cr, -hori3, -vert)
end
elseif bars==1 then
for i = 1,length-1 do
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_translate (cr, hori3, vert)
cairo_move_to (cr, width*i,  -tablecpu[i])
cairo_line_to (cr, width*(i+0.5), -tablecpu[i])
cairo_line_to (cr, width*(i+1),-tablecpu[i+1])
cairo_stroke (cr)
cairo_translate (cr, -hori3, -vert)
end
elseif bars==2 then
for i = 1,length-1 do
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_translate (cr, hori3, vert)
cairo_move_to (cr, width*i,  tablecpu[i])
cairo_line_to (cr, width*(i+0.5), tablecpu[i])
cairo_line_to (cr, width*(i+1),tablecpu[i+1])
cairo_stroke (cr)
cairo_translate (cr, -hori3, -vert)
end
end
end

function conky_draw_graph()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates==1 then     
len_t=30
t1={}  
end
if updates> 3 then
    
--SETTINGS
width=10
hori=200
vert=200
height=100
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=1
linered=1
linegreen=1
lineblue=1
linealpha=1
--background setup
bgr=0
bgg=0
bgb=1
--background alpha 0 for no background
bga=0.5
--bewlo enter 1 for gridlines, 0 for none
gridlines=1
glthick=1  
glr=1
glg=1
glb=1
gla=0.8
--select output type, 1=barsup, 2=barsdown, 3=barszigzag up and dwn
bars=3
--END OF SETTINGS
--CALCULATIONS
for i = 1, tonumber(len_t) do
if t1[i+1]==nil then t1[i+1]=0 end
t1[i]=t1[i+1]    
if i==len_t then
t1[len_t]=tonumber(conky_parse('${cpu}'))
end
--END OF CALCULATIONS
end   
t1string=table.concat(t1, ":")
linedraw(cr, t1string, len_t, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla, bars)
end
end

Last edited by mrpeachy (2010-02-24 02:17:28)

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

Re: My Conky Config

with some tweaking i have this big_smile

http://omploader.org/tM25qNw

the "heartbeat" blip is the HDD used percent followed by HDD used x 0.25

--[[system monitor lua script by mrpeachy (2010) based on linegraph/electroencephalogram lua script by mrpeachy (2010) incorporates code from Background by londonali1010 (2009)]]
require 'cairo'

function addzero100(num)
if tonumber(num) < 10 then
return "00" .. num
elseif tonumber(num) <100 then
return "0" .. num
else
return num
end
end

function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end

function linedraw(cr, tablestring, length, hori, vert, width, height, thick, dotr, dotg, dotb, dota, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla, bars)
cpus=tablestring
tablecpu=string.split(cpus, '%p')

if width < 0 then
hori1=hori-(length*width)
hori2=(width*length)-width
hori3=hori-(length*width)-width
elseif width > 0 then
hori1=hori+width
hori2=(width*length)-width
hori3=hori
end

if bars == 3 then
verti=vert-height
bghigh=height*2
elseif bars == 2 then
verti=vert
bghigh=height
elseif bars == 1 then
verti=vert
bghigh=-1*height
end
--background
cairo_set_source_rgba (cr, bgr, bgg, bgb, bga)
cairo_rectangle (cr, hori1, verti, hori2, bghigh)
cairo_fill (cr)
--gridlines

if gridlines == 1 and bars == 3 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert-height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
elseif gridlines == 1 and bars == 1 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert-height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert-(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
elseif gridlines == 1 and bars == 2 then
cairo_set_line_width (cr, glthick)
cairo_set_source_rgba (cr, glr, glg, glb, gla)
cairo_move_to (cr, hori1, vert)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+height)
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.75))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.5))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
cairo_move_to (cr, hori1, vert+(height*0.25))
cairo_rel_line_to (cr, hori2, 0)
cairo_stroke (cr)
end
adjust=height/100
if bars==3 then
for i = 1,length-1 do
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_translate (cr, hori3, vert)
cairo_move_to (cr, width*i,  -tablecpu[i]*adjust)
cairo_line_to (cr, width*(i+0.5), tablecpu[i]*adjust)
cairo_line_to (cr, width*(i+1),-tablecpu[i+1]*adjust)
--cairo_line_to (cr, width*(i+1.5), tablecpu[i+1])
cairo_stroke (cr)
cairo_translate (cr, -hori3, -vert)
end
elseif bars==1 then
for i = 1,length-1 do
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_translate (cr, hori3, vert)
cairo_move_to (cr, width*i,  -tablecpu[i]*adjust)
cairo_line_to (cr, width*(i+0.5), -tablecpu[i]*adjust)
cairo_line_to (cr, width*(i+1),-tablecpu[i+1]*adjust)
cairo_stroke (cr)
cairo_translate (cr, -hori3, -vert)
end
elseif bars==2 then
for i = 1,length-1 do
cairo_set_line_width (cr, thick)
cairo_set_source_rgba (cr, dotr, dotg, dotb, dota)
cairo_translate (cr, hori3, vert)
cairo_move_to (cr, width*i,  tablecpu[i]*adjust)
cairo_line_to (cr, width*(i+0.5), tablecpu[i]*adjust)
cairo_line_to (cr, width*(i+1),tablecpu[i+1]*adjust)
cairo_stroke (cr)
cairo_translate (cr, -hori3, -vert)
end
end
end

function textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
cairo_translate (cr, across, down)
cairo_scale (cr, 0.70, 1)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, txtred, txtgreen, txtblue, txtalpha);
cairo_move_to (cr, 0, 0)
cairo_show_text (cr, text)
cairo_scale (cr, 1/0.70, 1/1)
cairo_translate (cr, -across, -down)
end

function conky_draw_graph()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))

if updates==1 then     
len_t=30
t1={}  
len_t2=30
t2={}  
len_t3=30
t3={}  
end

if updates> 3 then

--background
corner_r=15
w=400
height=400
cairo_move_to(cr,corner_r,0)
cairo_line_to(cr,w-corner_r,0)
cairo_curve_to(cr,w,0,w,0,w,corner_r)
cairo_line_to(cr,w,height-corner_r)
cairo_curve_to(cr,w,height,w,height,w-corner_r,height)
cairo_line_to(cr,corner_r,height)
cairo_curve_to(cr,0,height,0,height,0,height-corner_r)
cairo_line_to(cr,0,corner_r)
cairo_curve_to(cr,0,0,0,0,corner_r,0)
cairo_close_path(cr)
cairo_set_source_rgba(cr, 0, 0, 0, 1)
cairo_fill(cr)

--CALCULATIONS
for i = 1, tonumber(len_t) do
if t1[i+1]==nil then t1[i+1]=0 end
t1[i]=t1[i+1]    
if i==len_t then
t1[len_t]=tonumber(conky_parse('${cpu}'))
end
end
--END OF CALCULATIONS
--CALCULATIONS
timer=(updates % 4)+1
if timer==1 or timer==2 then
value=tonumber(conky_parse('${memperc}'))
else
value=0
end
for i = 1, tonumber(len_t2) do
if t2[i+1]==nil then t2[i+1]=0 end
t2[i]=t2[i+1]    
if i==len_t2 then
t2[len_t2]=tonumber(value)
end
end
--END OF CALCULATIONS
--CALCULATIONS
timer=(updates % 4)+1
if timer==1 then
value=tonumber(conky_parse('${fs_used_perc /}'))
elseif timer==2 then
calc=tonumber(conky_parse('${fs_used_perc /}'))
value=calc*0.25
else
value=0
end
for i = 1, tonumber(len_t3) do
if t3[i+1]==nil then t3[i+1]=0 end
t3[i]=t3[i+1]    
if i==len_t3 then
t3[len_t3]=tonumber(value)
end
end
--END OF CALCULATIONS

--SETTINGS 1
--TITLE
--settings for text
--text must be in quotes
text="SYSTEM MONITOR"
across=70
down=40
--font must be in quotes
font="White Rabbit"
fsize=30
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
--set data string
t1string=table.concat(t1, ":")
--variables
width=10
hori=10
vert=110
height=50
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=1
linered=1
linegreen=1
lineblue=1
linealpha=1
--background setup
bgr=0
bgg=0
bgb=1
--background alpha 0 for no background
bga=0.5
--bewlo enter 1 for gridlines, 0 for none
gridlines=1
glthick=0.5  
glr=1
glg=1
glb=1
gla=0.8
--select output type, 1=barsup, 2=barsdown, 3=barszigzag up and dwn
bars=3
--call figure drawing function
linedraw(cr, t1string, len_t, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla, bars)
--settings for text
--text must be in quotes
text="CPU"
across=320
down=100
--font must be in quotes
font="White Rabbit"
fsize=50
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
text=addzero100(tonumber(conky_parse('${cpu}')))
across=320
down=150
--font must be in quotes
font="White Rabbit"
fsize=50
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
--END OF SETTINGS

--SETTINGS 2
--set data string
t2string=table.concat(t2, ":")
--variables
width=10
hori=10
vert=370
height=100
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=1
linered=1
linegreen=1
lineblue=1
linealpha=1
--background setup
bgr=0
bgg=0
bgb=1
--background alpha 0 for no background
bga=0.5
--bewlo enter 1 for gridlines, 0 for none
gridlines=1
glthick=0.5  
glr=1
glg=1
glb=1
gla=0.8
--select output type, 1=barsup, 2=barsdown, 3=barszigzag up and dwn
bars=1
--call figure drawing function
linedraw(cr, t2string, len_t2, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla, bars)
--settings for text
--text must be in quotes
text="FSY"
across=320
down=205
--font must be in quotes
font="White Rabbit"
fsize=50
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
text=addzero100(tonumber(conky_parse('${fs_used_perc /}')))
across=320
down=255
--font must be in quotes
font="White Rabbit"
fsize=50
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
--END OF SETTINGS

--SETTINGS 3
--set data string
t3string=table.concat(t3, ":")
--variables
width=10
hori=10
vert=215
height=50
--thick=line thickness should be greater than width (width=spacing of lines)  
thick=1
linered=1
linegreen=1
lineblue=1
linealpha=1
--background setup
bgr=0
bgg=0
bgb=1
--background alpha 0 for no background
bga=0.5
--bewlo enter 1 for gridlines, 0 for none
gridlines=1
glthick=0.5  
glr=1
glg=1
glb=1
gla=0.8
--select output type, 1=barsup, 2=barsdown, 3=barszigzag up and dwn
bars=3
--call figure drawing function
linedraw(cr, t3string, len_t3, hori, vert, width, height, thick, linered, linegreen, lineblue, linealpha, bgr, bgg, bgb, bga, gridlines, glthick, glr, glg, glb, gla, bars)
--settings for text
--text must be in quotes
text="MEM"
across=320
down=310
--font must be in quotes
font="White Rabbit"
fsize=50
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
text=addzero100(tonumber(conky_parse('${memperc}')))
across=320
down=360
--font must be in quotes
font="White Rabbit"
fsize=50
txtred=1
txtgreen=1
txtblue=1
txtalpha=1
--call text function
textdraw(text, down, across, font, fsize, txtred, txtgreen, txtblue, txtalpha)
--END OF SETTINGS
end
end

Last edited by mrpeachy (2010-02-24 19:39:40)

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

911

Re: My Conky Config

I'll stand in for Bruce and say Wow, great work Mr Peachy!

I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Re: My Conky Config

tawan wrote:

I'll stand in for Bruce and say Wow, great work Mr Peachy!

Thanks tawan... but you forgot the "Have a nice day" at the end.  big_smile

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

Re: My Conky Config

blur effect
this will let you apply a pseudo blur to text and conky outputs
(also works nicely to provide shadows smile )

http://omploader.org/tM255Mg

and here is a comparison of blurred and not blurred

http://omploader.org/tM255Ng

--[[textblur and shadow function by mrpeachy (2010)]]
require 'cairo'

function addzero100(num)
if tonumber(num) < 10 then
return "00" .. num
elseif tonumber(num) <100 then
return "0" .. num
else
return num
end
end

function textblur(inum, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha)
for i=1,inum do
deg=360/inum
text_arc=((2*math.pi/inum)*i)
txs=0+radi*(math.sin(text_arc))
tys=0-radi*(math.cos(text_arc))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, tred, tgreen, tblue, talpha);
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_show_text (cr, text)
end
end

function conky_draw_blur()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates> 3 then
day=string.upper(conky_parse('${time %a}'))
--blur function settings
positionx=200
positiony=200
text=(day .. " " .. (conky_parse('${time %H:%M:%S}')) .. " ")
font="321impact"
fontsize=50
fred, fgreen, fblue=0,0,0
--blur settings
number=8
radius=1.75
--end of settings
textblur(number, text, font, fontsize, radius, positionx, positiony, fred, fgreen, fblue, 1/number)

--blur function settings
positionx=195
positiony=195
text=(day .. " " .. (conky_parse('${time %H:%M:%S}')) .. " ")
font="321impact"
fontsize=50
fred, fgreen, fblue=0.5,0.5,0.5
--blur settings
number=1
radius=1.75
--end of settings
textblur(number, text, font, fontsize, radius, positionx, positiony, fred, fgreen, fblue, 1/number)


--blur function settings
positionx=200
positiony=220
text=("___________")
font="321impact"
fontsize=50
fred, fgreen, fblue=0,0,0
--blur settings
number=8
radius=1.75
--end of settings
textblur(number, text, font, fontsize, radius, positionx, positiony, fred, fgreen, fblue, 1/number)


--blur function settings
positionx=200
positiony=260
text=("CPU" .. "  - " .. (addzero100(conky_parse('${cpu}'))) .. "%  RAM - " .. (addzero100(conky_parse('${memperc}'))) .. "%")
font="321impact"
fontsize=28
fred, fgreen, fblue=0,0,0
--blur settings
number=8
radius=1.75
--end of settings
textblur(number, text, font, fontsize, radius, positionx, positiony, fred, fgreen, fblue, 1/number)


--blur function settings
positionx=200
positiony=300
text=("HD1" .. "  - " .. (addzero100(conky_parse('${fs_used_perc /}'))) .. "%  HD2 - " .. (addzero100(conky_parse('${fs_used_perc /media/Windows XP}'))) .. "%")
font="321impact"
fontsize=28
fred, fgreen, fblue=0,0,0
--blur settings
number=8
radius=1.75
--end of settings
textblur(number, text, font, fontsize, radius, positionx, positiony, fred, fgreen, fblue, 1/number)

end
end

Last edited by mrpeachy (2010-02-25 18:48:53)

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

Re: My Conky Config

i'be been looking at applying shading to cairo objects... turns out it wasn't nearly as difficult as i thought it was going to be.
I used the conky blog contest (valentine theme) as an excuse to try it out with the flower conky I made.
http://blog.conky.be/2010/02/03/februar … ymassacre/

UPDATE

http://omploader.org/tM29rNw

I decided to draw the hearts in cairo and shade them to match the flowers better (I had a heart shape on file from my first flower conky). 
The hearts don't do anything, just look pretty.
Also you can now change the number of petals for each flower.
A minor fix to work on is so that when you change the petal number the shading effect stays the same.
(and yes, it is very pink.)

http://omploader.org/tM29maQ
these meters were completely redesigned (again) to incorporate a shading effect on each petal.
the hearts are on the wallpaper

require 'cairo'
function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end

function circlewriting(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
range=finish
deg=(finish-start)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start+(deg*(i-1))))+var1
interval2=degrads*(start+(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, tred, tgreen, tblue, talpha);
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2)
cairo_show_text (cr, (texttable[i]))
cairo_rotate (cr, -interval2)
end
end
function circlewritingdown(cr, text, font, fsize, radi, horiz, verti, tred, tgreen, tblue, talpha, start, finish, var1)
local inum=string.len(text)
deg=(start-finish)/(inum-1)
degrads=1*(math.pi/180)
local textcut=string.gsub(text, ".", "%1@@@")
texttable=string.split(textcut, "@@@")
for i = 1,inum do
ival=i
interval=(degrads*(start-(deg*(i-1))))+var1
interval2=degrads*(start-(deg*(i-1)))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, tred, tgreen, tblue, talpha);
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval2+(180*math.pi/180))
cairo_show_text (cr, (texttable[i]))
cairo_rotate (cr, -interval2-(180*math.pi/180))
end
end

function flower (output, hori, vert, scale, rotation, red, green, blue, alpha, petals)

--BACKGROUND FLOWER FLAT
if background==1 then
inner=60+100
outer1=60+(100*2)
outer2=(60+(100*2))
outer3=outer1
varth1=0.5
varth2=0.5
for i=1,petals do
cairo_translate (cr, hori, vert)
cairo_scale (cr, scale, scale)
cairo_rotate (cr, (rotation*(math.pi/180)))
cairo_rotate (cr, ((360/petals*(i-1))*(math.pi/180)))
--inner arc from
cairo_move_to (cr, 0, 0)
text_arc=((2*math.pi/(petals*2))*(3))
txs1=0+inner*(math.sin(text_arc))
tys1=0-inner*(math.cos(text_arc))
--outer arc through
text_arc=((2*math.pi/(petals*2))*(3+varth1))
txs2=0+outer1*(math.sin(text_arc))
tys2=0-outer1*(math.cos(text_arc))
--outer arc to
text_arc=((2*math.pi/(petals*2))*(4))
txs3=0+outer2*(math.sin(text_arc))
tys3=0-outer2*(math.cos(text_arc))
cairo_move_to (cr, txs1, tys1)
cairo_curve_to (cr, txs1, tys1, txs2, tys2, txs3, tys3)
--outer arc through
text_arc=((2*math.pi/(petals*2))*(4+varth2))
txs4=0+outer3*(math.sin(text_arc))
tys4=0-outer3*(math.cos(text_arc))
--outer arc to
text_arc=((2*math.pi/(petals*2))*(5))
txs5=0+inner*(math.sin(text_arc))
tys5=0-inner*(math.cos(text_arc))
cairo_curve_to (cr, txs3, tys3, txs4, tys4, txs5, tys5)
cairo_line_to (cr,0,0)
cairo_set_source_rgba (cr, bgred, bggreen, bgblue, 1)
cairo_fill (cr)
cairo_rotate (cr, ((360/petals*(i-1))*(math.pi/180))*-1)
cairo_rotate (cr, (rotation*(math.pi/180))*-1)
cairo_scale (cr, 1/scale, 1/scale)
cairo_translate (cr, hori*-1, vert*-1)
end
end

--BACKGROUND FLOWER PETALS
inner=60+100
outer1=60+(100*2)
outer2=(60+(100*2))
outer3=outer1
varth1=0.5
varth2=0.5
for i=1,petals do
cairo_translate (cr, hori, vert)
cairo_scale (cr, scale, scale)
cairo_rotate (cr, (rotation*(math.pi/180)))
cairo_rotate (cr, ((360/petals*(i-1))*(math.pi/180)))
--inner arc from
cairo_move_to (cr, 0, 0)
text_arc=((2*math.pi/(petals*2))*(3))
txs1=0+inner*(math.sin(text_arc))
tys1=0-inner*(math.cos(text_arc))
--outer arc through
text_arc=((2*math.pi/(petals*2))*(3+varth1))
txs2=0+outer1*(math.sin(text_arc))
tys2=0-outer1*(math.cos(text_arc))
--outer arc to
text_arc=((2*math.pi/(petals*2))*(4))
txs3=0+outer2*(math.sin(text_arc))
tys3=0-outer2*(math.cos(text_arc))
cairo_move_to (cr, txs1, tys1)
cairo_curve_to (cr, txs1, tys1, txs2, tys2, txs3, tys3)
--outer arc through
text_arc=((2*math.pi/(petals*2))*(4+varth2))
txs4=0+outer3*(math.sin(text_arc))
tys4=0-outer3*(math.cos(text_arc))
--outer arc to
text_arc=((2*math.pi/(petals*2))*(5))
txs5=0+inner*(math.sin(text_arc))
tys5=0-inner*(math.cos(text_arc))
cairo_curve_to (cr, txs3, tys3, txs4, tys4, txs5, tys5)
cairo_line_to (cr,0,0)
pat = cairo_pattern_create_radial (100, 120, 10,
                                   100,  100, 128.0);
cairo_pattern_add_color_stop_rgba (pat, 0, red, green, blue, alpha/2)
cairo_pattern_add_color_stop_rgba (pat, 1, red*0.7, green*0.7, blue*0.7, alpha/2)
cairo_set_source (cr, pat)
cairo_fill (cr)
cairo_rotate (cr, ((360/petals*(i-1))*(math.pi/180))*-1)
cairo_rotate (cr, (rotation*(math.pi/180))*-1)
cairo_scale (cr, 1/scale, 1/scale)
cairo_translate (cr, hori*-1, vert*-1)
end
--INDICATOR FLOWER
inner=60+output
outer1=60+(output*2)
outer2=(60+(output*2))
outer3=outer1
varth1=0.5
varth2=0.5
for i=1,petals do
cairo_translate (cr, hori, vert)
cairo_scale (cr, scale, scale)
cairo_rotate (cr, (rotation*(math.pi/180)))
cairo_rotate (cr, ((360/petals*(i-1))*(math.pi/180)))
--inner arc from
cairo_move_to (cr, 0, 0)
text_arc=((2*math.pi/(petals*2))*(3))
txs1=0+inner*(math.sin(text_arc))
tys1=0-inner*(math.cos(text_arc))
--outer arc through
text_arc=((2*math.pi/(petals*2))*(3+varth1))
txs2=0+outer1*(math.sin(text_arc))
tys2=0-outer1*(math.cos(text_arc))
--outer arc to
text_arc=((2*math.pi/(petals*2))*(4))
txs3=0+outer2*(math.sin(text_arc))
tys3=0-outer2*(math.cos(text_arc))
cairo_move_to (cr, txs1, tys1)
cairo_curve_to (cr, txs1, tys1, txs2, tys2, txs3, tys3)
--outer arc through
text_arc=((2*math.pi/(petals*2))*(4+varth2))
txs4=0+outer3*(math.sin(text_arc))
tys4=0-outer3*(math.cos(text_arc))
--outer arc to
text_arc=((2*math.pi/(petals*2))*(5))
txs5=0+inner*(math.sin(text_arc))
tys5=0-inner*(math.cos(text_arc))
cairo_curve_to (cr, txs3, tys3, txs4, tys4, txs5, tys5)
cairo_line_to (cr,0,0)
pat = cairo_pattern_create_radial (100, 120, 10,
                                   100,  100, 128.0);
cairo_pattern_add_color_stop_rgba (pat, 0, red, green, blue, alpha)
cairo_pattern_add_color_stop_rgba (pat, 1, red*0.7, green*0.7, blue*0.7, alpha)
cairo_set_source (cr, pat)
cairo_fill (cr)
cairo_rotate (cr, ((360/petals*(i-1))*(math.pi/180))*-1)
cairo_rotate (cr, (rotation*(math.pi/180))*-1)
cairo_scale (cr, 1/scale, 1/scale)
cairo_translate (cr, hori*-1, vert*-1)
end
--draw center circle
cairo_translate (cr, hori, vert)
cairo_scale (cr, scale, scale)
circrad=60
circx=0
circy=0
cairo_move_to (cr, 100, 100);
cairo_arc(cr,circx,circy,circrad,0,2*math.pi)
cairo_close_path(cr)
cairo_set_source_rgba (cr, 1, 1, 0, 1);
cairo_fill (cr);
cairo_scale (cr, 1/scale, 1/scale)
cairo_translate (cr, -hori, -vert)

--draw hearts delete or comment out this part to remove the hearts
scale=0.75
xpos=hori
ypos=vert+200
--cairo_set_source_rgba (cr, 255/255, 100/255, 130/255, 1)
cairo_translate (cr, xpos, ypos)
cairo_translate (cr, 200*scale*-1, 150*scale*-1);
cairo_move_to (cr, 200*scale, 150*scale);
--top right bump
cairo_curve_to (cr, 210*scale, 100*scale, 290*scale, 90*scale, 300*scale, 160*scale);
--right side
cairo_curve_to (cr, 300*scale, 160*scale, 320*scale, 270*scale, 200*scale, 320*scale);
--left side
cairo_curve_to (cr, 200*scale, 320*scale, 80*scale, 270*scale, 100*scale, 160*scale);
--left bump
cairo_curve_to (cr, 110*scale, 100*scale, 190*scale, 90*scale, 200*scale, 160*scale);
pat = cairo_pattern_create_radial (150*scale, 160*scale, 10*scale,
                                   150*scale,  160*scale, 128*scale);
cairo_pattern_add_color_stop_rgba (pat, 0, red, green, blue, alpha)
cairo_pattern_add_color_stop_rgba (pat, 1, red*0.7, green*0.7, blue*0.7, alpha)
cairo_set_source (cr, pat)
cairo_close_path (cr);
cairo_fill (cr)
cairo_translate (cr, 200*scale, 150*scale)
cairo_translate (cr, -xpos, -ypos)

end

function conky_draw_flower()
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num > 5 then
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)

output=tonumber(conky_parse('${fs_used_perc /}'))
hori=210
vert=200
scale=0.4
rotation=0
red, green, blue, alpha=241/255,39/255,167/255,1
petals=5
--for flat opaque background enter 1
background=1
bgred=0.9
bggreen=0.7
bgblue=0.7
flower (output, hori, vert, scale, rotation, red, green, blue, alpha, petals)
circlewriting(cr, "FILESYSTEM USED", "Teenage Fantasy Romance Novel", 22, 110, hori, vert, red, green, blue, alpha, 270, 390, 0)

output=tonumber(conky_parse('${cpu}'))
hori=425
vert=200
scale=0.4
rotation=0
red, green, blue, alpha=241/255,39/255,115/255,1
petals=7
--for flat opaque background enter 1
background=1
bgred=0.9
bggreen=0.7
bgblue=0.7
flower (output, hori, vert, scale, rotation, red, green, blue, alpha, petals)
circlewriting(cr, "CENTRAL PROCESSOR", "Teenage Fantasy Romance Novel", 22, 110, hori, vert, red, green, blue, alpha, 300, 420, -0.05)

output=tonumber(conky_parse('${memperc}'))
hori=640
vert=200
scale=0.4
rotation=0
red, green, blue, alpha=243/255,39/255,40/255,1
petals=6
--for flat opaque background enter 1
background=1
bgred=0.9
bggreen=0.7
bgblue=0.7
flower (output, hori, vert, scale, rotation, red, green, blue, alpha, petals, background, bgred, bggreen, bgblue)
circlewriting(cr, "RANDOM ACCESS MEMORY", "Teenage Fantasy Romance Novel", 22, 110, hori, vert, red, green, blue, alpha, 320, 440, 0)
end
end

Last edited by mrpeachy (2010-02-27 16:47:02)

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

915

Re: My Conky Config

http://omploader.org/vM29tNw/conky-db.png

This is my attempt to create a simple and useful conky display. I removed as much as possible to try and improve the "information-to-ink" ratio that people like Edward Tufte talk about. I want to be able to glance quickly at it to get what I need: and idea of whether there is something going wrong that needs attention. If the bars and graphs are small on the screen, they are generally OK. As more resources get committed to tasks, the amount of white ink increases -- which is a signal to me to investigate. But if things are OK, then I don't want it to grab my attention. A useful analogy from the message board linked above: Imagine a boss walking down a hallway with glass walls where his employees work in offices on the other side of the glass. As he walks, he glances into each office. If he can see complex pictures or alot of activity going on from his distant viewpoint, he knows he should go in and ask the employee what is happening.

in other words: the display should be small -- and even boring -- until it needs my attention.

What's new about this?

1. Exponential moving averages
I wanted something slightly different from the standard conky timeseries graphs for showing trends in resource usage. While those standard ones show good detail over recent time, they aren't able to show long-term trends. So I created a lua script to keep track of both short-term and long-term moving averages. I'm using it to plot a set of 5 averages each for CPU, network up, network down. That allows me to compare 15 time-ordered numbers with a quick glance and see activity on a scale from 2 seconds to 1 hour.

The script is copied into this message below. This is my first lua script and my first experience with conky, and so it probably contains some silly workarounds for things I couldn't find in lua and conky. It's based on general purpose functions, so if other people want to track moving averages of other quantities over other time ranges, they should be able to use this script with minimal modifications.

2. drawing vertical bars without cairo
I'm running crunchbang 9.04, and from what I can see, the most recent version of conky in the repositories is v.1.7.1.1. This means I don't have access to cairo (unless I upgrade manually). So I used the $hr element along with $alignr and $voffset to draw the vertical bars.

3. checking on a specific user's activity
Backup processes run daily on my system and sometimes run at inconvenient times - stealing resources from me while I'm working, so I included a check to see if that process is running. If it is, it tells me for how long it's been running - so that I can know whether it's a good idea to postpone it or to let it finish.

4. workaround for mpd status and non-smartness
I read elsewhere that the conky option for $if_mpd_playing was broken in v.1.7.1 so I put together an equivalent function. Also I didn't like how the $mpd_smart handled the names of internet radio stations, so I wrapped it in a function to see if there was an $mpd_name available instead.

comments and suggestions welcome! Thanks to all the good posts here that helped me get this done.

Dan

ps- does anyone know how to get conky to correctly display exotic UTF characters from mpd song names ?

conky.rc :

background yes
use_xft yes
xftfont Free Sans:size=9
xftalpha 1
update_interval 2.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_type desktop
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 150 200
maximum_width 200
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_shade_color black
default_outline_color white
alignment top_right
gap_x 15
gap_y 15
no_buffers yes
uppercase no
cpu_avg_samples 1
net_avg_samples 1
override_utf8_locale no
lua_load scripts/conky_db.lua

# colors for vertical bar graphs
color1 ffffff
color2 cccccc
color3 999999
color4 666666
color5 333333
color6 000000

##############################################
#  Output
##############################################
TEXT
SYSTEM${offset 10}${hr 2}
RAM:$alignr$mem  ${membar 10,60}
Swap:$alignr$swap  ${swapbar 10,60}
Disk:$alignr${fs_used /home}  ${fs_bar 10,60 /home}
CPU:${alignr 45}${lua_read_parse update_state_cpu ${cpu cpu0}}${lua display_current_state_cpu}%${lua_parse display_vbars_cpu 10 45 100}
${if_existing /proc/net/route eth0}Net up:${lua update_state_eth0_up}${alignr 45}${lua display_current_state_eth0_up 1}kB${lua_parse display_vbars_eth0_up 10 45 100}
Net down:${lua update_state_eth0_down}${alignr 45}${lua display_current_state_eth0_down 1}kB${lua_parse display_vbars_eth0_down -10 45 160}
${endif}Backup:$alignr 3:12:55
Music: ${alignr}${if_match "${mpd_status}" != "Stopped"}${if_empty $mpd_name}${mpd_smart 50}${else}${mpd_name}${endif}${else} ${endif}

scripts/conky_db.lua :

-- System resource usage
-- exponentially decaying moving averages
-- developed for conky version 1.7.1.1 (requires lua, but does not require cairo)

-- dbro, 2010

-- Especially intended to track cpu0, eth0, wlan0 usage over time.

-- Goal is to provide an easy-to-interpret and rich answer to the 
-- questions:
--   * How much activity is there now?
--   * And how does this compare with recent and long-term history?
-- Comparing across different time scales (1-second, 1-hour, 1-day) is
-- difficult with common linear scale time series charts. This program
-- enables tracking arbitrary time scales and visual comparison.
-- As an example, I use it to see gauge activity of my CPU and network
-- over the very recent time (2 seconds) and very long time (1 hour) which
-- alerts me to recent short-term variance and long-term trends.

-- The code contains convenient aliases for use in tracking common
-- variables: cpu, eth0, wlan0. It can be used to track moving averages
-- of any variable instead (with minimal modification).

-- WHAT IS AN EXPONENTIAL MOVING AVERAGE?
-- see also http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
-- X(t) = moving average with exponential decay at time t
-- number of periods to average over = n, current measurement = c:
-- X(t) = X(t-1)*(n-1)/n + c*(1/n)
-- Note that this is done differently (not correctly) in linux kernel
-- when calculating system load averages. Short-term averages are most
-- affected by this difference. The kernel's method is this:
-- X(t) = X(t-1)*e^(-1/n) + c*(1 - e^(-1/n))

-- EXPONENTIAL DECAY PARAMETERS --
-- these values should be integers >= 0
-- they will be sorted to be in order from largest to smallest for display
-- eg for 1s, 10s, 1m, 10m, 1h averages, use:
-- local time_factors_seconds = {3600,600,60,10,1}
local update_frequency = 2 -- seconds per update (should match conky's settings)
local time_factors_seconds = {3600,600,60,10,1}

-- REQUIREMENTS!! --
-- The vbar drawing routine uses the colors defined in the .conkyrc file 
-- to assign colors to each average when drawing the vbars. The most 
-- recent average will use color1, and the largest time period will 
-- use colorN where N is the number of (valid) items in the 
-- time_factors_seconds table above.
-- Also make sure you put this line in .conkyrc:
--   lua_load path_to_this_script/this_script_name.lua

-- USAGE EXAMPLES
-- This is a two-step process:
-- 1) First, the state must be updated. This should be done only once per
--    conky update cycle.
-- 2) Then the state can be read. This can happen in various ways and 
--    done zero or more times per conky update cycle.
-- As a convenience, there are wrapper functions for common variables 
-- (cpu, eth0, wlan0). It is possible to use the underlying functions
-- to track any variable, but we won't describe how to do that in these
-- instructions.
-- CPU isage example --
-- To update the cpu usage averages, we use conky's built-in $cpu object:
--   ${lua_read_parse update_state_cpu ${cpu cpu0}}
-- Then to read the most current state:
--   ${lua display_current_state_cpu}
-- And to create a vertical bar chart showing all of the exponential
-- averages, with a height of 10 and width of 45, and a maximum value
-- that will be at least 100:
--   ${lua_parse display_vbars_cpu 10 45 100}
-- Network throughput example --
-- To update a set of network throughput averages representing
-- the eth0 interface's upload activity, we use this function:
--   ${lua update_state_eth0_up}
-- Then to read the most current state, displaying the number of kB per
-- second with 1 digit of precision after the decimal:
--   ${lua display_current_state_eth0_up 1}
-- And to create a vertical bar chart showing all of the exponential
-- averages, with a height of 10 and width of 45, and a maximum value
-- that will be at least 100:
--   ${lua_parse display_vbars_eth0_up 10 45 100}
-- Note that the third parameter is accurately described as a "minimum
-- maximum value", and if any of the moving averages are greater than
-- that parameter, the entire chart will be re-scaled to use the actual
-- maximum instead of the parameter given here.
-- For plotting download activity, the vbars routine can produce
-- a plot that shows values as going downward from the top of the chart.
-- To use this mode, supply a negative value for the height, ie:
--   ${lua_parse display_vbars_eth0_down -10 45 170}

-- PREFERRED FUNCTION CALLS
-- When calling from conky, we suggest using these functions to interact
-- with this libaray. It is possible to get to the data more directly
-- using other functions, but these are the intended interface.

-- ${lua_read_parse update_state_cpu ${cpu cpu0}}
-- ${lua display_current_state_cpu}
-- ${lua_parse display_vbars_cpu height width minmax}

-- ${lua update_state_eth0_up}
-- ${lua display_current_state_eth0_up precision}
-- ${lua_parse display_vbars_eth0_up height width minmax}

-- ${lua update_state_eth0_down}
-- ${lua display_current_state_eth0_down precision}
-- ${lua_parse display_vbars_eth0_down height width minmax}

-- ${lua update_state_wlan0_up}
-- ${lua display_current_state_wlan0_up precision}
-- ${lua_parse display_vbars_wlan0_up height width minmax}

-- ${lua update_state_wlan0_down}
-- ${lua display_current_state_wlan0_down precision}
-- ${lua_parse display_vbars_wlan0_down height width minmax}

-- TODO:
-- add reset state function. Use when network gets re/dis-connected to remove old data.

------------------------------------------------------------------------
-- HELPER FUNCTIONS --

function round(x)
  if x >= 0 then
    return math.floor (x + 0.5)
  end
  return math.ceil (x - 0.5) -- else condition
end
function mymax(a,b)
  if a > b then return a else return b end
end
function map(func, tbl)
  -- iterates over all items
  local newtbl = {}
  for i,v in pairs(tbl) do
    newtbl[i] = func(v)
  end
  return newtbl
end
function imap(func, tbl)
  -- iterates over integer indexed items only
  local newtbl = {}
  for i,v in ipairs(tbl) do
    newtbl[i] = func(v)
  end
  return newtbl
end
function filter(func, tbl)
  -- iterates over all items
  local newtbl= {}
  for i,v in pairs(tbl) do
    if func(v) then
      newtbl[i]=v
    end
  end
  return newtbl
end
function foldr(func, val, tbl)
  -- iterates over all items
  for i,v in pairs(tbl) do
    val = func(val, v)
  end
  return val
end
function ifoldr(func, val, tbl)
  -- iterates over integer indexed items only
  for i,v in ipairs(tbl) do
    val = func(val, v)
  end
  return val
end
function itablesize(tbl)
  -- counts integer indexed items only
  return ifoldr(function(a,b) return a+1 end, 0, tbl)
end

function os.capture(cmd, raw)
  local f = assert(io.popen(cmd, 'r'))
  local s = assert(f:read('*a'))
  f:close()
  if raw then return s end
  s = string.gsub(s, '^%s+', '')
  s = string.gsub(s, '%s+$', '')
  s = string.gsub(s, '[\n\r]+', ' ')
  return s
end

------------------------------------------------------------------------
-- GLOBAL VARIABLES

-- input parameter validation
-- create a cleaned up version of time_factors_seconds, expressed in
-- terms of periods per average, and sorted correctly
local time_factors = map(function(x) return math.ceil(x/update_frequency) end,time_factors_seconds)
time_factors = filter(function(x) return x>0 end,time_factors)
table.sort(time_factors, function(a,b) return a>b end) -- sort descending

-- derived constants, cached for easy reuse
local tsize = #time_factors
local max_time_factor = time_factors[1]
local damp = map(function (x) return 1/x end, time_factors)
local damp_comp = map(function (x) return 1-x end, damp)

-- our state table, which holds a set of states for each name.
-- Each set has a state for every time_factor
local state = {}

------------------------------------------------------------------------
-- FUNCTIONS

function get_or_initialize_state(name)
  -- create an empty state for this name if it's new
  if (not state[name]) then
    state[name] = map(function(x) return 0 end, time_factors)
    state[name]["count"] = 0 -- counts how many items we've seen so far
  end
  return state[name]
end

function conky_update_state(name, value)
  local this_state = get_or_initialize_state(name)
  -- increment the counter if we are still working with incomplete data
  if this_state["count"] < max_time_factor then
    this_state["count"] = this_state["count"] + 1
  end
  for i,v in ipairs(this_state) do -- ipairs() should not affect the "count" record
    this_state[i] = value*damp[i] + v*damp_comp[i]
  end
  return ""
end

function conky_update_state_cpu(value)
  local answer = conky_update_state("cpu", value)
  return answer
end

function conky_update_state_net(iface, up)
  -- iface should be a string, eg "eth0" or "wlan0"
  -- up is optional. if provided, return uploads; if absent, return downloads
  local name = iface .. "_down" -- default for download
  local fieldnum = "3" -- default for download
  if up then
    name = iface .. "_up"
    fieldnum = "11"
  end
  local current = tonumber(os.capture("cat /proc/net/dev | grep " .. iface .. " | awk -F'[: ]+' '{print $" .. fieldnum .. "}'"))
  local this_state = get_or_initialize_state(name)
  if (not this_state["previous"]) or (this_state["previous"] > current) then
    -- this is the first measurement or we just overflowed the accumulator
    this_state["previous"] = current
  end
  local value = (current - this_state["previous"]) / (2 * 1024) -- 2 seconds per interval, 1024 bytes per kB
  conky_update_state(name, value)
  this_state["previous"] = current
  return ""
end

function conky_update_state_eth0_up() conky_update_state_net("eth0", true) return "" end
function conky_update_state_eth0_down() conky_update_state_net("eth0") return "" end
function conky_update_state_wlan0_up() conky_update_state_net("wlan0", true) return "" end
function conky_update_state_wlan0_down() conky_update_state_net("wlan0") return "" end

function conky_display_states_raw(name, precision)
  -- precision is an optional whole number, eg 0, 1, 2, ...
  local this_state = get_or_initialize_state(name)
  local prec = tonumber(precision) or 0
  return string.format("%." .. prec .. "0f : ",this_state["count"]) .. table.concat(imap(function(x) return string.format("%.1f",x) end, this_state), ", ")
end

function conky_display_state_raw_item(name, index, precision)
  -- precision is an optional whole number, eg 0, 1, 2, ...
  local this_state = get_or_initialize_state(name)
  local prec = tonumber(precision) or 0
  return string.format("%." .. prec .. "f",this_state[tonumber(index)])
end

function conky_display_current_state_cpu(precision)
  return conky_display_state_raw_item("cpu", tsize, precision)
end
function conky_display_current_state_eth0_up(precision)
  return conky_display_state_raw_item("eth0_up", tsize, precision)
end
function conky_display_current_state_eth0_down(precision)
  return conky_display_state_raw_item("eth0_down", tsize, precision)
end
function conky_display_current_state_wlan0_up(precision)
  return conky_display_state_raw_item("wlan0_up", tsize, precision)
end
function conky_display_current_state_wlan0_down(precision)
  return conky_display_state_raw_item("wlan0_down", tsize, precision)
end

function conky_display_state_vbars(name, height, width, minmaxvalue)
  -- this routine does not work properly with negative values,
  -- so make sure that all state values are >= 0
  local mirrorfactor = 1
  local row_voffset = 2
  local maxheight = height
  if tonumber(height) < 0 then
    -- we will plot in negative space, drawing the bars downward from the top
    mirrorfactor = -1
    row_voffset = 2 + height
    maxheight = -1 * height
  end
  local this_state = get_or_initialize_state(name)
  local count = this_state["count"]
  --~ -- Test data set
  --~ local this_state = {10, 30, 75, 50,30}
  --~ local count = 2000
  local maxval = ifoldr(mymax, tonumber(minmaxvalue), this_state)
  local incomplete_count = 0
  if count < max_time_factor then 
    incomplete_count = itablesize(filter(
      function(x) return x>count end, time_factors))
  end
  local currentheight = 0
  local voffset = 0 -- keep a running track of the offset
  -- assemble the plotting instructions
  local answer = string.format("${voffset %.0f} ", row_voffset) -- initial voffset
  for i,v in ipairs(this_state) do
    if i > incomplete_count then
      currentheight = 2 * round(maxheight * v / maxval / 2) -- round to the nearest multiple of 2
      answer = answer ..
        string.format("$color%.0f", tsize + 1 - i) .. -- the color for this item
        "${offset -1000}" .. -- reset the cursor to the far left
        string.format("${alignr %.0f}", width * (tsize + 1 - i) / tsize) .. -- width of this item
        string.format("${voffset %.0f}", mirrorfactor * (( -1 * voffset) - (currentheight / 2))) .. -- put the cursor halfway up the item's height
        string.format("${hr %.0f} ", currentheight)     -- height for this item
      voffset =  voffset + ( -1 * voffset) - (currentheight / 2)
    end
  end
  -- lastly, set the color and voffset to normal
  answer = answer .. string.format(" $color${voffset %.0f}$alignr", mirrorfactor * (-1 * voffset) - row_voffset)
  return answer
end

function conky_display_vbars_cpu(height, width, minmaxvalue)
  return conky_display_state_vbars("cpu", height, width, minmaxvalue)
end
function conky_display_vbars_eth0_up(height, width, minmaxvalue)
  return conky_display_state_vbars("eth0_up", height, width, minmaxvalue)
end
function conky_display_vbars_eth0_down(height, width, minmaxvalue)
  return conky_display_state_vbars("eth0_down", height, width, minmaxvalue)
end
function conky_display_vbars_wlan0_up(height, width, minmaxvalue)
  return conky_display_state_vbars("wlan0_up", height, width, minmaxvalue)
end
function conky_display_vbars_wlan0_down(height, width, minmaxvalue)
  return conky_display_state_vbars("wlan0_down", height, width, minmaxvalue)
end

Re: My Conky Config

hi dbro, nice (not so) simple conky smile
for your ps : replace "override_utf8_locale no" by "yes" .

Re: My Conky Config

@ dbro it's pretty simple to add the conky ppa to get the latest releases

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

Re: My Conky Config

@dbro

I really liked your idea of recording usage over a set time period.
But I didn't really understand how you were doing it with your script...
and I didn't understand how your graph output was displaying the information...

so i tried to do what you described myself (or at least what I thought you were describing) using my own logic smile

I got this:
http://omploader.org/tM29xeQ

it shows cpu usage...
current and then averages over the last minute, 5 minutes, 15 minutes and 30 minutes.

here is the code

--[[cpu usage recorded over time by mrpeachy 2010 based on a concept by dbro http://crunchbanglinux.org/forums/post/56845/#p56845]]
require 'cairo'
function bars(sum, hori, vert, width, text)
--BACKGROUND BAR
cairo_translate (cr, hori, vert)
cairo_set_source_rgba (cr, 1, 1, 1, 0.2)
cairo_set_line_width (cr, width)
cairo_move_to (cr, 0, 0)
cairo_rel_line_to (cr, 0, -100)
cairo_stroke (cr)
cairo_translate (cr, -hori, -vert)
--INDICATOR BAR
cairo_translate (cr, hori, vert)
cairo_set_source_rgba (cr, 1, 1, 1, 1)
cairo_set_line_width (cr, width)
cairo_move_to (cr, 0, 0)
cairo_rel_line_to (cr, 0, -sum)
cairo_stroke (cr)
cairo_translate (cr, -hori, -vert)
--TEXT PRINTING
cairo_translate (cr, hori, vert)
cairo_select_font_face (cr, "White Rabbit", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14);
cairo_rotate (cr, 90*math.pi/180)
cairo_move_to (cr, 5, 4)
cairo_show_text (cr, text);
cairo_rotate (cr, -90*math.pi/180)
cairo_translate (cr, -hori, -vert)
end

function conky_draw_graph()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
--INITIALIZING ARRAYS--if changes are made to the below section conky must be killed and restarted
if updates==1 then     
minlength=60
mintable={} 
min5length=(60*5)
min5table={}
min15length=(60*15)
min15table={}
min30length=(60*30)
min30table={}
min60length=(60*60)
min60table={}
end
--END OF INITIALIZATION---------------------------------------------------------
if updates> 3 then
--CALCULATIONS OVER 1 MINUTE----------------------------------------------------
for i = 1, tonumber(minlength) do
if mintable[i+1]==nil then mintable[i+1]=0 end
mintable[i]=mintable[i+1]    
if i==minlength then
mintable[minlength]=tonumber(conky_parse('${cpu}'))
end
end   
--CALCULATE AVERAGE 
sum=0
for i=1,minlength do
if mintable[i]==nil then mintable[i]=0 end
sum=sum+mintable[i]
end
--END OF CALCULATIONS
--call draw function
hori=175
vert=200
width=20
sum=(sum/minlength)
text="01 MIN"
bars(sum, hori, vert, width, text)
--end call----------------------------------------------------------------------
--CALCULATIONS OVER 5 MINUTES---------------------------------------------------
for i = 1, tonumber(min5length) do
if min5table[i+1]==nil then min5table[i+1]=0 end
min5table[i]=min5table[i+1]    
if i==min5length then
min5table[min5length]=tonumber(conky_parse('${cpu}'))
end
end   
--CALCULATE AVERAGE
sum5=0
for i=1,min5length do
if min5table[i]==nil then min5table[i]=0 end
sum5=sum5+min5table[i]
end
--END OF CALCULATIONS
--call draw function
hori=150
vert=200
width=20
sum=(sum5/min5length)
text="05 MIN"
bars(sum, hori, vert, width, text)
--end call----------------------------------------------------------------------
--CALCULATIONS OVER 15 MINUTES--------------------------------------------------
for i = 1, tonumber(min15length) do
if min15table[i+1]==nil then min15table[i+1]=0 end
min15table[i]=min15table[i+1]    
if i==min15length then
min15table[min15length]=tonumber(conky_parse('${cpu}'))
end
end   
--CALCULATE AVERAGE
sum15=0
for i=1,min15length do
if min15table[i]==nil then min15table[i]=0 end
sum15=sum15+min15table[i]
end
--END OF CALCULATIONS
--call draw function
hori=125
vert=200
width=20
sum=(sum15/min15length)
text="15 MIN"
bars(sum, hori, vert, width, text)
--end call----------------------------------------------------------------------
--CALCULATIONS OVER 30 MINUTES--------------------------------------------------
for i = 1, tonumber(min30length) do
if min30table[i+1]==nil then min30table[i+1]=0 end
min30table[i]=min30table[i+1]    
if i==min30length then
min30table[min30length]=tonumber(conky_parse('${cpu}'))
end
end   
--CALCULATE AVERAGE
sum30=0
for i=1,min30length do
if min30table[i]==nil then min30table[i]=0 end
sum30=sum30+min30table[i]
end
--END OF CALCULATIONS
--call draw function
hori=100
vert=200
width=20
sum=(sum30/min30length)
text="30 MIN"
bars(sum, hori, vert, width, text)
--end call----------------------------------------------------------------------
--CALCULATIONS OVER 60 MINUTES--------------------------------------------------
for i = 1, tonumber(min60length) do
if min60table[i+1]==nil then min60table[i+1]=0 end
min60table[i]=min60table[i+1]    
if i==min60length then
min60table[min60length]=tonumber(conky_parse('${cpu}'))
end
end   
--CALCULATE AVERAGE
sum60=0
for i=1,min60length do
if min60table[i]==nil then min60table[i]=0 end
sum60=sum60+min60table[i]
end
--END OF CALCULATIONS
--call draw function
hori=75
vert=200
width=20
sum=(sum60/min60length)
text="60 MIN"
bars(sum, hori, vert, width, text)
--end call----------------------------------------------------------------------

--call draw function for current cpu--------------------------------------------
hori=200
vert=200
width=20
sum=tonumber(conky_parse('${cpu}'))
text="CURRENT"
bars(sum, hori, vert, width, text)
--end call----------------------------------------------------------------------
end
end

it records cpu usage in tables of lengths according to the time frame I want to average, then it sums up all the entries and averages them every cycle...
so until the script has been running for each interval it will appear to be underestimating the average for that interval.
I originally had it so that each interval was only averaged at the end of a cycle the length of the interval... ie the script would run for 5 mins then disply the 5 min average and update every 5 mins, then i realized that this wasn't necessary and i could have "live" averages.  So some things in the script would not make much sense without knowing this smile  like the use of a timer.

After a period of reflection on this script smile I think I can probably reduce the line count and make the whole thing less complicated....
UPDATE - which is what I have done above

Last edited by mrpeachy (2010-02-28 03:41:10)

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

919

Re: My Conky Config

MrPeachy- Those are nice looking bars.

The exponentially decaying average may be simpler than your algorithm: less space, fewer operations to update and calculate it. Here's a quick example: to maintain the e.d.average over a 3 period range with the first 4 periods of data = {4,2,0,6}, these would be the calculations:

We need to keep track of only 2 numbers: the number of measurements collected so far and the current average.
Start with the pair (0, 0.0). Your first measurement is 4, and you are working with a 3-period average. So your state will be updated like this:
average @ time=1: (0.0 * 2/3) + (4 * 1/3) = 4/3 = 1.333  (but we've only got 1 measurement, so it's an incomplete average and shouldn't be used)
then continue:
average @ time=2: (1.333 * 2/3) + (2 * 1/3) = 14/9 = 1.555 (still incomplete because we've only seen 2 measurements)
average @ time=3: (1.555 * 2/3) + (0 * 1/3) = 1.037 (this is the first average that is based on 3 measurements, so we can use it. Note that it's not the same as the simple average of (4+2+0)/3 = 2.00, because it puts more weight on recent values. continuing:
average @ time=4: (1.037 * 2/3) + (6 * 1/3) =  2.691

the 2/3 comes from the number of periods per average. it's (n-1)/n. and the 1/3 is just 1/n


At first I didn't like the way the graph output appeared -- it doesn't separate the bars cleanly. This was the only way I could see to do it because the hr element draws a bar from the current position to the far right of the conky window. But now that I have seen it for a few days, I think it makes sense: it will show the longer-term averages as underneath and spanning the recent ones, as it overlaps those time periods, too. And the greying out is a cue that the data that is more grey (less vivid) is older.

Re: My Conky Config

@dbro
that exponentially decaying average method you describe makes sense and it would certainly make the script run lighter
i did say that I used my own logic smile

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

921

Re: My Conky Config

has anyone here seen this? (yes I stole the graphic from it)

It is an amazing bit of work by sen7 (link)

http://th03.deviantart.net/fs70/300W/i/2010/023/d/7/Conky___NightDrive_by_sen7.png

I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Re: My Conky Config

tawan wrote:

has anyone here seen this? (yes I stole the graphic from it)

It is an amazing bit of work by sen7 (link)

I agree smile

Ive been working on some more isometric drawing functions...

here is the cpu recording function from above represented with the new function.
the darker bars are all small because the conky hasn't been running for very long.

I need to add titles and make the whole thing more configurable
http://omploader.org/tM3BiMA
working out all of the mathematics to get the perspectives right was the hard part... my math skills suck!

code later unless anyone really wants to see it

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

923

Re: My Conky Config

Mr Peachy, don't worry if this is hard.. but if it is easy can you help?

I want to list the latest jobs from this site in a conky (save refreshing the page all the time)

I was looking at your past examples of curl but I can't get it to work..

If it is tricky, forget it, it is not really important smile

I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Re: My Conky Config

tawan wrote:

Mr Peachy, don't worry if this is hard.. but if it is easy can you help?

I want to list the latest jobs from this site in a conky (save refreshing the page all the time)

I was looking at your past examples of curl but I can't get it to work..

If it is tricky, forget it, it is not really important smile

it can be tricky, depending on the site... pulling out the info relies on the line that has the information having something that distinguishes it from the lines you don't want (or at least the method i have used before does)

i took a look at the source code for that site and it seems that this is the case...
you want a list of the "top ads" i assume?
and it could be possible to get the descriptions too

i'll have to see how rusty my curl/grep/awk/sed skills have gotten smile

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

925

Re: My Conky Config

@tawan
i would go for the rss feed http://sydney.gumtree.com.au/f-SearchAd … on=3000001

then either use conkys built in rss function or grab a script, theres quite a few around, you could even write your own, i believe python comes with an rss module.

- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts