SEARCH

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

You are not logged in.

#351 2012-07-30 18:57:06

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

Re: interactive conky

image settings is done

add

image=1,im_file="/path/image.png"

and thats it

you still set button width and button height in the setup and the script fits the image to the button
this way you could have a simple size increase, for example, on mouseover

hmm... need to be able to set an off and on image... brb!

ok... DONE
options:

image=1 --1 for images 0 no images, default is 0
im_file_off=path --set path to off image (btype 1,2,3)
im_file_on=path --set path to on image (btype 1,2,3)
im_file_cyc={path1,path2} --set images for cycle type button (btype=4)

i'll update the main how to in a bit
had to fix a bug and update archive

Last edited by mrpeachy (2012-07-30 19:39:06)

Offline

Be excellent to each other!

#352 2012-07-30 19:07:52

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

peachy wrote:

hmm... need to be able to set an off and on image... brb!

This could just be controlled by

if button==0 then
--image--
end
if button==1 then
--image--
end

Correct?

Last edited by falldown (2012-07-30 19:11:01)

Offline

#353 2012-07-30 19:20:18

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

Re: interactive conky

^ true
I'm just thinking about continuity with other options and trying to have everything you need integrated into the button function itself

Offline

#354 2012-07-30 20:05:54

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Peachy how would I write

${top_mem name 1} - ${top_mem mem_res 1} - ${top_mem mem 1}%

In a consecutive

out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=xpos2-5,y=ypos+gap*9,txt=conky_parse"${---}"})

line?

Offline

#355 2012-07-30 20:16:35

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

Re: interactive conky

^
you could set the values to strings first
like this

mem_name1=conky_parse("${top_mem name 1}")
mem_res1=conky_parse("${top_mem mem_res 1}")
mem_mem1=conky_parse("${top_mem mem 1}")

then

txt=mem_name1.." - "..mem_res1.." - "..mem_mem1

or conky_parse the whole line

txt=conky_parse("${top_mem name 1} - ${top_mem mem_res 1} - ${top_mem mem 1}%")

if you want to set up a table of mem info you could use a for loop..something like this

