Code:
--conky setup by mrpeachy April 2011
--[[
call in conky rc (above text)
top_name_width 5 --needed for processes to fit
lua_load /path to file/display.lua
lua_draw_hook_pre draw_fig
]]
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 round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function max(a)
local mi = 1 --index of max value
local m = a[mi] --max value
for i, val in ipairs(a) do --can use pairs() as well, ipairs() indicates an array-like table
if val > m then
mi = i
m = val
end
end
return m, mi --neat feature of lua, can return multiple values
end
function dnumg(s)
str=string.gsub(s,"[ /%a]","")
return str
end
function dunit(s)
str=string.gsub(s,"[%d%p ]","")
return str
end
--------------------------------------------------------------------------------
function conky_draw_fig()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
--####################################################################################################
if updates>5 then -- starts the display
--####################################################################################################
--conkyrc text
flx=5;fly=28;lw=11
--add=fly+((line-1)*lw)
--settings
line=0;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="S Y S T E M I N F O",textx=flx,texty=fly};write(pass)
line=line+1;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="UPTIME",textx=flx};write(pass)
uptime=": " .. conky_parse("${uptime}")
pass={line=line,text=uptime,textx=flx+88};write(pass)
line=line+1;pass={line=line,text="MEMORY",textx=flx};write(pass)
memory=": " .. conky_parse("${mem}") .. "/" .. conky_parse("${memmax}")
pass={line=line,text=memory,textx=flx+88};write(pass)
memperc=conky_parse("${memperc}") .. "%"
line=line+1.5;pass={line=line,text=memperc,textx=flx,fsize=18};write(pass)
line=line+0.5;pass={line=line,text="PROCESSES BY MEM:",textx=flx+40};write(pass)
line=line+1;pass={line=line,text="NAME",textx=flx+88};write(pass)
pass={line=line,text="MEM%",textx=flx+135};write(pass)
pass={line=line,text="PID",textx=flx+180};write(pass)
tmn1=conky_parse("${top_mem name 1}")
tmn2=conky_parse("${top_mem name 2}")
tmn3=conky_parse("${top_mem name 3}")
tmm1=conky_parse("${top_mem mem 1}")
tmm2=conky_parse("${top_mem mem 2}")
tmm3=conky_parse("${top_mem mem 3}")
tmp1=conky_parse("${top_mem pid 1}")
tmp2=conky_parse("${top_mem pid 2}")
tmp3=conky_parse("${top_mem pid 3}")
line=line+1;pass={line=line,text=tmn1,textx=flx+88};write(pass)
pass={line=line,text=tmm1,textx=flx+135};write(pass)
pass={line=line,text=tmp1,textx=flx+180};write(pass)
line=line+1;pass={line=line,text=tmn2,textx=flx+88};write(pass)
pass={line=line,text=tmm2,textx=flx+135};write(pass)
pass={line=line,text=tmp2,textx=flx+180};write(pass)
line=line+1;pass={line=line,text=tmn3,textx=flx+88};write(pass)
pass={line=10,text=tmm3,textx=flx+135};write(pass)
pass={line=10,text=tmp3,textx=flx+180};write(pass)
line=line+1;pass={line=line,text="VOLUMES:",textx=flx};write(pass)
line=line+1;pass={line=line,text="ROOT",textx=flx};write(pass)
root=": " .. conky_parse("${fs_used /}") .. "/" .. conky_parse("${fs_size /}")
pass={line=line,text=root,textx=flx+40};write(pass)
line=line+2;pass={line=line,text="HOME",textx=flx};write(pass)
home=": " .. conky_parse("${fs_used /home}") .. "/" .. conky_parse("${fs_size /home}")
pass={line=line,text=home,textx=flx+40};write(pass)
line=line+2;pass={line=line,text="CENTRAL PROCESSOR:",textx=flx};write(pass)
line=line+1;pass={line=line,text="CORE 1",textx=flx+40};write(pass)
core1=": " .. conky_parse("${cpu cpu1}")
pass={line=line,text=core1 .. "%",textx=flx+88};write(pass)
line=line+1;pass={line=line,text="CORE 2",textx=flx+40};write(pass)
core2=": " .. conky_parse("${cpu cpu2}")
pass={line=line,text=core2 .. "%",textx=flx+88};write(pass)
line=line+1;pass={line=line,text="CORE 3",textx=flx+40};write(pass)
core3=": " .. conky_parse("${cpu cpu3}")
pass={line=line,text=core3 .. "%",textx=flx+88};write(pass)
totcpu=conky_parse("${cpu cpu0}") .. "%"
line=line-1;pass={line=line,text=totcpu,textx=flx,fsize=18};write(pass)
line=line+2;pass={line=line,text="PROCESSES BY CPU:",textx=flx+40};write(pass)
line=line+1;pass={line=line,text="NAME",textx=flx+88};write(pass)
pass={line=line,text="CPU%",textx=flx+135};write(pass)
pass={line=line,text="PID",textx=flx+180};write(pass)
tcn1=conky_parse("${top name 1}")
tcn2=conky_parse("${top name 2}")
tcn3=conky_parse("${top name 3}")
tcc1=conky_parse("${top cpu 1}")
tcc2=conky_parse("${top cpu 2}")
tcc3=conky_parse("${top cpu 3}")
tcp1=conky_parse("${top pid 1}")
tcp2=conky_parse("${top pid 2}")
tcp3=conky_parse("${top pid 3}")
line=line+1;pass={line=line,text=tcn1,textx=flx+88};write(pass)
pass={line=line,text=tcc1,textx=flx+135};write(pass)
pass={line=line,text=tcp1,textx=flx+180};write(pass)
line=line+1;pass={line=line,text=tcn2,textx=flx+88};write(pass)
pass={line=line,text=tcc2,textx=flx+135};write(pass)
pass={line=line,text=tcp2,textx=flx+180};write(pass)
line=line+1;pass={line=line,text=tcn3,textx=flx+88};write(pass)
pass={line=line,text=tcc3,textx=flx+135};write(pass)
pass={line=line,text=tcp3,textx=flx+180};write(pass)
line=line+1;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="D A T E A N D T I M E",textx=flx};write(pass)
line=line+1;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="DATE",textx=flx};write(pass)
date=": " .. os.date("%m/%d/%Y")
pass={line=line,text=date,textx=flx+88};write(pass)
line=line+1;pass={line=line,text="TIME",textx=flx};write(pass)
time=": " .. os.date("%H:%M:%S")
pass={line=line,text=time,textx=flx+88};write(pass)
--####################################################################################################
--CALENDAR
--title text color
tred,tgreen,tblue,talpha=1,1,1,1
--title text font
tfont="Acknowledge TT BRK"
--title text size
tfontsize=12
--###################################################
--main body text color
bred,bgreen,bblue,balpha=1,1,1,1
--main body text font
mfont="Acknowledge TT BRK"
--main body text size
mfontsize=12
--###################################################
--highlight text color
hred,hgreen,hblue,halpha=1,1,0,1
--highlight font
hfont="Acknowledge TT BRK"
--highlight size
hfontsize=12
--###################################################
--surrounding numbers (previous and next month) 1=on, 0=off
surround=1
--surrounding dates text color
sred,sgreen,sblue,salpha=0.6,0.6,0.6,1
--surrounding font
sfont="Acknowledge TT BRK"
--surounding size
sfontsize=12
--##################################################
--position
across=50
flx=5;fly=28;lw=11
down=fly+((30-1)*lw)
--###################################################
--horizontal gap between dates
gaph=25
--###################################################
--gap between day titles and first line
gapt=11
--###################################################
--gap between calendar line
gapl=11
--###################################################
--spacer -- this can help with alignment enter 0, 1 space or 2 spaces between the ""
spacer=""
--###################################################
--start day, enter 0 for sunday, 1 for monday
sday=0
--###################################################
--## END OF CALENDAR SETUP ##########################
--###################################################
--calendar calcs
year=os.date("%G")
today=tonumber(os.date("%d"))
t1 = os.time( { year=year,month=03,day=01,hour=00,min=0,sec=0} );
t2 = os.time( { year=year,month=02,day=01,hour=00,min=0,sec=0} );
feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={ 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local day=tonumber(os.date("%w"))+1-sday
local day_num = today
local remainder=day_num % 7
start_day=day-(day_num % 7)
if start_day<0 then start_day=7+start_day end
month=os.date("%m")
mdays=monthdays[tonumber(month)]
mdaystm=mdays
x=mdays+start_day
dnum={}
dnumh={}
if mdays+start_day<36 then
dlen=35
plen=29
else
dlen=42
plen=36
end
for i=1,dlen do
if i<=start_day then dnum[i]=" "
else dn=i-start_day
if dn=="nil" then dn=0 end
if dn<=9 then dn=(spacer .. dn) end
if i>x then dn="" end
dnum[i]=dn
dnumh[i]=dn
if dn==(spacer .. today) or dn==today then
dnum[i]=""
end
if dn==(spacer .. today) or dn==today then
dnumh[i]=dn
place=i
else dnumh[i]=" "
end
end
end--for
--###################################################
--print calendar titles
--###################################################
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
if sday==0 then
dys={"SU","MO","TU","WE","TH","FR","SA"}
else
dys={"MO","TU","WE","TH","FR","SA","SU"}
end
--------------------------------
for i=1,7 do
cairo_move_to (cr, across+(gaph*(i-1)), down)
cairo_show_text (cr, dys[i])
cairo_stroke (cr)
end
cairo_select_font_face (cr, mfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, mfontsize);
cairo_set_source_rgba (cr,bred,bgreen,bblue,balpha)
for i=1,plen,7 do
fn=i
for i=fn,fn+6 do
cairo_move_to (cr, across+(gaph*(i-fn)),down+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, dnum[i])
cairo_stroke (cr)
end
end
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, hfontsize);
cairo_set_source_rgba (cr,hred,hgreen,hblue,halpha)
for i=1,plen,7 do
fn=i
for i=fn,fn+6 do
cairo_move_to (cr, across+(gaph*(i-fn)),down+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, dnumh[i])
cairo_stroke (cr)
end
end
--###############################################################################
if surround==1 then
thisstart=tonumber(start_day)+1
thisend=tonumber(start_day)+mdays
previous=tonumber(start_day)
nextmon=dlen-thisend
pmon=tonumber(month)-1
if pmon==0 then pmon=12 end
pmon=monthdays[pmon]
snum={}
for i=1,dlen do
snum[i]=""
end
for i=tonumber(thisend)+1,tonumber(thisend)+nextmon do
snum[i]=i-tonumber(thisend)
end
for i=1,previous do
snum[i]=pmon-(previous-(i))
end
cairo_select_font_face (cr, sfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, sfontsize);
cairo_set_source_rgba (cr,sred,sgreen,sblue,salpha)
for i=1,plen,7 do
fn=i
for i=fn,fn+6 do
cairo_move_to (cr, across+(gaph*(i-fn)),down+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, snum[i])
cairo_stroke (cr)
end
end
end
--###################################################
--end of calendar
if mdays+start_day<36 then
line=line
else
line=line+1
end
--####################################################################################################
line=line+7;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="N E T W O R K",textx=flx};write(pass)
line=line+1;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="CURRENT ACTIVITY:",textx=flx};write(pass)
line=line+1;pass={line=line,text="UPSPEED",textx=flx+40};write(pass)
upspeed=": " .. conky_parse("${upspeed eth1}")
pass={line=line,text=upspeed,textx=flx+125};write(pass)
line=line+1;pass={line=line,text="UPLOADED",textx=flx+40};write(pass)
uploaded=": " .. conky_parse("${totalup eth1}")
pass={line=line,text=uploaded,textx=flx+125};write(pass)
line=line+3;pass={line=line,text="DOWNSPEED",textx=flx+40};write(pass)
downspeed=": " .. conky_parse("${downspeed eth1}")
pass={line=line,text=downspeed,textx=flx+125};write(pass)
line=line+1;pass={line=line,text="DOWNLOADED",textx=flx+40};write(pass)
downloaded=": " .. conky_parse("${totaldown eth1}")
pass={line=line,text=downloaded,textx=flx+125};write(pass)
line=line+3;pass={line=line,text="NETWORK DATA:",textx=flx};write(pass)
nwtime=os.date("%a %D")
line=line+1;pass={line=line,text=nwtime,textx=flx};write(pass)
nwmnth=os.date("%B")
pass={line=line,text=nwmnth,textx=flx+115};write(pass)
--#################################################
--network info on 1800 timer
nwtimer=(updates %1800)+1
if nwtimer==1 or updates==10 then--update
--daily
lookup=os.date("%D")
local f = io.popen("vnstat -d |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $2}'| sed -e 's/^[ \t]*//'") -- runs command
rxd=f:read("*a") -- read output of command
rxd=string.gsub(rxd,"[\t\n\r]","")
f:close()
local f = io.popen("vnstat -d |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $3}'| sed -e 's/^[ \t]*//'") -- runs command
txd= f:read("*a") -- read output of command
txd=string.gsub(txd,"[\t\n\r]","")
f:close()
local f = io.popen("vnstat -d |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $4}'| sed -e 's/^[ \t]*//'") -- runs command
tld= f:read("*a") -- read output of command
tld=string.gsub(tld,"[\t\n\r]","")
f:close()
local f = io.popen("vnstat -d |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $5}'| sed -e 's/^[ \t]*//'") -- runs command
avd= f:read("*a") -- read output of command
avd=string.gsub(avd,"[\t\n\r]","")
f:close()
--monthly
lookup=os.date("%h")
local f = io.popen("vnstat -m |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $2}'| sed -e 's/^[ \t]*//'") -- runs command
rxm= f:read("*a") -- read output of command
rxm=string.gsub(rxm,"[\t\n\r]","")
f:close()
local f = io.popen("vnstat -m |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $3}'| sed -e 's/^[ \t]*//'") -- runs command
txm= f:read("*a") -- read output of command
txm=string.gsub(txm,"[\t\n\r]","")
f:close()
local f = io.popen("vnstat -m |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $4}'| sed -e 's/^[ \t]*//'") -- runs command
tlm= f:read("*a") -- read output of command
tlm=string.gsub(tlm,"[\t\n\r]","")
f:close()
local f = io.popen("vnstat -m |grep '" .. lookup .. "' | awk -F'" .. lookup .. "' '{print $2}' |awk -F'|' '{print $5}'| sed -e 's/^[ \t]*//'") -- runs command
avm= f:read("*a") -- read output of command
avm=string.gsub(avm,"[\t\n\r]","")
f:close()
end
--#################################################
line=line+1;pass={line=line,text="RX:",textx=flx};write(pass)
pass={line=line,text="RX:",textx=flx+115};write(pass)
pass={line=line,text=rxd,textx=flx+25};write(pass)
pass={line=line,text=rxm,textx=flx+140};write(pass)
line=line+1;pass={line=line,text="TX:",textx=flx};write(pass)
pass={line=line,text="TX:",textx=flx+115};write(pass)
pass={line=line,text=txd,textx=flx+25};write(pass)
pass={line=line,text=txm,textx=flx+140};write(pass)
line=line+1;pass={line=line,text="TL:",textx=flx};write(pass)
pass={line=line,text="TL:",textx=flx+115};write(pass)
pass={line=line,text=tld,textx=flx+25};write(pass)
pass={line=line,text=tlm,textx=flx+140};write(pass)
line=line+1;pass={line=line,text="AV:",textx=flx};write(pass)
pass={line=line,text="AV:",textx=flx+115};write(pass)
pass={line=line,text=avd,textx=flx+25};write(pass)
pass={line=line,text=avm,textx=flx+140};write(pass)
line=line+1.5;pass={line=line,text="30 DAY RX",textx=flx};write(pass)
pass={line=line,text="30 DAY TX",textx=flx+110};write(pass)
--####################################################################################################
--vnstat graphs
timer1=(updates % 1800)+1
if timer1==1 or updates==8 then
local f = io.popen("vnstat -d | grep '|' | tail -n 31 | sed ':a;N;$!ba;s/\\n/ /g' | sed -e 's/estimated/| |/' -e 's/--//g' -e 's/ //g'") -- runs command
vnday=f:read("*a") -- read output of command
f:close()
print (vnday)
vnday=string.split(vnday, "|")
lvntab=#vnday-1
for i=1,lvntab do
if vnday[i]=="" then vnday[i]="1nodata" end
--print (vnday[i])
end
if dunit(vnday[6+4])=="KiB" then
end
vnday30rx={}
for i=0,(lvntab/9) do
if vnday[5+(i*4)]=="nil" then vnday[5+(i*4)]="1nodata" end
if dunit(vnday[5+(i*4)])=="GiB" then
vnday30rx[i]=tonumber(dnumg(vnday[5+(i*4)]))*1024
end
if dunit(vnday[5+(i*4)])=="KiB" then
vnday30rx[i]=tonumber(dnumg(vnday[5+(i*4)]))/1024
end
if dunit(vnday[5+(i*4)])=="MiB" then
vnday30rx[i]=tonumber(dnumg(vnday[5+(i*4)]))
end--if
end--for
vnday30tx={}
for i=1,(lvntab/9) do
if vnday[6+(i*4)]=="nil" then vnday[6+(i*4)]="1nodata" end
if tostring(dunit(vnday[6+(i*4)]))=="GiB" then
vnday30tx[i]=tonumber(dnumg(vnday[6+(i*4)]))*1024
end
if tostring(dunit(vnday[6+(i*4)]))=="KiB" then
vnday30tx[i]=tonumber(dnumg(vnday[6+(i*4)]))/1024
end
if tostring(dunit(vnday[6+(i*4)]))=="MiB" then
vnday30tx[i]=tonumber(dnumg(vnday[6+(i*4)]))
end--if
end--for
end--timer
--###############################################################################
--rx----------------------------------------------------
--graph position
acrossx=6.5
flx=5;fly=28;lw=11
downy=(fly+((line+5)*lw))+0.5
gheight=55
--calculate table height----------------------------
heightm,position=max(vnday30rx)
ht=string.split(heightm, "%p")
ht=string.gsub(ht[1],"^.","")
htl=string.len(ht)
add=10^(htl-1)
addn=add
while heightm>add do
add=add+addn
end--while
heightm=(add)
----------------------------------------------------
cairo_set_line_width (cr,1)
height=(gheight/(heightm/100))
across=acrossx
down=downy
for i=1,31 do
cairo_set_source_rgba (cr,1,1,1,1)
adjust=2.5
if vnday30rx[i]==nil then vnday30rx[i]=0 end
if vnday30rx[i+1]==nil then vnday30rx[i+1]=0 end
idata=(vnday30rx[i]/100)*height
iplus=(vnday30rx[i+1]/100)*height
--if iplus==0 then cairo_set_source_rgba (cr,1,1,1,0) end
cairo_move_to (cr,(across+(31*adjust))-(i*adjust),down-idata)
cairo_line_to (cr,(across+(31*adjust))-((i+1)*adjust),down-iplus)
cairo_stroke (cr)
heightrx=gheight
end--for
font="Acknowledge TT BRK"
fontsize=12
tadjrx=-30*adjust-5
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fontsize);
cairo_move_to (cr,across-tadjrx,down-((heightrx/4)*0))
cairo_show_text (cr, "0 M")
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heightrx/4)*1))
cairo_show_text (cr, round((heightm/4)*1,2))
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heightrx/4)*2))
cairo_show_text (cr, round((heightm/4)*2,2))
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heightrx/4)*3))
cairo_show_text (cr, round((heightm/4)*3,2))
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heightrx/4)*4))
cairo_show_text (cr, heightm)
cairo_stroke (cr)
--x axis label
across=across--6
downs=down+10
cairo_move_to (cr,across,downs)
cairo_show_text (cr, "30")
cairo_stroke (cr)
add=adjust*10
cairo_move_to (cr,across+add,downs)
cairo_show_text (cr, "20")
cairo_stroke (cr)
add=add+adjust*10
cairo_move_to (cr,across+add,downs)
cairo_show_text (cr, "10")
cairo_stroke (cr)
add=add+adjust*10
cairo_move_to (cr,across+add+2,downs)
cairo_show_text (cr, "0")
cairo_stroke (cr)
--tx-------------------------------------------------------------------------
--graph position
acrossx=115.5
flx=5;fly=28;lw=11
downy=(fly+((line+5)*lw))+0.5
gheight=55
--calculate table height----------------------------
heightm,position=max(vnday30tx)
ht=string.split(heightm, "%p")
ht=string.gsub(ht[1],"^.","")
htl=string.len(ht)
add=10^(htl-1)
addn=add
while heightm>add do
add=add+addn
end--while
heightm=(add)
----------------------------------------------------
height=(gheight/(heightm/100))
adjust=2.5
across=acrossx
down=downy
for i=1,31 do
cairo_set_source_rgba (cr,1,1,1,1)
if vnday30tx[i]==nil then vnday30tx[i]=0 end
if vnday30tx[i+1]==nil then vnday30tx[i+1]=0 end
idata=(vnday30tx[i]/100)*height
iplus=(vnday30tx[i+1]/100)*height
cairo_move_to (cr,(across+(31*adjust))-(i*adjust),down-idata)
cairo_line_to (cr,(across+(31*adjust))-((i+1)*adjust),down-iplus)
cairo_stroke (cr)
heighttx=gheight
end--for
font="Acknowledge TT BRK"
fontsize=12
tadjrx=-30*adjust-5
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fontsize);
cairo_move_to (cr,across-tadjrx,down-((heighttx/4)*0))
cairo_show_text (cr, "0 M")
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heighttx/4)*1))
cairo_show_text (cr, round((heightm/4)*1,2))
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heighttx/4)*2))
cairo_show_text (cr, round((heightm/4)*2,2))
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heighttx/4)*3))
cairo_show_text (cr, round((heightm/4)*3,2))
cairo_stroke (cr)
cairo_move_to (cr,across-tadjrx,down-((heighttx/4)*4))
cairo_show_text (cr, heightm)
cairo_stroke (cr)
--x axis label
across=across--6
downs=down+10
cairo_move_to (cr,across,downs)
cairo_show_text (cr, "30")
cairo_stroke (cr)
add=adjust*10
cairo_move_to (cr,across+add,downs)
cairo_show_text (cr, "20")
cairo_stroke (cr)
add=add+adjust*10
cairo_move_to (cr,across+add,downs)
cairo_show_text (cr, "10")
cairo_stroke (cr)
add=add+adjust*10
cairo_move_to (cr,across+add+2,downs)
cairo_show_text (cr, "0")
cairo_stroke (cr)
--end of vnstat graphs
--####################################################################################################
line=line+8.5;pass={line=line,hr=1};write(pass)
line=line+1;pass={line=line,text="W E A T H E R",textx=flx};write(pass)
line=line+1;pass={line=line,hr=1};write(pass)
--weather data
--reads KSDK website and extracts current weather conditions-------------------------------------------
timerw=(updates %1800)+1
if timerw==1 or updates==8 then
local f = io.popen("curl -L 'http://www.ksdk.com/weather/default.aspx' | grep -A37 '<h3>CURRENT CONDITIONS</h3>'")
data1= f:read("*a")
f:close()
local f = io.popen("echo '" .. data1 .. "' | gawk -F'>' -v RS='<' 'RT{print $NF}' | sed -e '/^[ \r]*$/d' -e 's/°/°/g' -e 's/%/%/g'")
data= f:read("*a")
data=string.split(data,"\n")
f:close()
end
line=line+1;pass={line=line,text=data[2],textx=flx};write(pass)
line=line+1;pass={line=line,text="CONDITIONS: " .. data[5],textx=flx};write(pass)
line=line+1;pass={line=line,text="TEMP: " .. data[3] .. data[4],textx=flx};write(pass)
line=line+1;pass={line=line,text=data[6] .. " " .. data[7],textx=flx};write(pass)
line=line+1;pass={line=line,text=data[8] .. " " .. data[9],textx=flx};write(pass)
line=line+1;pass={line=line,text=data[10] .. " " .. data[11],textx=flx};write(pass)
line=line+2;pass={line=line,text="FORECAST",textx=flx};write(pass)
line=line+1;pass={line=line,text=data[12],textx=flx};write(pass)
pass={line=line,text=data[14],textx=flx+65};write(pass)
pass={line=line,text=data[16],textx=flx+125};write(pass)
line=line+1;pass={line=line,text=data[13],textx=flx};write(pass)
pass={line=line,text=data[15],textx=flx+65};write(pass)
pass={line=line,text=data[17],textx=flx+125};write(pass)
--#################################################################################
--bars -- bnum,barx,bary,bhigh,blong,bout
flx=5;fly=28;lw=11
---------------------
memperc=conky_parse("${memperc}");add=fly+((4)*lw)
pass={bnum=memperc,barx=flx+40,bary=add,bhigh=6,blong=173,bout=1};bar(pass)
rootbar=tonumber(conky_parse("${fs_used_perc /}"));add=fly+((12)*lw)
pass={bnum=rootbar,barx=flx,bary=add,bhigh=6,blong=150,bout=1};bar(pass)
homebar=tonumber(conky_parse("${fs_used_perc /home}"));add=fly+((14)*lw)
pass={bnum=rootbar,barx=flx,bary=add,bhigh=6,blong=150,bout=1};bar(pass)
core1=tonumber(conky_parse("${cpu cpu1}"));add=fly+((16)*lw)
pass={bnum=core1,barx=flx+130,bary=add,bhigh=6,blong=82,bout=1};bar(pass)
core2=tonumber(conky_parse("${cpu cpu2}"));add=fly+((17)*lw)
pass={bnum=core2,barx=flx+130,bary=add,bhigh=6,blong=82,bout=1};bar(pass)
core3=tonumber(conky_parse("${cpu cpu3}"));add=fly+((18)*lw)
pass={bnum=core3,barx=flx+130,bary=add,bhigh=6,blong=82,bout=1};bar(pass)
end--end if 5
end--end main function
function write(t)
flx=5;fly=28;lw=11
local line=t.line
add=fly+((line-1)*lw)
--set default font,fsize and face
if t.textx==nil then textx=flx else textx=t.textx end
if t.texty==nil then texty=add else texty=t.texty end
if t.hr==nil then hr=0 else hr=t.hr end
if t.font==nil then font="Acknowledge tt BRK" else font=t.font end
if t.fsize==nil then fsize=14 else fsize=t.fsize end
if t.face==nil then face=CAIRO_FONT_WEIGHT_NORMAL end
if t.face=="bold" then face=CAIRO_FONT_WEIGHT_BOLD end
if t.tred==nil then tred=1 else tred=t.tred end
if t.tgreen==nil then tgreen=1 else tgreen=t.tgreen end
if t.tblue==nil then tblue=1 else tblue=t.tblue end
if t.talpha==nil then talpha=1 else talpha=t.talpha end
if t.talpha==nil then talpha=1 else talpha=t.talpha end
if t.text~=nil then
local text=t.text
cairo_move_to(cr,textx,texty)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, face)
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
cairo_show_text (cr,text)
cairo_stroke (cr)
end
if t.hrl==nil then hrl=250 else hrl=t.hrl end
if t.hr~=nil then
cairo_set_source_rgba (cr,1,1,1,1)
cairo_move_to (cr,textx,texty+0.5-3)
cairo_set_line_width (cr,1)
cairo_rel_line_to (cr,hrl,0)
cairo_stroke (cr)
end
end
function bar(t)
local bnum=t.bnum
if t.bmax==nil then bmax=100 else bmax=t.bmax end
local barx=t.barx+0.5
local bary=t.bary+0.5
local bhigh=t.bhigh
local blong=t.blong
local bout=t.bout
local length=((bnum/bmax)*blong)
cairo_rectangle (cr,barx,bary,length,-bhigh)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_fill (cr)
if bout==1 then
cairo_rectangle (cr,barx,bary,blong,-bhigh)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_set_line_width (cr,1)
cairo_stroke (cr)
end
end
conkyrc
Bookmarks