SEARCH

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

You are not logged in.

#3226 2012-10-11 04:00:24

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

Re: The New Monster Conky Thread

So finally like 8 hours later I make it to the computer in question................

Heres my sensors output

luke@crunchbang:~$ sensors
k10temp-pci-00c3
Adapter: PCI adapter
temp1:        +32.0°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +68.0°C)

f71889ed-isa-0600
Adapter: ISA adapter
+3.3V:        +3.36 V  
in1:          +0.89 V  (max =  +2.04 V)
in2:          +1.10 V  
in3:          +0.87 V  
in4:          +0.59 V  
in5:          +1.27 V  
in6:          +1.57 V  
3VSB:         +3.38 V  
Vbat:         +3.28 V  
fan1:        2626 RPM
fan2:        1011 RPM
fan3:        1103 RPM
temp1:        +28.0°C  (high = +255.0°C, hyst = +251.0°C)  ALARM (CRIT)
                       (crit = +255.0°C, hyst = +251.0°C)  sensor = transistor
temp2:          FAULT  (high = +255.0°C, hyst = +251.0°C)
                       (crit = +255.0°C, hyst = +251.0°C)  sensor = transistor
temp3:        +32.0°C  (high = +255.0°C, hyst = +253.0°C)  ALARM (CRIT)
                       (crit = +255.0°C, hyst = +253.0°C)  sensor = transistor

but this is what aticonfig says my temp is

luke@crunchbang:~$ aticonfig --adapter=0 --od-gettemperature | grep 'Temperature' | cut --characters 36-38
[b] 47[/b]

So Im not sure which if any of those sensors is supposed to be my GPU.


@ mrpeachy

Thanks for that. Ill add it in and see what I can get working from there. I really appreciate the help.

I made those changes and Im getting this error

Conky: llua_do_call: function conky_gpu execution failed: /home/luke/conky/allcombined.lua:30: attempt to perform arithmetic on global 'gpuc' (a nil value)
Conky: llua_do_call: function conky_gpu execution failed: /home/luke/conky/allcombined.lua:30: attempt to perform arithmetic on global 'gpuc' (a nil value)

Heres my entire allcombined file incase I screwed it up somehow

--[[ by mrpeachy - 
combines background bar and calendar functions
]]
require 'cairo'
require 'imlib2'

function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
conky_start=1
function conky_gpu()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then --as this function may use conky_parse("${cpu}")
--#########################################################################################################
--setup timer
local interval=10
local timer=(updates % interval)
if timer==0 or conky_start==1 then
local file = io.popen("aticonfig --adapter=0 --od-gettemperature | grep 'Temperature' | cut --characters 36-38")
local gpuc = file:read("*a")
gpuc = tonumber(gpu)
file:close()
conky_start=nil
end--of timer
--convert C to F
--°C  x  9/5 + 32 = °F
local gpuf=(gpuc*(9/5))+32
--call bar function
conky_gradbar ({5,140,gpuf,159,80,2,10,1,0xFFFFFF,0.25,0x00FF00,1,0xFFFF00,1,0xFF0000,1})
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--return gpuf to conky
return gpuf
end-- end main function ###################################################################################