gap=15
for i=1,5 do
out({x=20,y=20+((i-1)*gap), txt=conky_parse("${top_mem name "..i.."} - ${top_mem mem_res "..i.."} - ${top_mem mem "..i.."}%")
end

Offline

#356 2012-07-30 20:26:40

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

peachy wrote:

or conky_parse the whole line

txt=conky_parse("${top_mem name 1} - ${top_mem mem_res 1} - ${top_mem mem 1}%")

Thats the GOLDEN TICKET!!
Gracias amigo!

Offline

#357 2012-07-30 23:13:02

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

A little closer..
http://youtu.be/cBU2YRxDzuA
...
2012_07_30_1343689742_891x614_scrot.jpg
and...
2012_07_30_1343689768_762x544_scrot.jpg
kinda looks like your traditional conky.. in a way. smile

Also Peachy will the calendar work with the same added lines?

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)
--####################################################################################################
--convert to table
if caltab[1]==nil then --added
caltab=loadstring("return" .. caltab)() --added
end --added
--variable setup --removed 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

Last edited by falldown (2012-07-30 23:43:36)

Offline

#358 2012-07-31 01:05:05

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Completed rough system_info template..
2012_07_30_1343696506_687x657_scrot.jpg
and...
2012_07_30_1343696533_684x669_scrot.jpg

Offline

#359 2012-07-31 01:09:53

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

Re: interactive conky

yes, the calendar should when setup in the lua with those extra lines
and the same format should make all those functions accessible

looking very nice by the way

Offline

#360 2012-07-31 01:19:38

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Thank you Peachy.
Thats 200+ lines of out , image and button function.
Doesn't look like it. big_smile

Offline

#361 2012-07-31 16:04:03

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Peachy the luacal is a little more complicated.
Does it have a value?

local val=

and does this look correct?

conky_luacal({25,80,val,30,16,16,0,"Poppl",14,0x41d8dd,1,"Poppl",14,0xDADADA,1,"Poppl",14,0x41d8dd,1," ",})

I'm getting this error with the above line..

Conky: llua_do_call: function conky_weather execution failed: /home/falldown/lua/interactive_all_cal.lua:248: attempt to perform arithmetic on local 'col' (a table value)

and line 247-249 in lua script..

function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end

Last edited by falldown (2012-07-31 16:09:54)

Offline

#362 2012-07-31 16:08:00

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

Re: interactive conky

no val variable

${lua luacal {x_position,y_position,"title_font",title_fontsize,title_color,title_alpha,"dates_font",dates_fontsize,dates_color,dates_alpha,"highlight_font",highlight_fontsize,highlight_color,highlight_alpha,"spacer",colum_gap,title_gap,row_gap,start_day}}

Offline

#363 2012-07-31 16:13:27

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

mrpeachy wrote:

no val variable

${lua luacal {x_position,y_position,"title_font",title_fontsize,title_color,title_alpha,"dates_font",dates_fontsize,dates_color,dates_alpha,"highlight_font",highlight_fontsize,highlight_color,highlight_alpha,"spacer",colum_gap,title_gap,row_gap,start_day}}

Ohhh.......
I just have the order all "out of whack!!"
                                              ^Unfortunately growing up in the MidWest shows up in my phrases occasionally. big_smile

Offline

#364 2012-07-31 16:36:05

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Still no luck sir.
I think the color table might be different.

Offline

#365 2012-07-31 16:42:22

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

Re: interactive conky

post the new luacal line and ill test it out
what errors are you getting?

Offline

#366 2012-07-31 16:45:45

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

I'm getting this error with the above line..

Conky: llua_do_call: function conky_weather execution failed: /home/falldown/lua/interactive_all_cal.lua:248: attempt to perform arithmetic on local 'col' (a table value)

and line 247-249 in lua script..

function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end

These errors^

and starting at line 247..

function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
--calendar 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)
--####################################################################################################
--#########################################################################################################
--convert to table
if caltab[1]==nil then
caltab=loadstring("return" .. caltab)()
end
--variable setup
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

Offline

#367 2012-07-31 16:59:58

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

Re: interactive conky

i just started my conky and am getting the same error... hmmm

Offline

#368 2012-07-31 17:04:06

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

mrpeachy wrote:

i just started my conky and am getting the same error... hmmm

could it be a conflict?

function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end

-------------------

--convert colors
--local font=string.gsub(font,"_"," ")
local tred,tgreen,tblue,talpha=rgb_to_r_g_b({tc,ta})

Offline

#369 2012-07-31 17:12:38

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

Re: interactive conky

actually it was a different function. the background drawing function,
was trying to drawn an outline

try this

luacal({100,755,"Sans",10,0x007f7f,1,"Sans",10,0xb2b2b2,1,"Sans",10,0x007f7f,1," ",20,18,16,0})

Offline

#370 2012-08-01 17:09:30

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Sorry Peachy yesterday got really busy.

With the above code I am still getting the same

Conky: llua_do_call: function conky_weather execution failed: /home/falldown/lua/interactive_all_cal.lua:61: attempt to perform arithmetic on local 'col' (a table value)

Offline

#371 2012-08-01 17:44:56

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

Re: interactive conky

post the luacal setup line that you are using
and for that matter might as well post the entire lua script so i can take a look!

Offline

#372 2012-08-01 17:47:36

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

Re: interactive conky

im working on some clicky stuff too
trying to get a similar effect as you have, but with everything done from the conkyrc
no editing of lua files at all

here is where i am so far:
open and closed... i have set the button up to be the same location and size as the "TIME" text
Screenshot_at_2012_08_01_12_41_15.jpg

Offline

#373 2012-08-01 17:52:10

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

