You are not logged in.
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
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)
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
^ true
I'm just thinking about continuity with other options and trying to have everything you need integrated into the button function itself
Offline
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?
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
^
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
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!
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
A little closer..
http://youtu.be/cBU2YRxDzuA
...
and...
kinda looks like your traditional conky.. in a way.
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)
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
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
Thank you Peachy.
Thats 200+ lines of out , image and button function.
Doesn't look like it.
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
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)
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
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
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.
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
Still no luck sir.
I think the color table might be different.
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
post the new luacal line and ill test it out
what errors are you getting?
Offline
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
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
i just started my conky and am getting the same error... hmmm
Offline
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})
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
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
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)
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
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
Offline
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.
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
That is sharp Peachy!!
Are you going to run a higher update_interval?
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
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
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