CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by mrpeachy on Wed 16th Nov 19:27 (modification of post by view diff)
View followups from mrpeachy | download | new post

  1. --[[weather display by mrpeachy nov 2011
  2. version 5
  3. call data via conkyrc
  4. ability to display weather images
  5. ]]
  6. --#########################################################################################################
  7. --SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP
  8. secs=1800--set update interval
  9. web="http://www.intellicast.com/Local/Forecast.aspx?location=USMO9688"--insert unit=C& after? for C
  10. --get web address by going to the intellicast site and entering your location in the box
  11. --for version 3 you must get click on "Extended Forecast" to get the necessary address
  12. units="F"
  13. --set location where weather data txt will be saved
  14. location="/home/benjamin/Desktop/weather.txt"
  15. --set location of weather images
  16. weathericons="/home/benjamin/Desktop/images/weathericons/"
  17. --#########################################################################################################
  18.  
  19. require 'cairo'
  20. ------------------------------------------------------------------------------
  21. function string:split(delimiter)
  22. local result = { }
  23. local from  = 1
  24. local delim_from, delim_to = string.find( self, delimiter, from  )
  25. while delim_from do
  26. table.insert( result, string.sub( self, from , delim_from-1 ) )
  27. from  = delim_to + 1
  28. delim_from, delim_to = string.find( self, delimiter, from  )
  29. end
  30. table.insert( result, string.sub( self, from  ) )
  31. return result
  32. end
  33. --------------------------------------------------------------------------------
  34.  
  35. function conky_weatherdata()
  36. local updates=tonumber(conky_parse('${updates}'))
  37.  
  38. local timer=(updates %secs)+1
  39. if timer==1 or updates==3 then
  40. data={}
  41. fdata2={}
  42. local f=io.popen("curl '"..web.."' | grep -A62 'As of ' | gawk -F'>' -v RS='</' 'RT{print $NF}' | sed -e 's/^[ \t]*//' -e '/^$/d' -e 's/&deg;//g' -e 's/%//g' -e 's/  / /g' -e 's/Thunderstorms/T.Storms/g'")
  43. data1=f:read("*a")
  44. f:close()
  45. local data2=string.split(data1,"\n")
  46.  
  47. for i,v in pairs(data2) do
  48. if string.find(v,"[%a%d]")~=nil then
  49. table.insert(data,data2[i])
  50. end
  51. end
  52.  
  53. local f=io.popen("curl '"..web.."' | grep -A554 'View the Calendar Forecast' | gawk -F'>' -v RS='<' 'RT{print $NF}' | sed -e 's/^[ \t]*//' -e 's/&deg;//g' -e 's/  / /g' -e 's/%//g' -e 's/&deg//g' -e 's/Thunderstorms/T.Storms/g'")
  54. local fdata1=f:read("*a")
  55. f:close()
  56. local fdata=string.split(fdata1,"\n")
  57.  
  58. for i,v in pairs(fdata) do
  59. if string.find(v,"[%a%d]")~=nil then
  60. table.insert(fdata2,fdata[i])
  61. end
  62. end
  63.  
  64. --current
  65. local cdn=string.split(data[2],"/")
  66. if cdn[2]==nil then cdn[2]="" end
  67. local wdr=string.split(data[25]," ")
  68. now={con=string.gsub(cdn[1],"[\r\n]",""),cd2=string.gsub(cdn[2],"[\r\n]",""),tmp=string.gsub(data[4],units,""),flk=string.gsub(data[5],"Feels Like: ",""),wch=data[7],cel=data[10],hid=data[12],vis=string.gsub(data[15],"[ %a]",""),dpt=data[17],wsp=string.gsub(data[20],"[ %a]",""),wdg=(wdr[1]),wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),wgs=string.gsub(data[30]," mph",""),hum=data[22],prs=string.gsub(data[27],"\"","")}
  69. --############################################
  70. --forecast
  71. local cdn=string.split(fdata2[3],"/")
  72. if cdn[2]==nil then cdn[2]="" end
  73. local dyt=string.split(fdata2[2],",")
  74. local uvi=string.split(fdata2[20]," ")
  75. local wsp=string.split(fdata2[32]," ")
  76. local wdr=string.split(fdata2[34]," ")
  77. day1={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],cd2=cdn[2],hih=fdata2[4],low=fdata2[5],sri=fdata2[8],sst=fdata2[10],mri=fdata2[12],mst=fdata2[14],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[22],ppt=fdata2[24],snw=fdata2[26],cld=fdata2[28],mph=fdata2[30],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
  78. --day2
  79. local cdn=string.split(fdata2[36],"/")
  80. if cdn[2]==nil then cdn[2]="" end
  81. local dyt=string.split(fdata2[35],",")
  82. local uvi=string.split(fdata2[53]," ")
  83. local wsp=string.split(fdata2[65]," ")
  84. local wdr=string.split(fdata2[67]," ")
  85. day2={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[37],low=fdata2[38],sri=fdata2[41],sst=fdata2[43],mri=fdata2[45],mst=fdata2[47],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[55],ppt=fdata2[57],snw=fdata2[59],cld=fdata2[61],mph=fdata2[63],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  86. --day3
  87. local start=68
  88. local cdn=string.split(fdata2[start+1],"/")
  89. if cdn[2]==nil then cdn[2]="" end
  90. local dyt=string.split(fdata2[start],",")
  91. local uvi=string.split(fdata2[start+14]," ")
  92. local wsp=string.split(fdata2[start+26]," ")
  93. local wdr=string.split(fdata2[start+28]," ")
  94. day3={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  95. --day4
  96. local start=start+29
  97. local cdn=string.split(fdata2[start+1],"/")
  98. if cdn[2]==nil then cdn[2]="" end
  99. local dyt=string.split(fdata2[start],",")
  100. local uvi=string.split(fdata2[start+14]," ")
  101. local wsp=string.split(fdata2[start+26]," ")
  102. local wdr=string.split(fdata2[start+28]," ")
  103. day4={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  104. --day5
  105. local start=start+29
  106. local cdn=string.split(fdata2[start+1],"/")
  107. if cdn[2]==nil then cdn[2]="" end
  108. local dyt=string.split(fdata2[start],",")
  109. local uvi=string.split(fdata2[start+14]," ")
  110. local wsp=string.split(fdata2[start+26]," ")
  111. local wdr=string.split(fdata2[start+28]," ")
  112. day5={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  113. --day6
  114. local start=start+29
  115. local cdn=string.split(fdata2[start+1],"/")
  116. if cdn[2]==nil then cdn[2]="" end
  117. local dyt=string.split(fdata2[start],",")
  118. local uvi=string.split(fdata2[start+14]," ")
  119. local wsp=string.split(fdata2[start+26]," ")
  120. local wdr=string.split(fdata2[start+28]," ")
  121. day6={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  122. --day7
  123. local start=start+29
  124. local cdn=string.split(fdata2[start+1],"/")
  125. if cdn[2]==nil then cdn[2]="" end
  126. local dyt=string.split(fdata2[start],",")
  127. local uvi=string.split(fdata2[start+14]," ")
  128. local wsp=string.split(fdata2[start+26]," ")
  129. local wdr=string.split(fdata2[start+28]," ")
  130. day7={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  131. --day8
  132. local start=start+29
  133. local cdn=string.split(fdata2[start+1],"/")
  134. if cdn[2]==nil then cdn[2]="" end
  135. local dyt=string.split(fdata2[start],",")
  136. local uvi=string.split(fdata2[start+14]," ")
  137. local wsp=string.split(fdata2[start+26]," ")
  138. local wdr=string.split(fdata2[start+28]," ")
  139. day8={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  140. --day9
  141. local start=start+29
  142. local cdn=string.split(fdata2[start+1],"/")
  143. if cdn[2]==nil then cdn[2]="" end
  144. local dyt=string.split(fdata2[start],",")
  145. local uvi=string.split(fdata2[start+14]," ")
  146. local wsp=string.split(fdata2[start+26]," ")
  147. local wdr=string.split(fdata2[start+28]," ")
  148. day9={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  149. --day10
  150. local start=start+29
  151. local cdn=string.split(fdata2[start+1],"/")
  152. if cdn[2]==nil then cdn[2]="" end
  153. local dyt=string.split(fdata2[start],",")
  154. local uvi=string.split(fdata2[start+14]," ")
  155. local wsp=string.split(fdata2[start+26]," ")
  156. local wdr=string.split(fdata2[start+28]," ")
  157. day10={day=dyt[1],dat=string.gsub(dyt[2],"^.",""),con=cdn[1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),cd2=cdn[2]}
  158. --weather font
  159. --weather type table for weather font
  160. wfont={
  161. Tornado="1",
  162. Tornadon="1",
  163. TropicalStorm="2",
  164. TropicalStormn="2",
  165. Hurricane="3",
  166. Hurricanen="3",
  167. SevereTStorms="n",
  168. SevereTStormsn="n",
  169. TStorms="m",
  170. TStormsn="m",
  171. MixedRainandSnow="x",
  172. MixedRainandSnown="x",
  173. MixedRainandSleet="x",
  174. MixedRainandSleetn="x",
  175. MixedPrecipitation="y",
  176. MixedPrecipitationn="y",
  177. FreezingDrizzle="s",
  178. FreezingDrizzlen="s",
  179. Drizzle="h",
  180. Drizzlen="h",
  181. FreezingRain="t",
  182. FreezingRainn="t",
  183. LightRain="h",
  184. LightRainn="h",
  185. FewShowers="h",
  186. FewShowersn="h",
  187. Rain="i",
  188. Rainn="i",
  189. Showers="i",
  190. Showersn="i",
  191. SnowFlurries="p",
  192. SnowFlurriesn="p",
  193. LightSnowShowers="p",
  194. LightSnowShowersn="p",
  195. DriftingSnow="8",
  196. DriftingSnown="8",
  197. Snow="q",
  198. Snown="q",
  199. Hail="u",
  200. Hailn="u",
  201. Sleet="w",
  202. Sleetn="w",
  203. Dust="7",
  204. Dustn="7",
  205. Fog="0",
  206. Fogn="0",
  207. Haze="9",
  208. Hazen="9",
  209. Smoke="4",
  210. Smoken="4",
  211. Blustery="6",
  212. Blusteryn="6",
  213. Windy="6",
  214. Windyn="6",
  215. NA="-",
  216. NAn="-",
  217. Cloudy="f",
  218. Cloudyn="f",
  219. Overcast="f",
  220. Overcastn="f",
  221. MostlyCloudyn="D", -- night
  222. MostlyCloudy="d", -- day
  223. PartlyCloudyn="C", -- night
  224. PartlyCloudy="c",--day
  225. FewCloudsn="C", -- night
  226. FewClouds="c", -- day
  227. Clearn="A", -- night
  228. Clear="a", -- day
  229. Sunny="A",
  230. Sunnyn="a",
  231. MostlySunny="A",
  232. MostlySunnyn="a",
  233. Fairn="B", -- night
  234. Fair="b", -- day
  235. MixedRainandHail="v",
  236. MixedRainandHailn="v",
  237. Hot="5",
  238. Hotn="5",
  239. IsolatedTStorms="k", -- day
  240. IsolatedTStormsn="K", -- night
  241. ScatteredTStorms="k", -- day
  242. ScatteredTStormsn="K", --night
  243. ScatteredShowers="g", -- day
  244. ScatteredShowersn="G", -- night
  245. HeavyRain="j",
  246. HeavyRainn="j",
  247. ScatteredSnowShowers="o", -- day
  248. ScatteredSnowShowersn="O", -- night
  249. HeavySnow="r",
  250. HeavySnown="r",
  251. }
  252. --check for day or night images
  253. timeinhours=tonumber(os.date("%H"))
  254. if timeinhours>17 or timeinhours<5 then
  255. daynight="n"
  256. else
  257. daynight=""
  258. end
  259. --------------------------------------------
  260. font=
  261. {
  262. now=(loadstring("return ".."wfont."..(string.gsub(now.con,"[ %.%/]","")..daynight))()),
  263. day1=(loadstring("return ".."wfont."..string.gsub(day1.con,"[ %.%/]",""))()),
  264. day2=(loadstring("return ".."wfont."..string.gsub(day2.con,"[ %.%/]",""))()),
  265. day3=(loadstring("return ".."wfont."..string.gsub(day3.con,"[ %.%/]",""))()),
  266. day4=(loadstring("return ".."wfont."..string.gsub(day4.con,"[ %.%/]",""))()),
  267. day5=(loadstring("return ".."wfont."..string.gsub(day5.con,"[ %.%/]",""))()),
  268. day6=(loadstring("return ".."wfont."..string.gsub(day6.con,"[ %.%/]",""))()),
  269. day7=(loadstring("return ".."wfont."..string.gsub(day7.con,"[ %.%/]",""))()),
  270. day8=(loadstring("return ".."wfont."..string.gsub(day8.con,"[ %.%/]",""))()),
  271. day9=(loadstring("return ".."wfont."..string.gsub(day9.con,"[ %.%/]",""))()),
  272. day10=(loadstring("return ".."wfont."..string.gsub(day10.con,"[ %.%/]",""))())
  273. }
  274. ---------------------------------------------]]
  275. --writing to file
  276. local file = io.open(location, "w")
  277. local datastringnow=now.con.."|"..now.cd2.."|"..now.tmp.."|"..now.flk.."|"..now.wch.."|"..now.cel.."|"..now.hid.."|"..now.vis.."|"..now.dpt.."|"..now.wsp.."|"..now.wdg.."|"..now.wdi.."|"..now.wgs.."|"..now.hum.."|"..now.prs.."|"..now.cd2
  278. local datastringday1=day1.day.."|"..day1.dat.."|"..day1.con.."|"..day1.cd2.."|"..day1.hih.."|"..day1.low.."|"..day1.sri.."|"..day1.sst.."|"..day1.mri.."|"..day1.mst.."|"..day1.uvn.."|"..day1.uvt.."|"..day1.hum.."|"..day1.ppt.."|"..day1.snw.."|"..day1.cld.."|"..day1.mph.."|"..day1.wmh.."|"..day1.wkm.."|"..day1.wkt.."|"..day1.wdg.."|"..day1.wdi.."|"..day1.cd2
  279. local datastringday2=day2.day.."|"..day2.dat.."|"..day2.con.."|"..day2.cd2.."|"..day2.hih.."|"..day2.low.."|"..day2.sri.."|"..day2.sst.."|"..day2.mri.."|"..day2.mst.."|"..day2.uvn.."|"..day2.uvt.."|"..day2.hum.."|"..day2.ppt.."|"..day2.snw.."|"..day2.cld.."|"..day2.mph.."|"..day2.wmh.."|"..day2.wkm.."|"..day2.wkt.."|"..day2.wdg.."|"..day2.wdi.."|"..day2.cd2
  280. local datastringday3=day3.day.."|"..day3.dat.."|"..day3.con.."|"..day3.cd2.."|"..day3.hih.."|"..day3.low.."|"..day3.sri.."|"..day3.sst.."|"..day3.mri.."|"..day3.mst.."|"..day3.uvn.."|"..day3.uvt.."|"..day3.hum.."|"..day3.ppt.."|"..day3.snw.."|"..day3.cld.."|"..day3.mph.."|"..day3.wmh.."|"..day3.wkm.."|"..day3.wkt.."|"..day3.wdg.."|"..day3.wdi.."|"..day3.cd2
  281. local datastringday4=day4.day.."|"..day4.dat.."|"..day4.con.."|"..day4.cd2.."|"..day4.hih.."|"..day4.low.."|"..day4.sri.."|"..day4.sst.."|"..day4.mri.."|"..day4.mst.."|"..day4.uvn.."|"..day4.uvt.."|"..day4.hum.."|"..day4.ppt.."|"..day4.snw.."|"..day4.cld.."|"..day4.mph.."|"..day4.wmh.."|"..day4.wkm.."|"..day4.wkt.."|"..day4.wdg.."|"..day4.wdi.."|"..day4.cd2
  282. local datastringday5=day5.day.."|"..day5.dat.."|"..day5.con.."|"..day5.cd2.."|"..day5.hih.."|"..day5.low.."|"..day5.sri.."|"..day5.sst.."|"..day5.mri.."|"..day5.mst.."|"..day5.uvn.."|"..day5.uvt.."|"..day5.hum.."|"..day5.ppt.."|"..day5.snw.."|"..day5.cld.."|"..day5.mph.."|"..day5.wmh.."|"..day5.wkm.."|"..day5.wkt.."|"..day5.wdg.."|"..day5.wdi.."|"..day5.cd2
  283. local datastringday6=day6.day.."|"..day6.dat.."|"..day6.con.."|"..day6.cd2.."|"..day6.hih.."|"..day6.low.."|"..day6.sri.."|"..day6.sst.."|"..day6.mri.."|"..day6.mst.."|"..day6.uvn.."|"..day6.uvt.."|"..day6.hum.."|"..day6.ppt.."|"..day6.snw.."|"..day6.cld.."|"..day6.mph.."|"..day6.wmh.."|"..day6.wkm.."|"..day6.wkt.."|"..day6.wdg.."|"..day6.wdi.."|"..day6.cd2
  284. local datastringday7=day7.day.."|"..day7.dat.."|"..day7.con.."|"..day7.cd2.."|"..day7.hih.."|"..day7.low.."|"..day7.sri.."|"..day7.sst.."|"..day7.mri.."|"..day7.mst.."|"..day7.uvn.."|"..day7.uvt.."|"..day7.hum.."|"..day7.ppt.."|"..day7.snw.."|"..day7.cld.."|"..day7.mph.."|"..day7.wmh.."|"..day7.wkm.."|"..day7.wkt.."|"..day7.wdg.."|"..day7.wdi.."|"..day7.cd2
  285. local datastringday8=day8.day.."|"..day8.dat.."|"..day8.con.."|"..day8.cd2.."|"..day8.hih.."|"..day8.low.."|"..day8.sri.."|"..day8.sst.."|"..day8.mri.."|"..day8.mst.."|"..day8.uvn.."|"..day8.uvt.."|"..day8.hum.."|"..day8.ppt.."|"..day8.snw.."|"..day8.cld.."|"..day8.mph.."|"..day8.wmh.."|"..day8.wkm.."|"..day8.wkt.."|"..day8.wdg.."|"..day8.wdi.."|"..day8.cd2
  286. local datastringday9=day9.day.."|"..day9.dat.."|"..day9.con.."|"..day9.cd2.."|"..day9.hih.."|"..day9.low.."|"..day9.sri.."|"..day9.sst.."|"..day9.mri.."|"..day9.mst.."|"..day9.uvn.."|"..day9.uvt.."|"..day9.hum.."|"..day9.ppt.."|"..day9.snw.."|"..day9.cld.."|"..day9.mph.."|"..day9.wmh.."|"..day9.wkm.."|"..day9.wkt.."|"..day9.wdg.."|"..day9.wdi.."|"..day9.cd2
  287. local datastringday10=day10.day.."|"..day10.dat.."|"..day10.con.."|"..day10.cd2.."|"..day10.hih.."|"..day10.low.."|"..day10.sri.."|"..day10.sst.."|"..day10.mri.."|"..day10.mst.."|"..day10.uvn.."|"..day10.uvt.."|"..day10.hum.."|"..day10.ppt.."|"..day10.snw.."|"..day10.cld.."|"..day10.mph.."|"..day10.wmh.."|"..day10.wkm.."|"..day10.wkt.."|"..day10.wdg.."|"..day10.wdi.."|"..day10.cd2
  288. local datastringfont=font.now.."|"..font.day1.."|"..font.day2.."|"..font.day3.."|"..font.day4.."|"..font.day5.."|"..font.day6.."|"..font.day7.."|"..font.day8.."|"..font.day9.."|"..font.day10
  289. file:write(datastringnow.."<>"..datastringday1.."<>"..datastringday2.."<>"..datastringday3.."<>"..datastringday4.."<>:"..datastringday5.."<>"..datastringday6.."<>"..datastringday7.."<>"..datastringday8.."<>"..datastringday9.."<>"..datastringday10.."<>"..datastringfont)
  290. file:close()
  291. end--timed section
  292.  
  293. if data1==nil then
  294. local f=io.popen("cat '"..location.."'")
  295. local alldata=f:read("*a")
  296. f:close()
  297. daydata=string.split(alldata,"<>")
  298. now=string.split(daydata[1],"|")
  299. day1=string.split(daydata[2],"|")
  300. day2=string.split(daydata[3],"|")
  301. day3=string.split(daydata[4],"|")
  302. day4=string.split(daydata[5],"|")
  303. day5=string.split(daydata[6],"|")
  304. day6=string.split(daydata[7],"|")
  305. day7=string.split(daydata[8],"|")
  306. day8=string.split(daydata[9],"|")
  307. day9=string.split(daydata[10],"|")
  308. day10=string.split(daydata[11],"|")
  309. font=string.split(daydata[12],"|")
  310. --test=day2[1]
  311. --set variables
  312. now={con=now[1],tmp=now[2],flk=now[3],wch=now[4],cel=now[5],hid=now[6],vis=now[7],dpt=now[8],wsp=now[9],wdg=now[10],wdi=now[11],wgs=now[12],hum=now[13],prs=now[14],cd2=now[15]}
  313. day1={day=day1[1],dat=day1[2],con=day1[3],hih=day1[4],low=day1[5],sri=day1[6],sst=day1[7],mri=day1[8],mst=day1[9],uvn=day1[10],uvt=day1[11],hum=day1[12],ppt=day1[13],snw=day1[14],cld=day1[15],mph=day1[16],wmh=day1[17],wkm=day1[18],wkt=day1[19],wdg=day1[20],wdi=day1[21],cd2=day1[22]}
  314. day2={day=day2[1],dat=day2[2],con=day2[3],hih=day2[4],low=day2[5],sri=day2[6],sst=day2[7],mri=day2[8],mst=day2[9],uvn=day2[10],uvt=day2[11],hum=day2[12],ppt=day2[13],snw=day2[14],cld=day2[15],mph=day2[16],wmh=day2[17],wkm=day2[18],wkt=day2[19],wdg=day2[20],wdi=day2[21],cd2=day1[22]}
  315. day3={day=day3[1],dat=day3[2],con=day3[3],hih=day3[4],low=day3[5],sri=day3[6],sst=day3[7],mri=day3[8],mst=day3[9],uvn=day3[10],uvt=day3[11],hum=day3[12],ppt=day3[13],snw=day3[14],cld=day3[15],mph=day3[16],wmh=day3[17],wkm=day3[18],wkt=day3[19],wdg=day3[20],wdi=day3[21],cd2=day1[22]}
  316. day4={day=day4[1],dat=day4[2],con=day4[3],hih=day4[4],low=day4[5],sri=day4[6],sst=day4[7],mri=day4[8],mst=day4[9],uvn=day4[10],uvt=day4[11],hum=day4[12],ppt=day4[13],snw=day4[14],cld=day4[15],mph=day4[16],wmh=day4[17],wkm=day4[18],wkt=day4[19],wdg=day4[20],wdi=day4[21],cd2=day1[22]}
  317. day5={day=day5[1],dat=day5[2],con=day5[3],hih=day5[4],low=day5[5],sri=day5[6],sst=day5[7],mri=day5[8],mst=day5[9],uvn=day5[10],uvt=day5[11],hum=day5[12],ppt=day5[13],snw=day5[14],cld=day5[15],mph=day5[16],wmh=day5[17],wkm=day5[18],wkt=day5[19],wdg=day5[20],wdi=day5[21],cd2=day1[22]}
  318. day6={day=day6[1],dat=day6[2],con=day6[3],hih=day6[4],low=day6[5],sri=day6[6],sst=day6[7],mri=day6[8],mst=day6[9],uvn=day6[10],uvt=day6[11],hum=day6[12],ppt=day6[13],snw=day6[14],cld=day6[15],mph=day6[16],wmh=day6[17],wkm=day6[18],wkt=day6[19],wdg=day6[20],wdi=day6[21],cd2=day1[22]}
  319. day7={day=day7[1],dat=day7[2],con=day7[3],hih=day7[4],low=day7[5],sri=day7[6],sst=day7[7],mri=day7[8],mst=day7[9],uvn=day7[10],uvt=day7[11],hum=day7[12],ppt=day7[13],snw=day7[14],cld=day7[15],mph=day7[16],wmh=day7[17],wkm=day7[18],wkt=day7[19],wdg=day7[20],wdi=day7[21],cd2=day1[22]}
  320. day8={day=day8[1],dat=day8[2],con=day8[3],hih=day8[4],low=day8[5],sri=day8[6],sst=day8[7],mri=day8[8],mst=day8[9],uvn=day8[10],uvt=day8[11],hum=day8[12],ppt=day8[13],snw=day8[14],cld=day8[15],mph=day8[16],wmh=day8[17],wkm=day8[18],wkt=day8[19],wdg=day8[20],wdi=day8[21],cd2=day1[22]}
  321. day9={day=day9[1],dat=day9[2],con=day9[3],hih=day9[4],low=day9[5],sri=day9[6],sst=day9[7],mri=day9[8],mst=day9[9],uvn=day9[10],uvt=day9[11],hum=day9[12],ppt=day9[13],snw=day9[14],cld=day9[15],mph=day9[16],wmh=day9[17],wkm=day9[18],wkt=day9[19],wdg=day9[20],wdi=day9[21],cd2=day1[22]}
  322. day10={day=day10[1],dat=day10[2],con=day10[3],hih=day10[4],low=day10[5],sri=day10[6],sst=day10[7],mri=day10[8],mst=day10[9],uvn=day10[10],uvt=day10[11],hum=day10[12],ppt=day10[13],snw=day10[14],cld=day10[15],mph=day10[16],wmh=day10[17],wkm=day10[18],wkt=day10[19],wdg=day10[20],wdi=day10[21],cd2=day1[22]}
  323. font={now=font[1],day1=font[2],day2=font[3],day3=font[4],day4=font[5],day5=font[6],day6=font[7],day7=font[8],day8=font[9],day9=font[10],day10=font[11]}
  324. end--if data1==nil
  325. return ""
  326. end--function
  327.  
  328. function conky_weather(conkydata,xpos,ypos,scale1,scale2)
  329. if xpos==nil then xpos=0 end
  330. if ypos==nil then ypos=0 end
  331. if scale1==nil then scale1=0 end
  332. if scale2==nil then scale2=0 end
  333.  
  334. --[[data available
  335. --current info.. use now.option
  336. --options
  337. con=conditions summary
  338. cd2=conditions secondary
  339. tmp=temperature
  340. flk=Feels Like
  341. wch=wind chill
  342. cel=ceiling
  343. hid=heat index
  344. vis=visibility
  345. dpt=dew point
  346. wsp=wind speed (in mph)
  347. wdg=wind direction in degrees
  348. wdi=wind direction NSEW
  349. wgs=wind gusts
  350. hum=humidity
  351. prs=pressure
  352. --forecast information, 10 day
  353. --use like this  dayX.option (where X=day number (1=today,2=tomorrow))
  354. --options
  355. day=forecast day
  356. dat=forecast date
  357. con=conditions summary
  358. cd2=conditions secondary
  359. hih=high temp
  360. low=low temp
  361. sri=sunrise
  362. sst=sunset
  363. mri=moon rise
  364. mst=moon set
  365. uvi=ultraviolet index
  366. hum=humidity
  367. ppt=chance of precipitation
  368. snw=chance of snow
  369. cld=cloud cover
  370. mph=moon phase
  371. wmh=wind speed in mph
  372. wkm=wind speed in km/h
  373. wkt=wind speed in knots
  374. wdg=wind direction in degrees
  375. wdi=wind direction in nesw
  376. "0": u"1", #Tornado
  377.         "1": u"2", #Tropical Storm
  378.         "2": u"3", #Hurricane
  379.         "3": u"n", #Severe Thunderstorms
  380.         "4": u"m", #Thunderstorms
  381.         "5": u"x", #Mixed Rain and Snow
  382.         "6": u"x", #Mixed Rain and Sleet
  383.         "7": u"y", #Mixed Precipitation
  384.         "8": u"s", #Freezing Drizzle
  385.         "9": u"h", #Drizzle
  386.         "10": u"t", #Freezing Rain
  387.         "11": u"h", #Light Rain
  388.         "12": u"i", #Rain
  389.         "13": u"p", #Snow Flurries
  390.         "14": u"p", #Light Snow Showers
  391.         "15": u"8", #Drifting Snow
  392.         "16": u"q", #Snow
  393.         "17": u"u", #Hail
  394.         "18": u"w", #Sleet
  395.         "19": u"7", #Dust
  396.         "20": u"0", #Fog
  397.         "21": u"9", #Haze
  398.         "22": u"4", #Smoke
  399.         "23": u"6", #Blustery
  400.         "24": u"6", #Windy
  401.         "25": u"-", #N/A
  402.         "26": u"f", #Cloudy
  403.         "27": u"D", #Mostly Cloudy - night
  404.         "28": u"d", #Mostly Cloudy - day
  405.         "29": u"C", #Partly Cloudy - night
  406.         "30": u"c", #Partly Cloudy - day
  407.         "31": u"A", #Clear - night
  408.         "32": u"a", #Clear - day
  409.         "33": u"B", #Fair - night
  410.         "34": u"b", #Fair - day
  411.         "35": u"v", #Mixed Rain and Hail
  412.         "36": u"5", #Hot
  413.         "37": u"k", #Isolated Thunderstorms - day
  414.         "38": u"k", #Scattered Thunderstorms - day
  415.         "39": u"g", #Scattered Showers - day
  416.         "40": u"j", #Heavy Rain
  417.         "41": u"o", #Scattered Snow Showers - day
  418.         "42": u"r", #Heavy Snow
  419.         "43": u"r", #Heavy Snow
  420.         "44": u"-", #N/A
  421.         "45": u"G", #Scattered Showers - night
  422.         "46": u"O", #Scattered Snow Showers - night
  423.         "47": u"K", #Isolated Thunderstorms - night
  424.         "na": u"-", #N/A
  425.         "-": u"-" #N/A
  426. intellicast={
  427. wx_65=32--clear/sunny
  428. wx_66=30--partly cloudy
  429. wx_67=26--cloudy
  430. wx_68=32--clear/sunny
  431. wx_69=28--mostly cloudy
  432. wx_70=20--fog
  433. wx_71=
  434. wx_72=
  435. wx_73=
  436. wx_74=
  437. wx_75=
  438. wx_76=
  439. wx_77=
  440. wx_78=
  441. wx_79=
  442. wx_80=
  443. wx_81=
  444. wx_82=
  445. wx_83=
  446. wx_84=
  447. wx_85=
  448. wx_86=
  449. wx_87=
  450. wx_88=
  451. wx_89=
  452. wx_90=
  453. wx_91=
  454. wx_92=
  455. wx_93=
  456. wx_94=
  457. wx_95=
  458. wx_96=
  459. wx_97=
  460. wx_98=
  461. wx_99=
  462. wx_100=
  463. wx_101=
  464. wx_102=
  465. wx_103=
  466. wx_104=
  467. wx_105=
  468. wx_106=
  469. wx_107=
  470. wx_108=
  471. wx_109=
  472. wx_110=
  473. wx_111=
  474. wx_112=
  475. wx_113=
  476. wx_114=
  477. wx_115=
  478. }--end table
  479. --]]
  480. --weather type table for images
  481. wimage={
  482. Tornado="00",
  483. Tornadon="00",
  484. TropicalStorm="01",
  485. TropicalStormn="01",
  486. Hurricane="02",
  487. Hurricanen="02",
  488. SevereTStorms="03",
  489. SevereTStormsn="03",
  490. TStorms="04",
  491. TStormsn="04",
  492. MixedRainandSnow="05",
  493. MixedRainandSnown="05",
  494. MixedRainandSleet="06",
  495. MixedRainandSleetn="06",
  496. MixedPrecipitation="07",
  497. MixedPrecipitationn="07",
  498. FreezingDrizzle="08",
  499. FreezingDrizzlen="08",
  500. Drizzle="09",
  501. Drizzlen="09",
  502. FreezingRain=10,
  503. FreezingRainn=10,
  504. LightRain=11,
  505. LightRainn=11,
  506. FewShowers=11,
  507. FewShowersn=11,
  508. Rain=12,
  509. Rainn=12,
  510. Showers=12,
  511. Showersn=12,
  512. SnowFlurries=13,
  513. SnowFlurriesn=13,
  514. LightSnowShowers=14,
  515. LightSnowShowersn=14,
  516. DriftingSnow=15,
  517. DriftingSnown=15,
  518. Snow=16,
  519. Snown=16,
  520. Hail=17,
  521. Hailn=17,
  522. Sleet=18,
  523. Sleetn=18,
  524. Dust=19,
  525. Dustn=19,
  526. Fog=20,
  527. Fogn=20,
  528. Haze=21,
  529. Hazen=21,
  530. Smoke=22,
  531. Smoken=22,
  532. Blustery=23,
  533. Blusteryn=23,
  534. Windy=24,
  535. Windyn=24,
  536. NA=25,
  537. NAn=25,
  538. Cloudy=26,
  539. Cloudyn=26,
  540. Overcast=26,
  541. Overcastn=26,
  542. MostlyCloudyn=27, -- night
  543. MostlyCloudy=28, -- day
  544. PartlyCloudyn=29, -- night
  545. PartlyCloudy=30,--day
  546. FewCloudsn=29, -- night
  547. FewClouds=30, -- day
  548. Clearn=31, -- night
  549. Clear=32, -- day
  550. Sunny=32,
  551. Sunnyn=32,
  552. MostlySunny=32,
  553. MostlySunnyn=32,
  554. Fairn=33, -- night
  555. Fair=34, -- day
  556. MixedRainandHail=35,
  557. MixedRainandHailn=35,
  558. Hot=36,
  559. Hotn=36,
  560. IsolatedTStorms=37, -- day
  561. IsolatedTStormsn=47, -- night
  562. ScatteredTStorms=38, -- day
  563. ScatteredTStormsn=38,
  564. ScatteredShowers=39, -- day
  565. ScatteredShowersn=45, -- night
  566. HeavyRain=40,
  567. HeavyRainn=40,
  568. ScatteredSnowShowers=41, -- day
  569. ScatteredSnowShowersn=46, -- night
  570. HeavySnow=42,
  571. HeavySnown=43,
  572. }
  573. --check for day or night images
  574. local timeinhours=tonumber(os.date("%H"))
  575. if timeinhours>17 or timeinhours<5 then
  576. daynight="n"
  577. else
  578. daynight=""
  579. end
  580. --------------------------------------------
  581. image=
  582. {
  583. now="${image "..weathericons..(loadstring("return ".."wimage."..(string.gsub(now.con,"[ %.%/]","")..daynight))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  584. day1="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day1.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  585. day2="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day2.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  586. day3="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day3.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  587. day4="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day4.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  588. day5="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day5.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  589. day6="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day6.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  590. day7="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day7.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  591. day8="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day8.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  592. day9="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day9.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}",
  593. day10="${image "..weathericons..(loadstring("return ".."wimage."..string.gsub(day10.con,"[ %.%/]",""))())..".png -p "..xpos..","..ypos.." -s "..scale1.."x"..scale2.."}"
  594. }
  595. ---------------------------------------------
  596.  
  597. if (loadstring("return " .. conkydata)())~=nil then
  598. output=(loadstring("return " .. conkydata)())
  599. else
  600. output="startup"
  601. end
  602.  
  603. return output
  604. --now=nil;day1=nil;day2=nil;day3=nil;day4=nil;day5=nil;day6=nil;day7=nil;day8=nil;day9=nil;day10=nil;font=nil;data=nil;data1=nil;fdata2=nil
  605. end--main function

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me