Heh! Speaking of commands...
Here's a cute one, for you:
Kills & reloads your .conkyrc in a single step.Code:killall -SIGUSR1 conky
That's cheating too...
EDIT
BTW, I changed exec to pre_exec, in the script (uses less resources).
Heh! Speaking of commands...
Here's a cute one, for you:
Kills & reloads your .conkyrc in a single step.Code:killall -SIGUSR1 conky
That's cheating too...
EDIT
BTW, I changed exec to pre_exec, in the script (uses less resources).
Last edited by VinDSL; May 21st, 2011 at 11:03 PM.
Intel ® P4 Extreme Edition 3.4 (Gallatin) || DFI ® LanParty PRO875B rev B1
Crucial ® Ballistix Tracer PC4000 1GB || Mountain Mods U2-UFO Opti-1203
XFX 7600GT 560M AGP (PV-T73A-UDF3) || Corsair HX520W Modular PSU
[QUOTE=42dorian;10844053]Yeah, I got bored and did some cleanup on my scripts. Including reducing the number.
@mrpeachy I found there were errors with the way you were doing the positive and negative arcs in a single script (Specifically every time it started it "Forgot" that some of the rings went counter-clockwise, and therefore needed to be "Told" by saving the script again before they would draw the right direction.) Fixed now. So... I kinda compiled everything I know (that you've taught me really) into reformatting the script entirely. It's a bit of a hack job right now, but it's all working. In case you wanted to see it.
if its working then its working but this doesn't seem a very efficient way of doing itCode:require 'cairo' function draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) local angle_0=rstart*(2*math.pi/360)-math.pi/2 local angle_f=rend*(2*math.pi/360)-math.pi/2 local t_arc=(co/100)*(angle_f-angle_0) -- Draw background ring cairo_arc(cr,across,down,rad,angle_0,angle_f) cairo_set_source_rgba(cr,bgr,bgg,bgb,bga) cairo_set_line_width(cr,inlw) cairo_stroke(cr) -- Draw indicator ring cairo_arc(cr,across,down,rad,angle_0,angle_0+t_arc) cairo_set_source_rgba(cr,inr,ing,inb,ina) cairo_stroke(cr) end function conky_draw_pos() if conky_window == nil then return end if cs == nil or cairo_xlib_surface_get_width(cs) ~= conky_window.width or cairo_xlib_surface_get_height(cs) ~= conky_window.height then if cs then cairo_surface_destroy(cs) end cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height) end if cr then cairo_destroy(cr) end cr = cairo_create(cs) local updates=tonumber(conky_parse('${updates}')) if updates>=5 then --NETRING SETUP------------------------------------------------------------------------------------- wtimer=(updates % 30)+1 months = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"} monthnum=tonumber(os.date('%m')) monthname=os.date('%b') day=tonumber(os.date('%d')) if day<12 then if monthnum==1 then monthbeforenum=12 else monthbeforenum=monthnum-1 end month=months[monthbeforenum] else month=monthname end if updates==6 or wtimer==1 then co=(conky_parse("${exec vnstat -m | grep -n '" .. month .. "' | sed -n 1p | awk -F'|' '{print $3}'}")) co=string.gsub(co," ","") num=tonumber((string.gsub(co,"%a",""))) units=(string.gsub(co,"[%p%d]","")) end if num==nil then num=0 end print (num,units) --max number-------------------------- if units=="GB" or units=="GiB" then max=25 end if units =="MB" or units=="MiB" then max=25600 end if units =="KB" or units=="KiB" then max=26214400 end if max==nil then max=0 end --position----------------------------- across=275 down=985 --radius of ring----------------------- rad=30 --ring width--------------------------- inlw=15 --start and end angles--------------- rstart=-135 rend=135 --color and alpha for indicator---- inr,ing,inb,ina=255,0,0,1 --background ring color and alpha----- bgr,bgg,bgb,bga=255,255,0,1 --calculation, do not edit below--------- co=(num/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina) --END NETRING SETUP--------------------------------------------------------------------------------- --SETUP:CPU2 Ring----------------------------------------------------------------------------- --conky object to be displayed----- co=tonumber(conky_parse('${cpu cpu2}')) if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=290 down=455 --radius of ring----------------------- rad=40 --ring width--------------------------- inlw=10 --start and end angles--------------- rstart=180 rend=360 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1 --background ring color and alpha----- bgr,bgg,bgb,bga=1,1,0,1 --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:RAM Ring----------------------------------------------------------------------------- --conky object to be displayed----- co=tonumber(conky_parse('${memperc}')) if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=290 down=455 --radius of ring----------------------- rad=25 --ring width--------------------------- inlw=10 --start and end angles--------------- rstart=-180 rend=180 --color and alpha for indicator---- inr,ing,inb,ina=1,1,1,1.0 --background ring color and alpha----- bgr,bgg,bgb,bga=0.5,0.5,0.5,1.0 --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:SWAP Ring----------------------------------------------------------------------------- --conky object to be displayed----- co=tonumber(conky_parse('${swapperc}')) if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=290 down=455 --radius of ring----------------------- rad=8 --ring width--------------------------- inlw=16 --start and end angles--------------- rstart=-180 rend=180 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1.0 --background ring color and alpha----- bgr,bgg,bgb,bga=1,1,1,0.75 --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:7GBACKUP3 Ring----------------------------------------------------------------------------- --conky object to be displayed----- mounted=conky_parse('${if_mounted /media/7GBACKUP3}1${else}0${endif}') if tonumber(mounted)==1 then co=tonumber(conky_parse('${fs_used_perc /media/7GBACKUP3}')) else co=0 end if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=240 down=695 --radius of ring----------------------- rad=45 --ring width--------------------------- inlw=5 --start and end angles--------------- rstart=180 rend=270 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1.0 --background ring color and alpha----- mounted=conky_parse('${if_mounted /media/7GBACKUP3}1${else}0${endif}') if tonumber(mounted)==1 then bgr,bgg,bgb,bga=0.75,0.75,0,1.0 else bgr,bgg,bgb,bga=1,1,1,1.0 end --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:120 Ring----------------------------------------------------------------------------- --conky object to be displayed----- mounted=conky_parse('${if_mounted /media/120}1${else}0${endif}') if tonumber(mounted)==1 then co=tonumber(conky_parse('${fs_used_perc /media/120}')) else co=0 end if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=240 down=695 --radius of ring----------------------- rad=45 --ring width--------------------------- inlw=5 --start and end angles--------------- rstart=270 rend=360 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1.0 --background ring color and alpha----- mounted=conky_parse('${if_mounted /media/120}1${else}0${endif}') if tonumber(mounted)==1 then bgr,bgg,bgb,bga=0.75,0.75,0,1.0 else bgr,bgg,bgb,bga=1,1,1,1.0 end --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:Sansa Ring----------------------------------------------------------------------------- --conky object to be displayed----- wtimer=(updates % 30)+1 if updates==6 or wtimer==1 then mounted=conky_parse("${if_match ${exec df -h | grep -c 'SANSA CLIPP'} == 1}1${else}0${endif}") end if tonumber(mounted)==1 then co=tonumber(conky_parse("${exec df -h | grep 'SANSA CLIPP' | awk '{print $5}' | sed 's/%//'}")) else co=0 end if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=328 down=670 --radius of ring----------------------- rad=5 --ring width--------------------------- inlw=5 --start and end angles--------------- rstart=-180 rend=180 --color and alpha for indicator---- inr,ing,inb,ina=1,0.75,0,1.0 --background ring color and alpha----- bgr,bgg,bgb,bga=0,0,0,0.0 --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:OS USB Stick Ring----------------------------------------------------------------------------- --conky object to be displayed----- mounted=conky_parse('${if_mounted /media/OSUSB}1${else}0${endif}') if tonumber(mounted)==1 then co=tonumber(conky_parse('${fs_used_perc /media/OSUSB}')) else co=0 end if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=325 down=730 --radius of ring----------------------- rad=5 --ring width--------------------------- inlw=5 --start and end angles--------------- rstart=-180 rend=180 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1.0 --background ring color and alpha----- bgr,bgg,bgb,bga=0,0,0,0.0 --calculation, do not edit below--------- co=(co/max)*100 draw_ring_pos(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- end end --NEGATIVE ARCS------------------------------------------------------------------------------------------- require 'cairo' function draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) local angle_0=rstart*(2*math.pi/360)-math.pi/2 local angle_f=rend*(2*math.pi/360)-math.pi/2 local t_arc=(co/100)*(angle_f-angle_0) -- Draw background ring cairo_arc(cr,across,down,rad,angle_0,angle_f) cairo_set_source_rgba(cr,bgr,bgg,bgb,bga) cairo_set_line_width(cr,inlw) cairo_stroke(cr) -- Draw indicator ring local angle_0_r=rend*(2*math.pi/360)-math.pi/2 local angle_f_r=rstart*(2*math.pi/360)-math.pi/2 local t_arc=(co/100)*(angle_f_r-angle_0_r) cairo_arc_negative(cr,across,down,rad,angle_0_r,angle_0_r+t_arc) cairo_set_source_rgba(cr,inr,ing,inb,ina) cairo_stroke(cr) end function conky_draw_neg() if conky_window == nil then return end if cs == nil or cairo_xlib_surface_get_width(cs) ~= conky_window.width or cairo_xlib_surface_get_height(cs) ~= conky_window.height then if cs then cairo_surface_destroy(cs) end cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height) end if cr then cairo_destroy(cr) end cr = cairo_create(cs) local updates=tonumber(conky_parse('${updates}')) if updates>=5 then --SETUP:CPU Ring----------------------------------------------------------------------------- --conky object to be displayed----- co=tonumber(conky_parse('${cpu cpu1}')) if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=290 down=455 --radius of ring----------------------- rad=40 --ring width--------------------------- inlw=10 --start and end angles--------------- rstart=0 rend=180 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1 --background ring color and alpha----- bgr,bgg,bgb,bga=1,1,0,1 --calculation, do not edit below--------- co=(co/max)*100 draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:7GBACKUP Ring----------------------------------------------------------------------------- --conky object to be displayed----- mounted=conky_parse('${if_mounted /media/7GBACKUP}1${else}0${endif}') if tonumber(mounted)==1 then co=tonumber(conky_parse('${fs_used_perc /media/7GBACKUP}')) else co=0 end if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=240 down=695 --radius of ring----------------------- rad=45 --ring width--------------------------- inlw=5 --start and end angles--------------- rstart=0 rend=90 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1.0 --background ring color and alpha----- mounted=conky_parse('${if_mounted /media/7GBACKUP}1${else}0${endif}') if tonumber(mounted)==1 then bgr,bgg,bgb,bga=0.75,0.75,0,1.0 else bgr,bgg,bgb,bga=1,1,1,1.0 end --calculation, do not edit below--------- co=(co/max)*100 draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- --SETUP:7GBACKUP2 Ring----------------------------------------------------------------------------- --conky object to be displayed----- mounted=conky_parse('${if_mounted /media/7GBACKUP2}1${else}0${endif}') if tonumber(mounted)==1 then co=tonumber(conky_parse('${fs_used_perc /media/7GBACKUP2}')) else co=0 end if co==nil then co=0 end --max number-------------------------- max=100 --position----------------------------- across=240 down=695 --radius of ring----------------------- rad=45 --ring width--------------------------- inlw=5 --start and end angles--------------- rstart=90 rend=180 --color and alpha for indicator---- inr,ing,inb,ina=1,0,0,1.0 --background ring color and alpha----- mounted=conky_parse('${if_mounted /media/7GBACKUP2}1${else}0${endif}') if tonumber(mounted)==1 then bgr,bgg,bgb,bga=0.75,0.75,0,1.0 else bgr,bgg,bgb,bga=1,1,1,1.0 end --calculation, do not edit below--------- co=(co/max)*100 draw_ring_neg(co, across, down, rad, inlw, rstart, rend, bgr, bgg, bgb, bga, inr, ing, inb, ina, direction) --END SETUP---------------copy setup section and paste for additional rings---------- end end
seeing as you have 2 separate function, one that draws positive and one that draws negative, you really dont need two main function called seperately in the conky rc
just copy all the setups and drawing function calls from function conky_draw_neg() into
function conky_draw_pos()
like so
you can also remove direction as a setting sent to the function as it no longer serves any purposeCode:function negative(x,y,z) end function positive(x,y,z) end function main setup positive ring x=x y=y z=z call positive ring function positive (x,y,z) setup negative ring x=x y=y z=z negative (x,y,z) end main function
i think its always a good idea to keep track of your variables and keep them in check
ive started putting lines like this at the end of the main functions
a good idea borrowed from wlorfs scriptsCode:end-- if updates>5 cairo_destroy(cr) cairo_surface_destroy(cs) cr=nil end-- end main function
and sometimes it is easier to draw rings without the need for functions at all, when you just need one or two
for exampleCode:cairo_set_source_rgba (cr,0.5,0.5,0.5,1) cairo_set_line_width (cr,14) cairo_arc (cr,sx,sy,117,((math.pi)/180)*(92.5),((math.pi)/180)*(175)) cairo_stroke (cr) root=conky_parse("${fs_used_perc /}") cairo_set_source_rgba (cr,102/255,122/255,119/255,1) cairo_arc_negative (cr,sx,sy,117,((math.pi)/180)*(175),((math.pi)/180)*(175-((82.5)*(root/100)))) cairo_stroke (cr)
sx and sy are defined elsewhere in the script
understanding what the numbers mean in the various cairo commands is extremely important
Last edited by mrpeachy; May 21st, 2011 at 11:23 PM.
I just reinstalled my system, so some specs changed, and obviously I also went for a new, fresh look. This brought a need for a semi-transparent conky background.
I used the conky+compiz method to get it semi transparnt, but the effect is BAD: everything in conky is semitransparent now, including text, pictures and graphs, and I want only the background transparent.
Any tips?
Oh... sorry mrpeachy... I don't mean YOU were doing it wrong, I mean that I was getting errors when it ran the old way. It wasn't drawing the negative rings in the negative when I first started it, so I had to save the script before it would draw them properly. And now it draws them perfectly every time.
I'm quite aware of the massive inefficiency of the code as it is. But, it works for me, and I actually understand enough of it that I can fix it if it breaks (to a degree.) and I still don't quite get what you just told me. I am, by far, not your best student. Thank You though! Ultimately I only brought it to your attention in case you got offended that I wedged the netring in the way I did.
I kinda get the surface destroy at the end of the function part though. I think I might add that eventually.
if i post some code on a forum then people can do whatever they want with it and i wont get offended
unfortunately i don't have the original script to test, as i would like to find out what was going on for future reference
you arent the first person who has tried a script i wrote that didnt work, and upon later inspection turned out it was a mistake in the script by me causing the problem
sun.lua
sun.shCode:--sun position lua script by mrpeachy 2010 --input latitude --for northern hemisphere enter positive --for southern hemisphere enter negative latitude=45.8333 --VARESE ITALY-- --input hemisphere --for northern enter 1 --for southern enter 2 hemisphere=1 --edit the below line to input location of bash script --in this case i have called the script "sundata.sh" location=('${exec /home/deegan/sun.sh}') require 'cairo' function addzero10(num) if tonumber(num) < 10 then return "0" .. num else return num end end function round(val, decimal) if (decimal) then return math.floor( (val * 10^decimal) + 0.5) / (10^decimal) else return math.floor(val+0.5) end end function string:split(delimiter) local result = { } local from = 1 local delim_from, delim_to = string.find( self, delimiter, from ) while delim_from do table.insert( result, string.sub( self, from , delim_from-1 ) ) from = delim_to + 1 delim_from, delim_to = string.find( self, delimiter, from ) end table.insert( result, string.sub( self, from ) ) return result end function conky_draw_newconky() if conky_window == nil then return end local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height) cr = cairo_create(cs) local updates=tonumber(conky_parse('${updates}')) if updates ==5 then test=(conky_parse(location)) end if updates > 5 then if updates == 10 then test=(conky_parse('${exec /home/deegan/sun.sh}')) end timer=(updates % 600)+1 if timer==1 then test=(conky_parse('${exec /home/deegan/sun.sh}')) end test2=string.split(test, ":") sunrisehours=test2[1] sunrisemins=test2[2] sunsethours=(test2[6])+12 sunsetmins=test2[7] --time at sunrise and sunset in minutes sun1=(test2[1]*60)+test2[2] sun2=((test2[6]+12)*60)+test2[7] sunlength=sun2-sun1 if tonumber(test2[3])<12 and test2[5]=="PM" then sunhighhrs=(test2[3])+12 else sunhighhrs=test2[3] end --time at solar noon in mins sun3=(sunhighhrs*60)+(test2[4]) --calculate current time hrs=os.date("%H") min=os.date("%M") current=(hrs*60)+min total=(24*60) --calculate offset to make solar noon at top sundiff=(12*60)-sun3 --civil twilight for sunrise ctr=(test2[8]*60)+test2[9] --civil twilight for sunset cts=((test2[10]+12)*60)+test2[11] --sunrise altitude ralt=test2[12] --solar noon altitude snalt=test2[13] --sunset altitude salt=test2[14] --sunrize azimuth rz=test2[15] --solar noon azimuth na=test2[16] --sunset azimuth sz=test2[17] --sun declination (average of rise, noon and set) sdec=(test2[18]+test2[19]+test2[20])/3 --sin(Alt) = cos(Lat) cos(Decl) cos(HAngle) + sin(Lat) sin(Dec) --calculate altitude at solar noon current=sun3 sha=(current-sun3)*(15/60) cossha=math.cos(math.rad(sha)) cossundec=math.cos(math.rad(sdec)) coslat=math.cos(math.rad(latitude)) cosmath=cossha*cossundec*coslat sinsundec=math.sin(math.rad(sdec)) sinlat=math.sin(math.rad(latitude)) sinmath=sinsundec*sinlat sinelevation=cosmath+sinmath elevation=math.deg(math.asin(sinelevation)) snalt=elevation --calculate altitude at solar midnight current=sun3+(12*60) sha=(current-sun3)*(15/60) cossha=math.cos(math.rad(sha)) cossundec=math.cos(math.rad(sdec)) coslat=math.cos(math.rad(latitude)) cosmath=cossha*cossundec*coslat sinsundec=math.sin(math.rad(sdec)) sinlat=math.sin(math.rad(latitude)) sinmath=sinsundec*sinlat sinelevation=cosmath+sinmath elevation=math.deg(math.asin(sinelevation)) smalt=elevation*-1 --calculate sha when altitude=0 --sin(Alt) = cos(Lat) cos(Decl) cos(HAngle) + sin(Lat) sin(Dec) sinalt0=math.sin(math.rad(0)) alt0math1=sinalt0-(sinlat*sinsundec) alt0math2=alt0math1/coslat alt0cossha=alt0math2/cossundec shaalt0=math.deg(math.acos(alt0cossha)) alt0time1=shaalt0/(15/60) alt0time=(alt0time1+sun3) --calculate current solar altitude current=(hrs*60)+min sha=(current-sun3)*(15/60) cossha=math.cos(math.rad(sha)) cossundec=math.cos(math.rad(sdec)) coslat=math.cos(math.rad(latitude)) cosmath=cossha*cossundec*coslat sinsundec=math.sin(math.rad(sdec)) sinlat=math.sin(math.rad(latitude)) sinmath=sinsundec*sinlat sinelevation=cosmath+sinmath elevation=math.deg(math.asin(sinelevation)) curaltlong=elevation curalt=round(curaltlong,2) --calculate current azimuth azmath1=(cossha*cossundec*sinlat)-(sinsundec*coslat) azmath2=math.cos(math.rad(elevation)) cosaz=azmath1/azmath2 azi1=math.deg(math.acos(cosaz)) azi2=round(azi1, 2) if sha>0 then azi=azi2+180 else azi=(azi2-180)*-1 end if current==sundiff*-1 then azi=180 else end --setup position horizontal=100 vertical=150 radius=(snalt+(smalt))/2 raddiff=(snalt-smalt)/2 across=horizontal down=vertical --plot arc points arc shatable={} alttable={} azitable={} for i = 0, 24*60 do sha=(i-sun3)*(15/60) shatable[i]=sha end for i = 0, 24*60 do sha=shatable[i] cossha=math.cos(math.rad(sha)) cossundec=math.cos(math.rad(sdec)) coslat=math.cos(math.rad(latitude)) cosmath=cossha*cossundec*coslat sinsundec=math.sin(math.rad(sdec)) sinlat=math.sin(math.rad(latitude)) sinmath=sinsundec*sinlat sinelevation=cosmath+sinmath elevationplot=math.deg(math.asin(sinelevation)) curaltlong=elevationplot altplot=round(curaltlong,2) alttable[i]=altplot end for i = 0, 24*60 do azmath1=(math.cos(math.rad(shatable[i]))*cossundec*sinlat)-(sinsundec*coslat) azmath2=math.cos(math.rad(alttable[i])) cosaz=azmath1/azmath2 azi1=math.deg(math.acos(cosaz)) aziplot=round(azi1, 2) if i>0 and i<sundiff*-1 then azitable[i]=aziplot*-1 else if i<(sun3) then azitable[i]=aziplot else azitable[i]=aziplot*-1 end end end --sin(Alt) = cos(Lat) cos(Decl) cos(HAngle) + sin(Lat) sin(Dec) --calculate hour angle of sun at altitude 0 hamath1=math.sin(math.rad(0))-(sinlat*sinsundec) hamath2=hamath1/(coslat*cossundec) --calculate azimuth at the hour angle at 0 altitude azmath1=(hamath2*cossundec*sinlat)-(sinsundec*coslat) azmath2=math.cos(math.rad(0)) cosaz=azmath1/azmath2 azi1=math.deg(math.acos(cosaz)) azi0alt=(round(azi1, 2))+start outer1=radius text_arc=((2*math.pi/(360))*(azi0alt))+((2*math.pi/(360))*(180)) tyshp=0+outer1*(math.cos(text_arc)) --horizontal position horipos={} for i=0,24*60 do outer1=radius text_arc=(2*math.pi/(360))*(azitable[i])+((2*math.pi/(360))*(180)) txshp=0-outer1*(math.sin(text_arc)) horipos[i]=txshp end for i=0,24*60 do circrad=0.5 circx=across-horipos[i] circy=down-alttable[i]+tyshp cairo_arc(cr,circx,circy,circrad,0,2*math.pi) cairo_close_path(cr) cairo_set_source_rgba(cr,0.4,0.4,0.4,1) cairo_fill (cr) end --end of plot current=(hrs*60)+min sha=(current-sun3)*(15/60) --draw south-north cairo_move_to (cr, across, down+smalt+tyshp) cairo_line_to (cr, across, down-snalt+tyshp) cairo_set_source_rgba(cr,0.5,0.5,0.5,1) cairo_set_line_width (cr, 1) cairo_stroke (cr) --draws horizon stationary cairo_move_to (cr, horizontal-100, down+tyshp) cairo_rel_line_to (cr, 200, 0) cairo_set_source_rgba(cr,0.5,0.5,0.5,1) cairo_set_line_width (cr, 1) cairo_stroke (cr) --draws current sun position outer1=radius text_arc=((2*math.pi/(360))*(azi))+((2*math.pi/(360))*(start)) txs=0-outer1*(math.sin(text_arc)) circrad=1.6 circx=across+txs circy=down-curalt+tyshp cairo_arc(cr,circx,circy,circrad,0,2*math.pi) cairo_close_path(cr) cairo_set_source_rgba(cr,1,1,1,1) cairo_fill (cr) --draws text label cairo_select_font_face (cr, "Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, 10); cairo_set_source_rgba (cr, 1, 1, 1, 1); --current values above cairo_move_to (cr, across-100, down-radius-40) cairo_show_text (cr, "Time " .. addzero10(hrs) .. ":" .. min) cairo_move_to (cr, across-100, down-radius-30) cairo_show_text (cr, "Azimuth " .. azi .. "°") cairo_move_to (cr, across-100, down-radius-20) cairo_show_text (cr, "Altitude " .. curalt .. "°") --table cairo_move_to (cr, across-100, down+radius+40) cairo_show_text (cr, "Time ") cairo_move_to (cr, across-100, down+radius+50) cairo_show_text (cr, "Altitude ") cairo_move_to (cr, across-100, down+radius+60) cairo_show_text (cr, "Azimuth ") --titles sr=-45 sn=5 ss=70 cairo_move_to (cr, across+sr, down+radius+30) cairo_show_text (cr, "Sunrise") cairo_move_to (cr, across+sn, down+radius+30) cairo_show_text (cr, "Solar Noon") cairo_move_to (cr, across+ss, down+radius+30) cairo_show_text (cr, "Sunset") sr=-38 sn=15 ss=72.5 cairo_move_to (cr, across+sr, down+radius+40) cairo_show_text (cr, addzero10(test2[1]) .. ":" .. test2[2]) cairo_move_to (cr, across+sr, down+radius+50) cairo_show_text (cr, test2[12] .. "°") cairo_move_to (cr, across+sr, down+radius+60) cairo_show_text (cr, test2[15] .. "°") if test2[5]=="PM" and tonumber(test2[3])<12 then sntime=(test2[3])+12 else sntime=addzero10(test2[3]) end cairo_move_to (cr, across+sn, down+radius+40) cairo_show_text (cr, sntime .. ":" .. test2[4]) cairo_move_to (cr, across+sn, down+radius+50) cairo_show_text (cr, test2[13] .. "°") cairo_move_to (cr, across+sn, down+radius+60) cairo_show_text (cr, test2[16] .. "°") cairo_move_to (cr, across+ss, down+radius+40) cairo_show_text (cr, (test2[6]+12) .. ":" .. test2[7]) cairo_move_to (cr, across+ss, down+radius+50) cairo_show_text (cr, test2[14] .. "°") cairo_move_to (cr, across+ss, down+radius+60) cairo_show_text (cr, test2[17] .. "°") cairo_move_to (cr, across-100, down+radius+80) cairo_show_text (cr, "Length of Day " .. test2[21]) cairo_move_to (cr, across-100, down+radius+90) cairo_show_text (cr, "Tomorrow will be " .. test2[22]) snz=round(test2[16],0) if snz==180 then cairo_move_to (cr, across-3, down+tyshp-snalt-5) cairo_show_text (cr, "S") cairo_move_to (cr, across-3, down+tyshp+smalt+12) cairo_show_text (cr, "N") else if snz==360 then cairo_move_to (cr, across-3, down+tyshp-snalt-5) cairo_show_text (cr, "N") cairo_move_to (cr, across-3, down+tyshp+smalt+12) cairo_show_text (cr, "S") end end if curalt>-5 and curalt<5 and sha<0 then cairo_move_to (cr, across-100, down-radius-10) cairo_show_text (cr, "Sunrise") else if curalt<5 and curalt>-5 and sha>0 then cairo_move_to (cr, across-100, down-radius-10) cairo_show_text (cr, "Sunset") else if sha>-2 and sha<2 then cairo_move_to (cr, across-100, down-radius-10) cairo_show_text (cr, "Solar Noon") end end end end end
.conkyrcCode:#!/bin/bash #!/bin/bash #Setup nstructions. #you will need to go to www.wunderground.com and locate your town/city #then scroll down untill you see the astronomy section #click on the button marked "extended view" #copy the resulting web address into the line beginning with "curl" below #in place of the existing address (which is for St Louis, MO) ## curl "http://www.wunderground.com/US/MO/Saint_Louis.html?MR=0&extendedsun=sunon" { curl "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Varese,%20Italy" }>/tmp/sundata.html { cat /tmp/sundata.html | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=3 s="<td>Actual Time</td>" cat /tmp/sundata.html | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=3 s="<td>Civil Twilight</td>" cat /tmp/sundata.html | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=3 s="<td>Altitude</td>" cat /tmp/sundata.html | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=3 s="<td>Azimuth</td>" cat /tmp/sundata.html | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=3 s="<td>Sun Declination</td>" cat /tmp/sundata.html | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=2 s="<td>Length of Day</td>" cat /tmp/sundata.html | grep -n 'Tomorrow will be' | sed -n 1p | awk -F'</span>.</div>' '{print $1}' }>/tmp/sundata.txt { #real time sunrise - hours and minutes cat /tmp/sundata.txt | grep -n '<td>' | sed -n 2p | awk -F'AM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat /tmp/sundata.txt | grep -n '<td>' | sed -n 2p | awk -F'AM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $2}' | sed 's| ||g' #real time solar noon - hours, minutes, am or pm cat /tmp/sundata.txt | grep -n '<td>' | sed -n 3p | awk -F'<td>' '{print $2}' | awk -F' ' '{print $1}' | awk -F':' '{print $1}' | sed 's|[ AMPM]||g' cat /tmp/sundata.txt | grep -n '<td>' | sed -n 3p | awk -F'<td>' '{print $2}' | awk -F' ' '{print $1}' | awk -F':' '{print $2}' | sed 's|[ AMPM]||g' cat /tmp/sundata.txt | grep -n '<td>' | sed -n 3p | awk -F'<td>' '{print $2}' | awk -F' ' '{print $2}' | sed 's|[0-9 ]||g' #real time sunset - hours and minutes cat /tmp/sundata.txt | grep -n '<td>' | sed -n 4p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat /tmp/sundata.txt | grep -n '<td>' | sed -n 4p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $2}' | sed 's| ||g' #civil twilight- sunrise - hours and minutes cat /tmp/sundata.txt | grep -n '<td>' | sed -n 6p | awk -F'AM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat /tmp/sundata.txt | grep -n '<td>' | sed -n 6p | awk -F'AM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $2}' | sed 's| ||g' #civil twilight- sunset - hours and minutes cat /tmp/sundata.txt | grep -n '<td>' | sed -n 8p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat /tmp/sundata.txt | grep -n '<td>' | sed -n 8p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $2}' | sed 's| ||g' #altitude at sunrise cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 1p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #altitude at solar noon cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 2p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #altitude at sunset cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 3p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #azimuth at sunrise cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 4p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #azimuth at solar noon cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 5p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #azimuth at sunset cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 6p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #declination at sunrise cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 7p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #declination at solar noon cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 8p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #declination at sunset cat /tmp/sundata.txt | grep -n '°</td>' | sed -n 9p | awk -F'°</td>' '{print $1}' | awk -F'<td>' '{print $2}' | sed 's| ||g' #length of day cat /tmp/sundata.txt | grep -n '</div>' | sed -n 1p | awk -F'</div>' '{print $1}' | awk -F'<div>' '{print $2}' #tomorrow will be cat /tmp/sundata.txt | grep -n '<span class="b">' | sed -n 1p | awk -F'<span class="b">' '{print $2}' }>/tmp/sundata2.txt { sed 's/$/:/' /tmp/sundata2.txt | tr -d '\n' }>/tmp/sundata3.txt cat /tmp/sundata3.txt
ERRORCode:#<<== LUA ==>># lua_load ~/sun.lua lua_draw_hook_pre draw_newconky TEXT
/home/deegan/sun.lua:69Code:Lucid ~~»» conky -c .conkyrc3 Conky: desktop window (12000ba) is subwindow of root window (b8) Conky: window type - override Conky: drawing to created window (0x3000001) Conky: drawing to double buffer % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 192k 0 192k 0 0 94430 0 --:--:-- 0:00:02 --:--:-- 108k Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 192k 0 192k 0 0 93578 0 --:--:-- 0:00:02 --:--:-- 107k Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/deegan/sun.lua:69: attempt to perform arithmetic on field '?' (a string value) ^CConky: received SIGINT or SIGTERM to terminate. bye! Lucid ~~»»
sunsethours=(test2[6])+12
----
How could I resolve?
Thanks
Anyone have an idea of how I could set up conky to show my current user-agent?
Life is an extraordinarily long concatenation of luck and coincidence.
Hi Degan
I just posted an updated version of this script here
http://crunchbanglinux.org/forums/post/123465/#p123465
take a look and see if that script works for you
the whole sun moon concept is still a work in progress
do you use more than 1 browser?
this site tells you your user-agent
http://whatsmyuseragent.com/
but the problem is you cant use curl to access the site because then the user-agent is curl and not your browser
i wrote a lua script that lets conky display open windows and identify the active window
http://crunchbanglinux.org/forums/post/121198/#p121198
if you have more than one type of browser open then you could identify which was active and then display info from whatismyuseragent
but i cant think of any simple way
Last edited by mrpeachy; May 22nd, 2011 at 02:24 AM.
Intel ® P4 Extreme Edition 3.4 (Gallatin) || DFI ® LanParty PRO875B rev B1
Crucial ® Ballistix Tracer PC4000 1GB || Mountain Mods U2-UFO Opti-1203
XFX 7600GT 560M AGP (PV-T73A-UDF3) || Corsair HX520W Modular PSU
Bookmarks