click_start=1
calbutton=0
--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION-
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--#######################################################################
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="Poppl"--font must be in quotes
default_font_size=12
default_color=0x1DD8D9--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--start clickfunction and return coordinates
localx,localy=clickfunction()
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
--####################################
--MAIN WEATHER BUTTON ################
--###################################
--calbutton button
local calbuttonx=5
local calbuttony=10
local calbuttonw=45
local calbuttonh=45
--calculate if click was inside box
if localx>=calbuttonx and localx<=calbuttonx+calbuttonw and localy>=calbuttony and localy<=calbuttony+calbuttonh and calbutton~=1 then 
calbutton=1 
elseif localx>=calbuttonx and localx<=calbuttonx+calbuttonw and localy>=calbuttony and localy<=calbuttony+calbuttonh and calbutton==1 then 
calbutton=0
end
if calbutton==0 then
image({x=calbuttonx,y=calbuttony-10,w=45,h=45,file="/home/falldown/lua/arrowoff.png"})
out({c=0x828282,a=1,f="BorisBlackBloxx",fs=12,x=calbuttonx+30,y=calbuttony+35,txt="CAL"})
image({x=calbuttonx+32,y=calbuttony+42,w=30,h=30,file="/home/falldown/lua/cal.png"})
out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=calbuttonx+5,y=calbuttony+50,txt=conky_parse"${time %b}"})
out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=calbuttonx+5,y=calbuttony+62,txt=conky_parse"${time %d}"})
out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=calbuttonx+5,y=calbuttony+74,txt=conky_parse"${time %y}"})
end
if calbutton==1 then
xpos1=5
xpos2=70
xpos3=40
ypos=40
gap=15
image({x=calbuttonx,y=calbuttony-10,w=45,h=45,file="/home/falldown/lua/arrowon.png"})
--calendar
conky_luacal({100,755,"Sans",10,0x007f7f,1,"Sans",10,0xb2b2b2,1,"Sans",10,0x007f7f,1," ",20,18,16,0})
end--calbutton==1 function
--########################################################################################
--END OF CODE ----END OF CODE ----END OF CODE ---
--#######################################################################
--#######################################################################
function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
--calendar 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)
--####################################################################################################
--#########################################################################################################
--convert to table
if caltab[1]==nil then
caltab=loadstring("return" .. caltab)()
end
--variable setup
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
end-- end main function ###################################################################################
function clickfunction()
--start click logging and calculations ##########################################
if click_start==1 then
print (click_start)
click_start=nil
xdot=conky_parse("${if_running xdotool}1${else}0${endif}")
if tonumber(xdot)==1 then
os.execute("killall xdotool && echo 'xdo killed' &")
end
os.execute("xdotool search --name weather behave %@ mouse-click getmouselocation >> /tmp/xdo &")
start=nil
local f = io.popen("xwininfo -name 'weather' | grep 'Absolute'")
geometry = f:read("*a")
f:close()
geometry=string.gsub(geometry,"[\n]","")
print (geometry)
s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
end--if click_start=1 ######################################
--click calculations #################################
local f=io.open("/tmp/xdo")
click=f:read()
f:close()
if click~=nil then
local f = io.open("/tmp/xdo","w")
f:write("")
f:close() 
end--if click=nil
if click==nil then click="x:0 y:0 " end
--print (click)
s,f,mousex=string.find(click,"x%p(%d*)%s")
s,f,mousey=string.find(click,"y%p(%d*)%s")
mousex=tonumber(mousex)
mousey=tonumber(mousey)
localx=mousex-abstlx
localy=mousey-abstly
--END CLICK CALCULATIONS #################################
return localx,localy
end--function

This is a recycled interactive_weather.lua
It will display a calendar, date, time and weather.

Offline

#374 2012-08-01 17:55:16

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

mrpeachy wrote:

im working on some clicky stuff too
trying to get a similar effect as you have, but with everything done from the conkyrc
no editing of lua files at all
here is where i am so far:
open and closed... i have set the button up to be the same location and size as the "TIME" text
Screenshot_at_2012_08_01_12_41_15.jpg

That is sharp Peachy!!
Are you going to run a higher update_interval?

Offline

Help fund CrunchBang, donate to the project!