function conky_gradbar(bartab)
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--#########################################################################################################
--convert to table
local bartab=loadstring("return" .. bartab)()
local bar_startx=bartab[1]
local bar_starty=bartab[2]
local number=bartab[3]
local number=conky_parse(number)
local number_max=bartab[4]
local divisions=bartab[5]
local div_width=bartab[6]
local div_height=bartab[7]
local div_gap=bartab[8]
local bg_col=bartab[9]
local bg_alpha=bartab[10]
local st_col=bartab[11]
local st_alpha=bartab[12]
local mid_col=bartab[13]
local mid_alpha=bartab[14]
local end_col=bartab[15]
local end_alpha=bartab[16]
--color conversion
local br,bg,bb,ba=rgb_to_r_g_b({bg_col,bg_alpha})
local sr,sg,sb,sa=rgb_to_r_g_b({st_col,st_alpha})
local mr,mg,mb,ma=rgb_to_r_g_b({mid_col,mid_alpha})
local er,eg,eb,ea=rgb_to_r_g_b({end_col,end_alpha})
if number==nil then number=0 end
local number_divs=(number/number_max)*divisions
cairo_set_line_width (cr,div_width)
--gradient calculations
for i=1,divisions do
if i<(divisions/2) and i<=number_divs then
colr=((mr-sr)*(i/(divisions/2)))+sr
colg=((mg-sg)*(i/(divisions/2)))+sg
colb=((mb-sb)*(i/(divisions/2)))+sb
cola=((ma-sa)*(i/(divisions/2)))+sa
elseif i>=(divisions/2) and i<=number_divs then
colr=((er-mr)*((i-(divisions/2))/(divisions/2)))+mr
colg=((eg-mg)*((i-(divisions/2))/(divisions/2)))+mg
colb=((eb-mb)*((i-(divisions/2))/(divisions/2)))+mb
cola=((ea-ma)*((i-(divisions/2))/(divisions/2)))+ma
else
colr=br
colg=bg
colb=bb
cola=ba
end
cairo_set_source_rgba (cr,colr,colg,colb,cola)
cairo_move_to (cr,bar_startx+((div_width+div_gap)*i-1),bar_starty)
cairo_rel_line_to (cr,0,div_height)
cairo_stroke (cr)
end
--#########################################################################################################
end-- if updates>5
bartab=nil
colr=nil
colg=nil
colb=nil
cola=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_draw_bg(bgtab)
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
--#########################################################################################################
--convert to table
local bgtab=loadstring("return" .. bgtab)()
local r=bgtab[1]
local x=bgtab[2]
local y=bgtab[3]
local w=bgtab[4]
local h=bgtab[5]
local color=bgtab[6]
local alpha=bgtab[7]
if w==0 then 
w=tonumber(conky_window.width)
end
if h==0 then
h=tonumber(conky_window.height)
end
cairo_set_source_rgba (cr,rgb_to_r_g_b({color,alpha}))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
--the drawing part---------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
--#########################################################################################################
bgtab=nil
w=nil
h=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_luacal(caltab)
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
--####################################################################################################
local caltab=loadstring("return" .. caltab)()
local cal_x=caltab[1]
local cal_y=caltab[2]
local tfont=caltab[3]
local tfontsize=caltab[4]
local tc=caltab[5]
local ta=caltab[6]
local bfont=caltab[7]
local bfontsize=caltab[8]
local bc=caltab[9]
local ba=caltab[10]
local hfont=caltab[11]
local hfontsize=caltab[12]
local hc=caltab[13]
local ha=caltab[14]
local spacer=caltab[15]
local gaph=caltab[16]
local gapt=caltab[17]
local gapl=caltab[18]
local sday=caltab[19]
--convert colors
--local font=string.gsub(font,"_"," ")
local tred,tgreen,tblue,talpha=rgb_to_r_g_b({tc,ta})
--main body text color
local bred,bgreen,bblue,balpha=rgb_to_r_g_b({bc,ba})
--highlight text color
local hred,hgreen,hblue,halpha=rgb_to_r_g_b({hc,ha})
--###################################################
--calendar calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time( {    year=year,month=03,day=01,hour=00,min=0,sec=0} );
local t2 = os.time( {    year=year,month=02,day=01,hour=00,min=0,sec=0} );
local 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
local start_day=day-(day_num % 7)
if start_day<0 then start_day=7+start_day end     
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
local x=mdays+start_day
local dnum={}
local dnumh={}
if mdays+start_day<36 then 
dlen=35
plen=29 
else 
dlen=42 
plen=36
end
for i=1,dlen do
    if i<=start_day then 
    dnum[i]="  " 
    else 
    dn=i-start_day
        if dn=="nil" then dn=0 end
        if dn<=9 then dn=(spacer .. dn) end
        if i>x then dn="" end
        dnum[i]=dn
        dnumh[i]=dn
        if dn==(spacer .. today) or dn==today then
        dnum[i]=""
        end 
        if dn==(spacer .. today) or dn==today then
        dnumh[i]=dn
        place=i 
        else dnumh[i]="  " 
        end 
    end
