Honestly? Me too.
I'm too bored too fast to master it
Honestly? Me too.
I'm too bored too fast to master it
Linux Debian Sid (Minted) x86_64/3.12.10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Lenovo T61, Intel X3100, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | My Conky Pitstop corner | One4All project
trying to get mrpeachy's sun lua script working but not getting it right.
getting the following error:
here are my files:Code:% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 172k 0 172k 0 0 59480 0 --:--:-- 0:00:02 --:--:-- 67904 Conky: llua_do_call: function conky_draw_newconky execution failed: /home/wayne/conky/sun.lua:73: attempt to perform arithmetic on field '?' (a nil value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/wayne/conky/sun.lua:73: attempt to perform arithmetic on field '?' (a nil value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/wayne/conky/sun.lua:73: attempt to perform arithmetic on field '?' (a nil value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/wayne/conky/sun.lua:73: attempt to perform arithmetic on field '?' (a nil value) Conky: llua_do_call: function conky_draw_newconky execution failed: /home/wayne/conky/sun.lua:73: attempt to perform arithmetic on field '?' (a nil value)
sundata.sh
sun.luaCode:#!/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/global/stations/68368.html?MR=0&extendedsun=sunon" }>~/conky/sundata/sundata.html { cat ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/sundata.html | grep -n 'Tomorrow will be' | sed -n 1p | awk -F'</span>.</div>' '{print $1}' }>~/conky/sundata/sundata.txt { #real time sunrise - hours and minutes cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 2p | awk -F'AM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | 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 ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 3p | awk -F'SAST' '{print $2}' | awk -F' ' '{print $1}' | awk -F':' '{print $1}' | sed 's|[ AMPM]||g' cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 3p | awk -F'SAST' '{print $2}' | awk -F' ' '{print $1}' | awk -F':' '{print $2}' | sed 's|[ AMPM]||g' cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 3p | awk -F'SAST' '{print $2}' | awk -F' ' '{print $2}' | sed 's|[0-9 ]||g' #real time sunset - hours and minutes cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 4p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | 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 ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 6p | awk -F'AM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | 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 ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 8p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $1}' | sed 's| ||g' cat ~/conky/sundata/sundata.txt | grep -n 'SAST' | sed -n 8p | awk -F'PM' '{print $1}' | awk -F'<td>' '{print $2}' | awk -F':' '{print $2}' | sed 's| ||g' #altitude at sunrise cat ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/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 ~/conky/sundata/sundata.txt | grep -n '</div>' | sed -n 1p | awk -F'</div>' '{print $1}' | awk -F'<div>' '{print $2}' #tomorrow will be cat ~/conky/sundata/sundata.txt | grep -n '<span class="b">' | sed -n 1p | awk -F'<span class="b">' '{print $2}' }>~/conky/sundata/sundata2.txt { sed 's/$/:/' ~/conky/sundata/sundata2.txt | tr -d '\n' }>~/conky/sundata/sundata3.txt cat ~/conky/sundata/sundata3.txt
conkysunCode:--sun position lua script by mrpeachy 2010 --input latitude --for northern hemisphere enter positive --for southern hemisphere enter negative latitude=-26.29 --input hemisphere --for northern enter 1 --for southern enter 2 hemisphere=2 --edit the below line to input location of bash script --in this case i have called the script "sundata.sh" location=('${exec /home/wayne/conky/sundata.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 > 10 then if hemisphere==1 then start=0 else start=180 end timer=(updates % 600)+1 if timer==1 then test=(conky_parse(location)) 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
any help would be appreciated.Code:use_xft yes xftfont LiberationSans:size=9 xftalpha 0.1 text_buffer_size 2048 override_utf8_locale yes update_interval 1 total_run_times 0 own_window yes own_window_type override own_window_transparent yes double_buffer yes draw_shades no draw_outline no draw_borders no draw_graph_borders no out_to_console no out_to_ncurses no alignment tr minimum_size 400 400 default_bar_size 0 4 gap_x 20 gap_y 20 short_units yes pad_percents 0 top_name_width 10 no_buffers no uppercase no cpu_avg_samples 8 net_avg_samples 2 use_spacer none color0 White color1 Ivory color2 Ivory2 color3 Ivory3 color4 Tan1 color5 Tan2 color6 Gray color7 AntiqueWhite4 color8 DarkSlateGray color9 Black lua_load ~/conky/sun.lua lua_draw_hook_pre draw_newconky TEXT
Last edited by thekeeperza; May 29th, 2011 at 06:48 AM.
i re-wrote that script
try this one instead
http://crunchbanglinux.org/forums/post/124127/#p124127
it needs conkyForecast to run
any conkyForecast i think... as long as you can get sunset and sunrise times from it
it isnt necessary in terms of the graph, but you will get errors if you dont have conkyForecast
also @thekeeperza can you change your quote boxes to code boxes please
thats a pretty long script
Well, I have conkyForecast v2.20 and conkyLatLong so I went crazy!
Popped in lats and longs in DD° MM' SS" and tossed in the Moon Phase and hours until sunrise or set whichever is next - and of course: HOME!
Sunrise "time" will be yellow, sunset "time" will be black.
conky
SunMoon.luaCode:## Sun Conky ## LUA by: mrpeachy ## killall conky && conky -c ~/Conky/OB_SunMoon2 background no own_window yes own_window_type override own_window_transparent yes own_window_hints undecorated,below,skip_taskbar,skip_pager own_window_title SunMoon own_window_class SunMoon override_utf8_locale yes use_xft yes uppercase no # set to yes if you want all text to be in uppercase stippled_borders 0 border_inner_margin 0 border_width 0 default_outline_color black default_shade_color black draw_borders no draw_graph_borders no draw_outline no draw_shades no # Colours default_color white #DCDCDC #Gainsboro color0 FFFFF0 #Ivory color1 778899 #LightSlateGrey color2 000000 #Black color3 7FFF00 #Chartreuse color4 FFA07A #LightSalmon color5 FFDEAD #NavajoWhite color6 00BFFF #DeepSkyBlue color7 48D1CC #MediumTurquoise color8 FFFF00 #Yellow color9 FF0000 #Red text_buffer_size 1028 double_buffer yes no_buffers yes short_units yes pad_percents 2 imlib_cache_size 0 minimum_size 360 320 maximum_width 360 alignment tl # tl, tr, tm, bl, br, bm, ml, mr gap_x 280 # left-right gap_y 665 # up-down update_interval 1 xftfont snap:bold:size=8 xftalpha 1.0 lua_load ~/Conky/LUA/SunMoon.lua lua_draw_hook_pre draw_fig TEXT ${image ~/Conky/images/Earth_SH.png -p 157,180 -s 43x40} Moon: ${color2}${execpi 1800 conkyForecast --location=ARBA0009 --datatype=MP} ${color}${if_match "${exec conkyForecast-SunsetSunriseCountdown --location=ARBA0009 -t}"=="Sunrise"}Sunrise in: ${color8}${exec conkyForecast-SunsetSunriseCountdown --location=ARBA0009}${else}Sunset in: (color black)${exec conkyForecast-SunsetSunriseCountdown --location=ARBA0009}${endif} ${color2}${exec conkyLatLong -i}
Code:--[[ sun and moon position chart by mrpeachy may 2011 call in conkyrc like so lua_load /path to file/fiename.lua lua_draw_hook_pre draw_fig ]] require 'cairo' function string:split(delimiter) local result = { } local from = 1 local delim_from, delim_to = string.find( self, delimiter, from ) while delim_from do table.insert( result, string.sub( self, from , delim_from-1 ) ) from = delim_to + 1 delim_from, delim_to = string.find( self, delimiter, from ) end table.insert( result, string.sub( self, from ) ) return result end -------------------------------------------------------------------------------- function conky_draw_fig() if conky_window == nil then return end local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height) cr = cairo_create(cs) local updates=tonumber(conky_parse('${updates}')) if updates>5 then --######################################################################################################### --######################################################################################################### Y=tostring(os.date("%Y")) M=tostring(os.date("%m")) D=tostring(os.date("%d")) --INPUT DATA I=5 -- interval, if changed then kill/restart, set 1, 5 or 10. shorter interval increases cpu load LEW="-1" -- -1 for west, 1 for east LOD="58" --longitude degrees LOM="28" --longitude minutes LNS="-1" -- 1 for north, -1 for south LAD="34" --latitude degrees LAM="37" --latitude minutes TZ="3" --timezone GEW="-1" -- -1 for west of Greenwich, 1 for east of Greenwich scale=1 center_y=200 left_x=0 -------------------------------------------------------------- delay=1800 -- time between info gathering, much like execi interval -------------------------------------------------------------- timer=(updates % delay)+1 --fetch sun and moon info if timer==1 or updates==10 or tostring(os.date("%H:%M:%S"))=="00:00:00" then os.execute ('curl -f --data "FFX=2&obj=11&xxy=' .. Y .. '&xxm=' .. M .. '&xxd=' .. D .. '&xxi=' .. I .. '&place=%28no+name+given%29&xx0=' .. LEW .. '&xx1=' .. LOD .. '&xx2=' .. LOM .. '&yy0=' .. LNS .. '&yy1=' .. LAD .. '&yy2=' .. LAM .. '&zz1=' .. TZ .. '&zz0=' .. GEW .. '&ZZZ=END" http://aa.usno.navy.mil/cgi-bin/aa_altazw.pl > /tmp/moon.txt') os.execute ('curl -f --data "FFX=2&obj=10&xxy=' .. Y .. '&xxm=' .. M .. '&xxd=' .. D .. '&xxi=' .. I .. '&place=%28no+name+given%29&xx0=' .. LEW .. '&xx1=' .. LOD .. '&xx2=' .. LOM .. '&yy0=' .. LNS .. '&yy1=' .. LAD .. '&yy2=' .. LAM .. '&zz1=' .. TZ .. '&zz0=' .. GEW .. '&ZZZ=END" http://aa.usno.navy.mil/cgi-bin/aa_altazw.pl > /tmp/sun.txt') local f = io.popen("cat /tmp/moon.txt | head -20 | tail -6") topper= f:read("*a") f:close() local f = io.popen("cat /tmp/moon.txt | grep ':' | awk '{print $3}'") azimuth= f:read("*a") f:close() local f = io.popen("cat /tmp/moon.txt | grep ':' | awk '{print $2}'") altitude= f:read("*a") f:close() local f = io.popen("cat /tmp/moon.txt | grep ':' | awk '{print $1}'") mtime= f:read("*a") f:close() local f = io.popen("cat /tmp/sun.txt | grep ':' | awk '{print $3}'") sazimuth= f:read("*a") f:close() local f = io.popen("cat /tmp/sun.txt | grep ':' | awk '{print $2}'") saltitude= f:read("*a") f:close() local f = io.popen("cat /tmp/sun.txt | grep ':' | awk '{print $1}'") stime= f:read("*a") f:close() --format moon tables aztab=string.split(azimuth,"\n") alttab=string.split(altitude,"\n") timetab=string.split(mtime,"\n") table.remove(alttab) table.remove(alttab) table.remove(alttab,1) table.remove(alttab,1) table.remove(aztab) table.remove(aztab) table.remove(aztab,1) table.remove(aztab,1) table.remove(timetab) table.remove(timetab) table.remove(timetab,1) table.remove(timetab,1) length=#aztab --format suntables saztab=string.split(sazimuth,"\n") salttab=string.split(saltitude,"\n") stimetab=string.split(stime,"\n") table.remove(salttab) table.remove(salttab) table.remove(salttab,1) table.remove(salttab,1) table.remove(saztab) table.remove(saztab) table.remove(saztab,1) table.remove(saztab,1) table.remove(stimetab) table.remove(stimetab) table.remove(stimetab,1) table.remove(stimetab,1) slength=#saztab --get sunrise and sunset sunrise=conky_parse("${exec conkyForecast -d SR -s 1}") sunset=stimetab[slength] end--timed data gathering section --remove terminal errors when script starts if topper==nil then topper="starting up..." end if azimuth==nil then azimuth=0 end if altitude==nil then altitude=0 end if mtime==nil then mtime=0 end if sazimuth==nil then sazimuth=0 end if saltitude==nil then saltitude=0 end if stime==nil then stime=0 end if sunrise==nil then sunrise=" " end if sunset==nil then sunset=" " end if length==nil then length=0 end if slength==nil then slength=0 end --top info - mostly to test curl function font="Mono" fsize=12 cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, fsize) cairo_set_source_rgba (cr,1,1,1,1) toppertab=string.split(topper,"\n") cairo_move_to (cr,left_x,center_y-150) cairo_show_text (cr, toppertab[1]) cairo_stroke (cr) cairo_move_to (cr,left_x,center_y-138) cairo_show_text (cr, toppertab[4]) cairo_stroke (cr) cairo_move_to (cr,left_x,center_y-126) cairo_show_text (cr, toppertab[5]) cairo_stroke (cr) --horizon and north south------------------------------------------------------------- cairo_set_line_width (cr,1) cairo_set_source_rgba (cr,0.5,0.5,0.5,1) cairo_move_to (cr,left_x,center_y) cairo_rel_line_to (cr,left_x+360,0) cairo_stroke (cr) cairo_move_to (cr,left_x+180,center_y) cairo_rel_line_to (cr,0,-100) cairo_stroke (cr) --get time in appropriate intervals to set current positions-------------------------- int=I*60 count=tonumber((os.date("%M")*60)+os.date("%S")) now_timer=(count % int)+1 if now_timer==1 then setmin=os.date("%M") sethour=tostring(os.date("%H")) timenow=sethour .. ":" .. setmin end --compensate for timenow being nil when script starts if timenow==nil then min=tostring(os.date("%M")) if I==10 then --time minutes mins=string.gsub(min, ".", "%1|") mins=string.split(mins, "|") hour=tostring(os.date("%H")) timenow=(hour .. ":" .. mins[1] .. "0") elseif I==5 then mins=string.gsub(min, ".", "%1|") mins=string.split(mins, "|") hour=tostring(os.date("%H")) if mins[2]=="0" or mins[2]=="1" or mins[2]=="2" or mins[2]=="3" or mins[2]=="4" then timenow=(hour .. ":" .. mins[1] .. "0") elseif mins[2]=="5" or mins[2]=="6" or mins[2]=="7" or mins[2]=="8" or mins[2]=="9" then timenow=(hour .. ":" .. mins[1] .. "5") end elseif I==1 then hour=tostring(os.date("%H")) timenow=hour .. ":" .. min end end--if time now --print moon data---------------------------------------------------------------------- cairo_set_line_width (cr,1) for i=1,length do if aztab[i+1]==nil then aztab[i+1]=aztab[i] end if alttab[i+1]==nil then alttab[i+1]=alttab[i] end if tonumber(aztab[i+1])>tonumber(aztab[i]) then cairo_set_source_rgba (cr,1,1,1,1) elseif tonumber(aztab[i+1])<tonumber(aztab[i]) then cairo_set_source_rgba (cr,0,0,0,0) end cairo_move_to (cr,left_x+tonumber(aztab[i]),center_y-tonumber(alttab[i])) cairo_line_to (cr,left_x+tonumber(aztab[i+1]),center_y-tonumber(alttab[i+1])) cairo_stroke (cr) if tostring(timetab[i])==tostring(timenow) then moontime=i end if tostring(timetab[moontime])~=tostring(timenow) then moontime=nil end end moony=center_y+20+24 font="Mono" fsize=12 cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, fsize) cairo_set_source_rgba (cr,1,1,1,1) if moontime==nil then cairo_move_to (cr,left_x,moony) cairo_show_text (cr,"Moon : Has set") cairo_stroke (cr) else cairo_move_to (cr,left_x,moony) cairo_show_text (cr,"Moon : Azimuth=" .. aztab[moontime] .. ", Altitude=" .. alttab[moontime]) cairo_stroke (cr) cairo_arc (cr,left_x+tonumber(aztab[moontime]),center_y-tonumber(alttab[moontime]),6,0,2*math.pi) cairo_fill (cr) end --print sun data--------------------------------------------------------------------- cairo_set_line_width (cr,1) cairo_set_source_rgba (cr,1,1,0,1) for i=1,slength do if saztab[i+1]==nil then saztab[i+1]=saztab[i]end if salttab[i+1]==nil then salttab[i+1]=salttab[i] end cairo_move_to (cr,left_x+tonumber(saztab[i]),center_y-tonumber(salttab[i])) cairo_line_to (cr,left_x+tonumber(saztab[i+1]),center_y-tonumber(salttab[i+1])) cairo_stroke (cr) if tostring(stimetab[i])==tostring(timenow) then suntime=i end if tostring(stimetab[suntime])~=tostring(timenow) then suntime=nil end end --for 1 slength --print sun info suny=center_y+20+36 font="Mono" fsize=12 cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, fsize) cairo_set_source_rgba (cr,1,1,0,1) if suntime==nil then cairo_move_to (cr,left_x,suny) cairo_show_text (cr,"Sun : Has set. Sunrise tomorrow at " .. sunrise) cairo_stroke (cr) else cairo_move_to (cr,left_x,suny) cairo_show_text (cr,"Sun : Azimuth=" .. saztab[suntime] .. ", Altitude=" .. salttab[suntime] .. ", Set=" .. sunset) cairo_stroke (cr) cairo_arc (cr,left_x+tonumber(saztab[suntime]),center_y-tonumber(salttab[suntime]),6,0,2*math.pi) cairo_fill (cr) end --######################################################################################################### --######################################################################################################### end-- if updates>5 cairo_destroy(cr) cairo_surface_destroy(cs) cr=nil end-- end main function
i will give the new script a try thank you
changed the boxes to CODE...momentary lapse of brain function on that one
I need help.. lol
I am playing around with Conky and working on have a monitor on both sides. The problem I am running into is the backgrounds of both have curves at the top like shown on my preview. Ok this was easily fixed on the Right side with a simple ${goto 55} pushing everything over 55px. Now the issue I am running into on the Left side is I cant seem to stop the text from being echo'd to far over. I would like it to have a hard stop about 55px shorter much like the other side, but reverse.
Can anyone tell me how to set the max width without cutting out my conky background?
Thanks,
Exo
Mac Mini: OSX 10.9 Mavericks, i7-3720QM 2.6Ghz, 16GB RAM, 1.25TB Fusion Array, Intel HD4000 iGPU
Photo Blog on Youtube: www.youtube.com/user/ExodistPhotoBlog
Linux User: 380654
no problem
the new script is really optimised for US locations, as that is where I am
and is still being tweaked... had to make a modification recently
here
http://crunchbanglinux.org/forums/post/125058/#p125058
so keep me posted on how the script works for you
it took a couple of seconds but i understand whats going on in that screenshot
but how to prevent it, that's harder
particularly those hr commands, they go across the entire width of the conky window without fail
for everything else, you could try setting a monospaced font immediately following the end of each line then put in a number of spaces to push everything left like this
####Code:${cpu cpu0}${alignr}${cpubar cpu0 10,100}${font Mono:size=9}some blank spaces
EDIT - this doesn't work to right align everything, it left aligns everything a certain distance from the right edge
####
EDIT2 - well it kind of works, assuming that everything is monospaced and there are no font changes or font size changes
####
x's are there to show where the blanks end
Code:TEXT ${font Mono:size=9}${cpu cpu0}${alignr}${cpubar 10,50}${font Mono:size=9} x TEST${alignr}SOME TEXT${font Mono:size=9} x TEST TEST${alignr}SOME MORE TEXT${font Mono:size=9} x ${memperc}${alignr}${membar 10,50}${font Mono:size=9} x ${cpu cpu0}${alignr}${cpubar 10,50}${font Mono:size=9} x
but this doesnt work
the top line is not in lineCode:TEXT ${font Sans:size=12}${cpu cpu0}${alignr}${cpubar 10,50}${font Mono:size=9} x TEST${alignr}SOME TEXT${font Mono:size=9} x TEST TEST${alignr}SOME MORE TEXT${font Mono:size=9} x ${memperc}${alignr}${membar 10,50}${font Mono:size=9} x ${cpu cpu0}${alignr}${cpubar 10,50}${font Mono:size=9} x
EDIT3 actualy its even more complicated
you can have any font and size you like on the right as long as you change to a monospace before the ${alignr} command... so then everything on the left needs to be monospaced
then you could replace the hr lines with lua lines
drawing a line in lua is pretty easy
these lines need to go after the bg has been drawn, after the "cairo_fill (cr)" in the bg scriptCode:cairo_set_line_width (cr,1) -- sets line width to 1 pixel cairo_set_source_rgba (1,1,1,1)--sets color red,gree,blue,alpha (all numbers are 0 to 1) cairo_move_to (cr, X,Y)--sets the start point of the line cairo_rel_line_to (cr,X+length,0)--draws a horizontal line, y coordinate is 0 cairo_stroke (cr)
i think the bg script you have can use hexidecimal color codes also
if it was me i would do the whole thing in lua, text, bars, lines et al
indented right alignment should be pretty easy using cairo text extents
but then again ive had the experience to do that
and thats enough rambling for one night
Last edited by mrpeachy; May 29th, 2011 at 07:57 AM.
Bookmarks