#375 2012-08-01 17:57:56

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

Re: interactive conky

it looks like you have the luacal function and color converter function inside the weather template function
they need to be outside like this:

click_start=1
calbutton=0
--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION-
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--#######################################################################
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="Poppl"--font must be in quotes
default_font_size=12
default_color=0x1DD8D9--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--start clickfunction and return coordinates
localx,localy=clickfunction()
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
--####################################
--MAIN WEATHER BUTTON ################
--###################################
--calbutton button
local calbuttonx=5
local calbuttony=10
local calbuttonw=45
local calbuttonh=45
--calculate if click was inside box
if localx>=calbuttonx and localx<=calbuttonx+calbuttonw and localy>=calbuttony and localy<=calbuttony+calbuttonh and calbutton~=1 then 
calbutton=1 
elseif localx>=calbuttonx and localx<=calbuttonx+calbuttonw and localy>=calbuttony and localy<=calbuttony+calbuttonh and calbutton==1 then 
calbutton=0
end
if calbutton==0 then
image({x=calbuttonx,y=calbuttony-10,w=45,h=45,file="/home/falldown/lua/arrowoff.png"})
out({c=0x828282,a=1,f="BorisBlackBloxx",fs=12,x=calbuttonx+30,y=calbuttony+35,txt="CAL"})
image({x=calbuttonx+32,y=calbuttony+42,w=30,h=30,file="/home/falldown/lua/cal.png"})
out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=calbuttonx+5,y=calbuttony+50,txt=conky_parse"${time %b}"})
out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=calbuttonx+5,y=calbuttony+62,txt=conky_parse"${time %d}"})
out({c=0x41d8dd,a=1,f="Poppl",fs=14,x=calbuttonx+5,y=calbuttony+74,txt=conky_parse"${time %y}"})
end
if calbutton==1 then
xpos1=5
xpos2=70
xpos3=40
ypos=40
gap=15
image({x=calbuttonx,y=calbuttony-10,w=45,h=45,file="/home/falldown/lua/arrowon.png"})
--calendar
conky_luacal({100,755,"Sans",10,0x007f7f,1,"Sans",10,0xb2b2b2,1,"Sans",10,0x007f7f,1," ",20,18,16,0})
end--calbutton==1 function
--########################################################################################
--END OF CODE ----END OF CODE ----END OF CODE ---
--#######################################################################
--#######################################################################
end-- end main template function ###################################################################################


function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end

--calendar 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)
--####################################################################################################
--#########################################################################################################
--convert to table
if caltab[1]==nil then
caltab=loadstring("return" .. caltab)()
end
--variable setup
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 calendar function

function clickfunction()
--start click logging and calculations ##########################################
if click_start==1 then
print (click_start)
click_start=nil
xdot=conky_parse("${if_running xdotool}1${else}0${endif}")
if tonumber(xdot)==1 then
os.execute("killall xdotool && echo 'xdo killed' &")
end
os.execute("xdotool search --name weather behave %@ mouse-click getmouselocation >> /tmp/xdo &")
start=nil
local f = io.popen("xwininfo -name 'weather' | grep 'Absolute'")
geometry = f:read("*a")
f:close()
geometry=string.gsub(geometry,"[\n]","")
print (geometry)
s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
end--if click_start=1 ######################################
--click calculations #################################
local f=io.open("/tmp/xdo")
click=f:read()
f:close()
if click~=nil then
local f = io.open("/tmp/xdo","w")
f:write("")
f:close() 
end--if click=nil
if click==nil then click="x:0 y:0 " end
--print (click)
s,f,mousex=string.find(click,"x%p(%d*)%s")
s,f,mousey=string.find(click,"y%p(%d*)%s")
mousex=tonumber(mousex)
mousey=tonumber(mousey)
localx=mousex-abstlx
localy=mousey-abstly
--END CLICK CALCULATIONS #################################
return localx,localy
end--function

i think that should fix it

Offline

Board footer

Powered by FluxBB

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

Debian Logo