end--for
cairo_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 tonumber(sday)==0 then
dys={"SU","MO","TU","WE","TH","FR","SA"}
else
dys={"MO","TU","WE","TH","FR","SA","SU"}
end
--draw calendar titles
for i=1,7 do
cairo_move_to (cr, cal_x+(gaph*(i-1)), cal_y)
cairo_show_text (cr, dys[i])
cairo_stroke (cr)
end
--draw calendar body
cairo_select_font_face (cr, bfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, bfontsize);
cairo_set_source_rgba (cr,bred,bgreen,bblue,balpha)
for i=1,plen,7 do
local fn=i
    for i=fn,fn+6 do
    cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
    cairo_show_text (cr, dnum[i])
    cairo_stroke (cr)
    end
end
--highlight
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
local fn=i
    for i=fn,fn+6 do
    cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
    cairo_show_text (cr, dnumh[i])
    cairo_stroke (cr)
    end
end
--#########################################################################################################
caltab=nil
dlen=nil
plen=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_luaimage(imtab)
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
--#########################################################################################################
local imtab=loadstring("return" .. imtab)()
local im_x=imtab[1]
local im_y=imtab[2]
local im_w=imtab[3]
local im_h=imtab[4]
local file=imtab[5]
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(im_w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(im_w)
end
if tonumber(im_h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(im_h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(im_x, im_y)
imlib_free_image()
show=nil
--#########################################################################################################
imtab=nil
height=nil
width=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function conky_tex_bg(textab)
local textab=loadstring("return" .. textab)()
local tex_file=textab[6]
local surface = cairo_image_surface_create_from_png(tostring(tex_file))
local cw,ch = conky_window.width, conky_window.height
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, cw,ch)
local cr=cairo_create(cs)
--#########################################################################################################
--convert to table
local r=textab[1]
local x=textab[2]
local y=textab[3]
local w=textab[4]
local h=textab[5]
if w=="0" then
w=cw
end
if h=="0" then
h=ch
end
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
--the drawing part---------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_clip (cr)
cairo_new_path (cr);
--image part
cairo_set_source_surface (cr, surface, 0, 0)
cairo_paint (cr)
--#########################################################################################################
textab=nil
w=nil
h=nil
cairo_destroy(cr)
cairo_surface_destroy (cs)
cairo_surface_destroy (surface)
cr=nil
return ""
end-- end main function

function conky_luatext(txttab)--x,y,c,a,f,fs,txt,j ##################################################
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
--#########################################################################################################
--convert to table
local txttab=loadstring("return" .. txttab)()
local x=txttab[1]
local y=txttab[2]
local c=txttab[3]
local a=txttab[4]
local f=txttab[5]
local fs=txttab[6]
local j=txttab[7]
local txt=txttab[8]
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,txt,extents)
local wx=extents.x_advance
cairo_set_source_rgba (cr,rgb_to_r_g_b({c,a}))
if j=="l" then
cairo_move_to (cr,x,y)
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
end
cairo_show_text (cr,txt)
cairo_stroke (cr)
--#########################################################################################################
txttab=nil
cairo_destroy(cr)
cairo_surface_destroy (cs)
cr=nil
return ""
end-- end main function

@Sector11

LOL! If you only knew my love of rock candy........... *sigh*........... thanks alot!

Last edited by lwfitz (2012-10-11 04:13:14)

Offline

Help fund CrunchBang, donate to the project!

#3227 2012-10-11 04:55:48

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

Re: The New Monster Conky Thread

sorry... this is the problem...
change

local gpuc = file:read("*a")
gpuc = tonumber(gpu)

to

local gpuc = file:read("*a")
gpuc = tonumber(gpuc)

Offline

#3228 2012-10-11 05:04:41

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

Re: The New Monster Conky Thread

mrpeachy wrote:

sorry... this is the problem...
change

local gpuc = file:read("*a")
gpuc = tonumber(gpu)

to

local gpuc = file:read("*a")
gpuc = tonumber(gpuc)

Thanks. I made the change and now I get

Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_do_call: function conky_gpu execution failed: /home/luke/conky/allcombined.lua:30: attempt to perform arithmetic on global 'gpuc' (a nil value)

Offline

#3229 2012-10-11 05:12:28

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,030
Website

Re: The New Monster Conky Thread

Sector11 wrote:

@ johnraff

Don't use the conky site for your variables (above TEXT) and settings (below TEXT) other than for general knowledge.  Those sites have been upgraded to reflect changes to Conky v1.9.0-2 that is now current.

For example:

border_inner_margin
border_outer_margin

did not exist for conky v1.8.0, it was simply:

border_margin

I don't remember how they got into the file, but probably from looking at the site sometime after the conky upgrade. roll I had a look at the conkyrc I was using in #! Jaunty and no there was no 'border_inner_margin' and no 'gap_y -30px' either, so that hanging window thing must have crept in during the move to Statler - maybe Conky was on a lower version at first, with a bug later fixed in 1.8.0...

a very interesting side affect... Right clicking on the 'menu bar' of the open program brings up the program menu.  Right clicking on the conky brings up the OpenBox Menu.

So it does! Now that's handy. The mouse is often up at that end of the screen. cool

If you look at conky help for v1.8.0 does it show the -D and -DD options?

Yes, OK

So you can always check for errors.

Indeed. Thank you.

Well that was a niggling issue that had been bothering me for some time, very happy to get it fixed, and with a bonus menu shortcut too! smile


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#3230 2012-10-11 05:32:27

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

Re: The New Monster Conky Thread

@lwfitz
maybe change the position of the return line
from this:

conky_gradbar ({5,140,gpuf,159,80,2,10,1,0xFFFFFF,0.25,0x00FF00,1,0xFFFF00,1,0xFF0000,1})
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--return gpuf to conky
return gpuf
end-- end main function ###################################################################################

to this:

conky_gradbar ({5,140,gpuf,159,80,2,10,1,0xFFFFFF,0.25,0x00FF00,1,0xFFFF00,1,0xFF0000,1})
--return gpuf to conky
return gpuf

--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function ###################################################################################

i cant test this right now im afraid

Last edited by mrpeachy (2012-10-11 05:33:16)

Offline

#3231 2012-10-11 05:42:47

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

Re: The New Monster Conky Thread

mrpeachy wrote:

@lwfitz
maybe change the position of the return line
from this:

conky_gradbar ({5,140,gpuf,159,80,2,10,1,0xFFFFFF,0.25,0x00FF00,1,0xFFFF00,1,0xFF0000,1})
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--return gpuf to conky
return gpuf
end-- end main function ###################################################################################

to this:

conky_gradbar ({5,140,gpuf,159,80,2,10,1,0xFFFFFF,0.25,0x00FF00,1,0xFFFF00,1,0xFF0000,1})
--return gpuf to conky
return gpuf

--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function ###################################################################################

i cant test this right now im afraid


Unfortunately no luck sad

Same error

Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_do_call: function conky_gpu execution failed: /home/luke/conky/allcombined.lua:30: attempt to perform arithmetic on global 'gpuc' (a nil value)
Conky: llua_do_call: function conky_gpu execution failed: /home/luke/conky/allcombined.lua:30: attempt to perform arithmetic on global 'gpuc' (a nil value)

Offline

#3232 2012-10-11 05:55:37

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

Re: The New Monster Conky Thread

doh!
well ill get you some working code tomorrow smile

Offline

#3233 2012-10-11 06:25:04

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

Re: The New Monster Conky Thread

mrpeachy wrote:

doh!
well ill get you some working code tomorrow smile


Haha right on buddy.  Again thanks for the help on this.

Offline

#3234 2012-10-11 06:36:11

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

Re: The New Monster Conky Thread

lwfitz wrote:
mrpeachy wrote:

doh!
well ill get you some working code tomorrow smile


Haha right on buddy.  Again thanks for the help on this.

what do you get when you just do this in a terminal:

aticonfig --adapter=0 --od-gettemperature

?

Offline

#3235 2012-10-11 06:56:23

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

Re: The New Monster Conky Thread

mrpeachy wrote:
lwfitz wrote:
mrpeachy wrote:

doh!
well ill get you some working code tomorrow smile


Haha right on buddy.  Again thanks for the help on this.

what do you get when you just do this in a terminal:

aticonfig --adapter=0 --od-gettemperature

?

luke@crunchbang:~$ aticonfig --adapter=0 --od-gettemperature

Adapter 0 - AMD Radeon HD 6700 Series 
            Sensor 0: Temperature - 46.00 C

Offline

#3236 2012-10-11 08:52:32

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

Re: The New Monster Conky Thread

The problem arouses because you declare gpuc as a local to if timer part.
If you declare "local gpuc=0" before if timer part and use it inside without declaration then it will be good:

        local gpuc=0        #gpuc declaration with local
        if timer==0 or conky_start==1 then
            local file = io.popen("aticonfig --adapter=0 --od-gettemperature | grep 'Temperature' | cut --characters 36-38")
            gpuc = file:read("*a")        #gpuc use without local declaration
            gpuc = tonumber(gpuc)
            file:close()
            conky_start=nil
        end--of timer
        --convert C to F
        --°C  x  9/5 + 32 = °F
        local gpuf=(gpuc*(9/5))+32

Another thing you should change in your allcombined is running functions after declared numbers of Conky loop/updates. You use if statement as everyone for that, but instead short, exclude one, you use long, include one.
In your version whole function is included inside if statement. And that's not good resource wise. If statements in every language should be as short as possible.

So, instead:

if updates>5 then --as this function may use conky_parse("${cpu}")
[..] whole function inside if statement
end-- if updates>5

you should use

if updates<=5 then return end
[..] whole function outside if statement

Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#3237 2012-10-11 14:55:27

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,788
Website

Re: The New Monster Conky Thread

johnraff wrote:

Well that was a niggling issue that had been bothering me for some time, very happy to get it fixed, and with a bonus menu shortcut too! smile

Yea, that makes the whole thing worthwhile.
Always nice to learn about undocumented features that are beneficial.

Online

#3238 2012-10-11 14:57:49

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 919

Re: The New Monster Conky Thread

dk75 wrote:

The problem arouses because you declare gpuc as a local to if timer part.
If you declare "local gpuc=0" before if timer part and use it inside without declaration then it

Yes that is likely the problem.
You have to do it like that because if statements are treated the same as for loops and functions with regard to variable scope in Lua for some strange reason.

dk75 wrote:

In your version whole function is included inside if statement. And that's not good resource wise. If statements in every language should be as short as possible.

Do you have a source for this?
I have never heard that before.

Offline

#3239 2012-10-11 14:58:18

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,788
Website

Re: The New Monster Conky Thread

dk75 wrote:

Another thing you should change in your allcombined is running functions after declared numbers of Conky loop/updates. You use if statement as everyone for that, but instead short, exclude one, you use long, include one.
In your version whole function is included inside if statement. And that's not good resource wise. If statements in every language should be as short as possible.

So, instead:

if updates>5 then --as this function may use conky_parse("${cpu}")
[..] whole function inside if statement
end-- if updates>5

you should use

if updates<=5 then return end
[..] whole function outside if statement

Now that looks interesting.  Thanks dk75

Online

#3240 2012-10-11 17:11:26

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

Re: The New Monster Conky Thread

arclance wrote:
dk75 wrote:

In your version whole function is included inside if statement. And that's not good resource wise. If statements in every language should be as short as possible.

Do you have a source for this?
I have never heard that before.

No, but as IF is placed in virtual register it's content must be parsed. More content inside IF statement, more work for parser.
And since simple quiting function, while update is lower than 5 is much smaller than full read file routine, I've assumed that.

And another interpreter I know have very slow IF statement - BASH.


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#3241 2012-10-11 17:15:35

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

Re: The New Monster Conky Thread

dk75 wrote:

The problem arouses because you declare gpuc as a local to if timer part.
If you declare "local gpuc=0" before if timer part and use it inside without declaration then it will be good:

        local gpuc=0        #gpuc declaration with local
        if timer==0 or conky_start==1 then
            local file = io.popen("aticonfig --adapter=0 --od-gettemperature | grep 'Temperature' | cut --characters 36-38")
            gpuc = file:read("*a")        #gpuc use without local declaration
            gpuc = tonumber(gpuc)
            file:close()
            conky_start=nil
        end--of timer
        --convert C to F
        --°C  x  9/5 + 32 = °F
        local gpuf=(gpuc*(9/5))+32

Another thing you should change in your allcombined is running functions after declared numbers of Conky loop/updates. You use if statement as everyone for that, but instead short, exclude one, you use long, include one.
In your version whole function is included inside if statement. And that's not good resource wise. If statements in every language should be as short as possible.

So, instead:

if updates>5 then --as this function may use conky_parse("${cpu}")
[..] whole function inside if statement
end-- if updates>5

you should use

if updates<=5 then return end
[..] whole function outside if statement

Still getting this error

luke@crunchbang:~$ ~/conky/conky_start
luke@crunchbang:~$ Conky: llua_load: /home/luke/conky/allcombined.lua:24: unexpected symbol near '#'
Conky: desktop window (b9) is root window
Conky: window type - desktop
Conky: drawing to created window (0x3a00001)
Conky: drawing to double buffer
Conky: llua_do_call: function conky_draw_bg execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_gpu execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_draw_bg execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_gpu execution failed: attempt to call a nil value

Offline

#3242 2012-10-11 17:43:03

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 919

Re: The New Monster Conky Thread

dk75 wrote:
arclance wrote:
dk75 wrote:

In your version whole function is included inside if statement. And that's not good resource wise. If statements in every language should be as short as possible.

Do you have a source for this?
I have never heard that before.

No, but as IF is placed in virtual register it's content must be parsed. More content inside IF statement, more work for parser.
And since simple quiting function, while update is lower than 5 is much smaller than full read file routine, I've assumed that.

And another interpreter I know have very slow IF statement - BASH.

Since a conky Lua script is not a run once and close script it should not matter.
conky runs the Lua compiler on the script once at startup, when you change your .conkyrc, or when you make changes to the lua script file.
It is not recompiled with every update so everything has to be stored somewhere for it to be used when the conditions are met.
This means the complier has to parse the whole file regardless of which if statement style you use.

You can think of it as the function being called once in each pass of a "while conkyRunning == True" loop.
Global variables are only reset if you change your .conkyrc or restart conky.

Comparing Lua and Bash is like comparing a speed boat to a bicycle.
They both get you somewhere but they do it in very different ways.

Also if you just use.

if updates<=5 then return end
[..] whole function outside if statement

You will get memory leaks since

end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--return gpuf to conky
return gpuf

will not be run because the function ends before it gets to them.
Not returning "gpuf" will cause whatever calls that function to fail.

Offline

#3243 2012-10-11 18:25:27

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

Re: The New Monster Conky Thread

arclance wrote:
dk75 wrote:
arclance wrote:

Do you have a source for this?
I have never heard that before.

No, but as IF is placed in virtual register it's content must be parsed. More content inside IF statement, more work for parser.
And since simple quiting function, while update is lower than 5 is much smaller than full read file routine, I've assumed that.

And another interpreter I know have very slow IF statement - BASH.

Since a conky Lua script is not a run once and close script it should not matter.
conky runs the Lua compiler on the script once at startup, when you change your .conkyrc, or when you make changes to the lua script file.
It is not recompiled with every update so everything has to be stored somewhere for it to be used when the conditions are met.
This means the complier has to parse the whole file regardless of which if statement style you use.

You can think of it as the function being called once in each pass of a "while conkyRunning == True" loop.
Global variables are only reset if you change your .conkyrc or restart conky.

Comparing Lua and Bash is like comparing a speed boat to a bicycle.
They both get you somewhere but they do it in very different ways.

True.
But my way you have less nested, more elegant code.



arclance wrote:

Also if you just use.

if updates<=5 then return end
[..] whole function outside if statement

You will get memory leaks since

end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--return gpuf to conky
return gpuf

will not be run because the function ends before it gets to them.
Not returning "gpuf" will cause whatever calls that function to fail.

That why you should use it as first thing in the code - then, no Cario surface will be created.


And as answer to lwifitz@ error, comment with "#" should be deleted in working code - sorry, I'm doing too much everything and mismatched different interpreters comments:

function conky_gpu()
    if conky_window == nil then return end
    local updates=tonumber(conky_parse('${updates}'))
    if updates<=5 then return end --as this function may use conky_parse("${cpu}")
    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local cr = cairo_create(cs)
    --#########################################################################################################
    --setup timer
    local interval=10
    local timer=(updates % interval)
    local gpuc=0
    if timer==0 or conky_start==1 then
        local file = io.popen("aticonfig --adapter=0 --od-gettemperature | grep 'Temperature' | cut --characters 36-38")
        gpuc = tonumber(file:read("*a"))
        file:close()
        conky_start=nil
    end--of timer
    --convert C to F
    --°C  x  9/5 + 32 = °F
    local gpuf=(gpuc*(9/5))+32
    --call bar function
    conky_gradbar ({5,140,gpuf,159,80,2,10,1,0xFFFFFF,0.25,0x00FF00,1,0xFFFF00,1,0xFF0000,1})
    --#########################################################################################################
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
    --return gpuf to conky
    return gpuf
end-- end main function ###################################################################################

Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#3244 2012-10-11 18:43:48

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

Re: The New Monster Conky Thread

thanks for the info dk75, i will use that in the future!

@lwifitz
unfortunately the code above still wont work for you (it does for me because i changed the way allcombined sends info from conky to lua)

this is towards the top of the gradbar function ( function conky_gradbar(bartab) )

--convert to table
local bartab=loadstring("return" .. bartab)()

need to change it to:

if bartab[1]==nil then
--convert to table
local bartab=loadstring("return" .. bartab)()
end

also that "local gpuc=0" line needs to be removed
and you still need "conky_start=1" above the function

Last edited by mrpeachy (2012-10-11 18:54:05)

Offline

#3245 2012-10-11 18:47:13

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 919

Re: The New Monster Conky Thread

dk75 wrote:

True.
But my way you have less nested, more elegant code.

More elegant, maybe.
I don't think so but others might, it depends on your preferred coding style.
I would say it is more confusing but I really don't like one line if statements.
They tend to get lost in the rest of the code, especially when you look as someone else's code.

dk75 wrote:

That why you should use it as first thing in the code - then, no Cario surface will be created.

Yes that would be the way to do it if you do it your way, but that was not what your original suggestion was.
I doubt you would get any speed improvement at all since you still have to evaluate the if statement condition either way.

Last edited by arclance (2012-10-11 18:50:41)

Offline

#3246 2012-10-11 18:58:30

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

Re: The New Monster Conky Thread

^ one situation where it would be an advantage in practical terms, if there was a script that might parse ${cpu} so needs the if or someone might not parse ${cpu} and use the script with a long conky_update interval (this has been the case with v9000).  Then there would be only one place to direct the script used to turn on/off the if
otherwise you have to have them searching for if at the top (which is relatively easy to find) and the matching end at the bottom (which can be harder to find in a long script)

Offline

#3247 2012-10-11 19:06:16

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,788
Website

Re: The New Monster Conky Thread

dk75 wrote:
arclance wrote:

Also if you just use.

if updates<=5 then return end
[..] whole function outside if statement

You will get memory leaks since

end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--return gpuf to conky
return gpuf

will not be run because the function ends before it gets to them.
Not returning "gpuf" will cause whatever calls that function to fail.

That why you should use it as first thing in the code - then, no Cario surface will be created

OK, I'm a bit lost here dk75

Does this mean that:


function conky_main()
    if conky_window == nil then
        return
    end

    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local display = cairo_create(cs)

    local updates = conky_parse('${updates}')
    update_num = tonumber(updates)

    if updates<=5 then return end
        go_gauge_rings(display)
        go_clock_rings(display)


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

isnt the same as:

function conky_main()
    if conky_window == nil then
        return
    end

    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local display = cairo_create(cs)

    local updates = conky_parse('${updates}')
    update_num = tonumber(updates)

    if update_num > 5 then
        go_gauge_rings(display)
        go_clock_rings(display)
    end

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

OK, it's a learning process.

Online

#3248 2012-10-11 19:25:51

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

Re: The New Monster Conky Thread

@ mrpeachy and dk75

YOu guys rock! Im getting this error

luke@crunchbang:~$ killall conky
luke@crunchbang:~$ ~/conky/conky_start
luke@crunchbang:~$ Conky: desktop window (b9) is root window
Conky: window type - desktop
Conky: drawing to created window (0x2c00001)
Conky: drawing to double buffer
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded

and the conky keeps jumping from c to (32c to 89.6f)

Offline

#3249 2012-10-11 19:33:17

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 919

Re: The New Monster Conky Thread

mrpeachy wrote:

^ one situation where it would be an advantage in practical terms, if there was a script that might parse ${cpu} so needs the if or someone might not parse ${cpu} and use the script with a long conky_update interval (this has been the case with v9000).  Then there would be only one place to direct the script used to turn on/off the if
otherwise you have to have them searching for if at the top (which is relatively easy to find) and the matching end at the bottom (which can be harder to find in a long script)

I am not talking about scripts that don't use a if statement that checks the number of updates.
I am talking about the difference between

function w()
    Setup Code
    if updates > 5 then
        Code
    end --# if updates > 5 then
    return output
end --# function w()

and

function w()
    if updates <= 5 then
        return some_value
    end --# if updates <= 5 then
    Setup Code
    Code
    return output
end --# function w()

My major gripe with dk75 suggestion is the use of a one line if statement like this

if updates <= 5 then return end

which easily disappears into the rest of the code, especially if it is near other if statements.
His example will also break that script without modification since it will make it return none instead of whatever is correct for that function.
I assume it should be a string since it is for your allcombined script.
That might be the cause of this error.

Conky: llua_getstring: function conky_gpu didn't return a string, result discarded

Last edited by arclance (2012-10-11 19:34:48)

Offline

Help fund CrunchBang, donate to the project!

#3250 2012-10-11 21:26:47

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

Re: The New Monster Conky Thread

lwfitz wrote:

@ mrpeachy and dk75

YOu guys rock! Im getting this error

luke@crunchbang:~$ killall conky
luke@crunchbang:~$ ~/conky/conky_start
luke@crunchbang:~$ Conky: desktop window (b9) is root window
Conky: window type - desktop
Conky: drawing to created window (0x2c00001)
Conky: drawing to double buffer
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded
Conky: llua_getstring: function conky_gpu didn't return a string, result discarded

and the conky keeps jumping from c to (32c to 89.6f)

the jumping is due to this line

local gpuc=0

delete it and the jumping will go away
the error you are getting is harmless i (or someone) will give you a fix to get rid of it at some point smile

this should fix it
change:

if updates<=5 then return end --as this function may use conky_parse("${cpu}")

to

if updates<=5 then return "" end --as this function may use conky_parse("${cpu}")

edit - i had those the wrong way round, fixed now

Last edited by mrpeachy (2012-10-11 22:03:38)

Offline

Board footer

Powered by FluxBB

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

Debian Logo