SEARCH

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

You are not logged in.

#851 2012-11-25 13:59:51

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

mrpeachy wrote:

@sector11 or other willing volunteers

here is a replacement text out function

function out(txj)--c,a,f,fs,face,x,y,txt,hj,vj,ro ##################################################
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
--#########################################################################################################
local function color(col,alp)
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
--#########################################################################################################
local c=txj.c 			or default_color		or 0xffffff
local a=txj.a 			or default_alpha		or 1
local f=txj.f 			or default_font			or "mono"
local fs=txj.fs 		or default_font_size		or 12
local x=txj.x 			or 100
local y=txj.y 			or 100
local txt=txj.txt 		or "set txt"
local hj=txj.hj 		or default_hj			or "l"
local vj=txj.vj 		or default_vj			or "n"
local ro=txj.ro			or defaukt_ro			or 0
local face=txj.face		or default_face			or "normal"
--set face
if face=="normal" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
elseif face=="bold" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
elseif face=="italic" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
elseif face=="bolditalic" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
else
print ('face not set correctly - "normal","bold","italic","bolditalic"')
end
cairo_set_font_size (cr, fs)
cairo_text_extents(cr,txt,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
local tx=x
local ty=y
--set horizontal alignment - l, c, r
if hj=="l" then
x=x-bx
rad=0
elseif hj=="c" then
x=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
x=x-wx
rad=wx-bx
else
print ("hj not set correctly - l, c, r")
end
--vj. n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
y=y
rad2=0
ry=by
elseif vj=="nb" then
y=y-by
rad2=-by
ry=by
elseif vj=="m" then
y=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
y=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
y=y+hy-by
rad2=hy-by
ry=0+by
else
print ("vj not set correctly - n, nb, m, mb, t")
end
--rotation
if ro~=0 then
local point2=(math.pi/180)*(ro-180)
local x2=tx+rad2*(math.sin(point2))
local y2=ty-rad2*(math.cos(point2))
local point=(math.pi/180)*(ro-90)
local x1=x2+rad*(math.sin(point))
local y1=y2-rad*(math.cos(point))
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*ro)
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,x,y)
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--if ro
end--function out ###################################################################

if you could paste it over the existing out function in v9000.lua (should start somewhere around line 1060)
want to make sure it doesn't affect any existing configs

All is well with my setup! Had to restart the conky twice however to get the click function to work (though I know not if this is a result of the new code or some other issue).
Thanks for the hard work mrpeachy!

Last edited by DrakarNoir (2012-11-25 14:04:27)


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

Be excellent to each other!

#852 2012-11-25 16:00:51

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

is it possible that the new function (text-features) doesn't work because of the additional functions that i load at the same time?

this are all of my additional functions:

-- ###################################################################
-- ## Dateisystem ####################################################
-- ###################################################################

function total_aendern(wert)

local laenge=tonumber(string.len(wert))
local str_endung=string.sub(wert,laenge-2,laenge)

if str_endung=='GiB' then
meinstring=string.sub(wert,0,laenge-3)..' gb'
elseif str_endung=='MiB' then
meinstring=string.sub(wert,0,laenge-3)..' mb'
elseif str_endung=='KiB' then
meinstring=string.sub(wert,0,laenge-3)..' kb'

end

convert_string=string.gsub(tostring(meinstring),"%.",",")

return convert_string
end


function aendern(wert,zeichen)

local str_laenge=string.len(wert)
local str_wert=string.sub(wert,0,str_laenge-3)
local str_null=add0(str_wert)
local convert_str=string.gsub(tostring(str_null),"%.",",")..' '..zeichen

return convert_str

end -- of function


-- ###################################################################
-- ## Entferne führende Nullen #######################################
-- ###################################################################

function dropZero(wert)

local erstezahl=tonumber(string.sub(wert,1,1))

if erstezahl == 0 then
ausgabe=string.sub(wert,2,8)
else
ausgabe=string.sub(wert,1,8)
end -- of if

return ausgabe

end -- of function






--##################################################################
--###### Tag-/ Nachtmodus (day-/night mode) ########################
--################################################################## 

function dnc(wert1,wert2)

-- time of the sunrise
local Stunden1=string.sub(sun_rise_24[1],1,2)
local UmrechnungStundenMinuten1=tonumber(Stunden1)*60
local Minuten1=string.sub(sun_rise_24[1],4,5)
local Gesamt1=tonumber(Minuten1)+UmrechnungStundenMinuten1

-- time of the sunset
local Stunden2=string.sub(sun_set_24[1],1,2)
local UmrechnungStundenMinuten2=tonumber(Stunden2)*60
local Minuten2=string.sub(sun_set_24[1],4,5)
local Gesamt2=tonumber(Minuten2)+UmrechnungStundenMinuten2

-- actual time
local AktuelleStunde=tonumber(os.date("%H"))*60
local AktuelleMinuten=tonumber(os.date("%M"))
local AktuelleZeit=AktuelleStunde+AktuelleMinuten

if AktuelleZeit>Gesamt1 and AktuelleZeit<Gesamt2 then
-- Funktion für den Tag
farbe=maya(wert1)
else
-- Funktion für die Nacht
farbe=wert2
end -- end of the if-section

return farbe

end -- end of function


-- ##########################################################
-- ### Maya-Uhr #############################################
-- ##########################################################

function maya(wert)

-- actual date (intellicast)
local intTag=now["date"]
local intTagNummer=tonumber(intTag)*365
local intMonat=month_number(now["month"])
local intMonatNummer=tonumber(intMonat)*12
local intJahr=now["year"]
local intJahrNummer=tonumber(intJahr)
local intDatumNummer=intTagNummer+intMonatNummer+intJahrNummer

-- Am Tag des 'Weltunterganges' wird der gesamte Text in roter Farbe
-- dargestellt. An diesem Tag endet der Maya-Kalender und laut
-- Überlieferung soll an diesem Tag die Welt untergehen.

local Tag=21
local Monat=12
local Jahr=2012
local Datum=(Tag*365)+(Monat*12)+Jahr

if intDatumNummer == Datum then
farbe=0xff0000
elseif intDatumNummer ~= Datum then
farbe=wert
end -- if schleife

return farbe

end -- the function


-- #################################################################



-- #################################################################
-- ## Funktion zum Umwandeln der Windwerte (beaufort scala) ########
-- #################################################################

function wind_speed_text(uebergabe)

local a,b,x=string.find(uebergabe,"(%d*).*")
local x=tonumber(x)

local laenge=string.len(uebergabe)-5
local teil=string.sub(uebergabe,0,laenge)
local wert=add0(teil).." km/h"

if x < 1.85  then
wind_text = "windstill"
elseif x >= 1.85 and x < 9.0 then
wind_text = "geringer Wind mit "..wert
elseif x >= 9.0 and x < 19.0 then
wind_text = "leichter Wind mit "..wert
elseif x >= 19.0 and x < 28.0 then
wind_text = "schwacher Wind mit "..wert
elseif x >= 28.0 and x < 37.0 then
wind_text = "mäßiger Wind mit "..wert
elseif x >= 37.0 and x < 46.0 then
wind_text = "frischer Wind mit "..wert
elseif x >= 46.0 and x < 56.0 then
wind_text = "starker Wind mit "..wert
end--of if x = section

mitkomma=string.gsub(tostring(wind_text),"%.",",")

return mitkomma

end--of function wind_speed_text


-- ##################################################################
-- ## Nachkommastelle bei Windstärke hinzufügen #####################
-- ##################################################################

function add0(input)

if string.find(input,"%a")==nil then
        if string.find(input,"%p")==nil then        
        input=input..',0'
        end
end
return input
end

--#####################################################################
--### Name des Monats wird in die entsprechende Zahl umgewandelt ######
--#####################################################################

function month_number(input)

month_to_num={
"Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember", 
}

for i,v in ipairs(month_to_num) do

    if tostring(input)==tostring(v) then

      -- null hinzufügen
	  if tonumber(i)<=9 then
	  output="0"..tonumber(i)
	  elseif tonumber(i)>=10 then
	  output=tonumber(i)
	  end
	  -- ende 'null hinzufügen'

    end
end--for loop

return output -- return number of month

end--function


-- ####################################################################
-- ## Webcam auslesen #################################################
-- ####################################################################

function meinewebcam()

updates=tonumber(conky_parse("${updates}"))
interval=10
timer=(updates % interval)

if timer==0 then
os.execute("curl -s -m 5 http://www.centennialbulb.org/ctbulb.jpg -o /tmp/bulb.jpg &>/dev/null")
end

end


function laenge(wert)

--set up and show text
font="PF Tempesta Seven"
fsize=8
text=wert
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.x_advance --supposed to measure spaces also

return width

end


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


-- #########################################################
-- ## isometric bars by mrpeachy ###########################
-- ## modified by lionhead #################################
-- #########################################################

require 'cairo'

function bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down,value_pos)

--line 1 settings end  
local a_num1=tonumber(conkyobject)
--local a_num=(height/100)*a_num1
local a_num=(height/100)*a_num1

if framelines == 1 then
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_set_line_width (cr, linethick)
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, width*0.5, -width*0.5)
cairo_rel_line_to (cr, 0, -height)
cairo_stroke (cr)
cairo_translate (cr, -bar_across, -bar_down)
end

--line 1 indicator front face
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, 0, 0);
cairo_rectangle (cr, 0, 0, width, -a_num);
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill (cr)
cairo_translate (cr, -bar_across, -bar_down)
--line 1 indicator side face
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, 0, (linethick*0.1));
cairo_rel_line_to (cr, 0, -a_num)
cairo_rel_line_to (cr, -1*(width*0.5), -1*(width*0.5))
cairo_rel_line_to (cr, 0, a_num)
cairo_rel_line_to (cr, (width*0.5), (width*0.5))
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill (cr)
cairo_translate (cr, -bar_across, -bar_down)

--line 1 indicator top face
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, 0, -a_num);
cairo_rel_line_to (cr, width, 0)
cairo_rel_line_to (cr, -1*(width*0.5), -1*(width*0.5))
cairo_rel_line_to (cr, -width, 0)
cairo_rel_line_to (cr, (width*0.5), (width*0.5))
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill (cr)
cairo_translate (cr, -bar_across, -bar_down)

--line 1 indicator lines
cairo_set_line_width (cr, linethick);
cairo_translate (cr, bar_across, bar_down)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
--vertical, middle
cairo_move_to (cr, 0, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -a_num-(linethick*0.5))
cairo_stroke (cr)
--vertical right
cairo_move_to (cr, width, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -a_num-(linethick*0.5))
cairo_stroke (cr)
--left line
cairo_move_to (cr, -1*(width*0.5), (-1*(width*0.5))+(linethick));
cairo_rel_line_to (cr, 0, -a_num)
cairo_stroke (cr)
--bottom line
cairo_move_to (cr, -1*(linethick*0.5), (linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top of indicator
cairo_move_to (cr, 0, -a_num+(linethick*0.5))
cairo_rel_line_to (cr, width, 0)
cairo_stroke (cr)
--bottom diagonal
cairo_move_to (cr, -1*(linethick*0.15), (linethick*0.65))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--topline
cairo_move_to (cr, (-1*(width*0.5))-(linethick*0.5), ((-1*(width*0.5))-a_num)+(linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top left diagonal
cairo_move_to (cr, 0, -a_num+(linethick*0.5))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--top right diagonal
cairo_move_to (cr, width+(linethick*0.15), -a_num+(linethick*0.35))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
cairo_translate (cr, -bar_across, -bar_down)

-- txt title
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fontsize);
cairo_set_source_rgba (cr,txtred,txtgreen,txtblue,txtalpha);
cairo_translate (cr, txt_across,txt_down)
cairo_move_to (cr, 0,0)
cairo_show_text (cr,title)
-- end txt title

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

--[[ 

-- absolute position below title (no framelines)
cairo_set_source_rgba (cr,valuered,valuegreen,valueblue,valuealpha);
cairo_move_to (cr, value_across,value_down)
cairo_show_text (cr,conkyobject..'%')

]]--

-- relative position above bar (no framelines)
ypos=(-a_num+(linethick*0.5))-40

cairo_set_source_rgba (cr,valuered,valuegreen,valueblue,valuealpha);
cairo_move_to (cr, value_across,ypos)
cairo_show_text (cr,conkyobject..'%')


--------------------------------------
cairo_translate (cr, -txt_across, -txt_down)

if framelines == 1 then
--frame lines
cairo_set_line_width (cr, linethick);
cairo_translate (cr, bar_across, bar_down)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
--vertical, middle
cairo_move_to (cr, 0, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -height-(linethick*0.5))
cairo_stroke (cr)
--vertical right
cairo_move_to (cr, width, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -height-(linethick*0.5))
cairo_stroke (cr)
--left line
cairo_move_to (cr, -1*(width*0.5), (-1*(width*0.5))+(linethick));
cairo_rel_line_to (cr, 0, -height)
cairo_stroke (cr)
--bottom line
cairo_move_to (cr, -1*(linethick*0.5), (linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top of indicator
cairo_move_to (cr, 0, -height+(linethick*0.5))
cairo_rel_line_to (cr, width, 0)
cairo_stroke (cr)
--bottom diagonal
cairo_move_to (cr, -1*(linethick*0.15), (linethick*0.65))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--topline
cairo_move_to (cr, (-1*(width*0.5))-(linethick*0.5), ((-1*(width*0.5))-height)+(linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top left diagonal
cairo_move_to (cr, 0, -height+(linethick*0.5))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--top right diagonal
cairo_move_to (cr, width+(linethick*0.15), -height+(linethick*0.35))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
cairo_translate (cr, -bar_across, -bar_down)
end
end

function conky_draw_shape ()

local schriftart="PF Tempesta Seven" -- font
local updates=conky_parse('${updates}')

local bar_vertical=530
local txt_vertical=550

update_num=tonumber(updates)

if update_num > 5 then
if conky_window==nil then return end
local w=tonumber(conky_window.width)
local h=tonumber(conky_window.height)
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
cr=cairo_create(cs)

-- ##############################################
-- ### Prozessor (CPU #1) #######################
-- ##############################################

conkyobject=conky_parse('${cpu}')

title="cpu1"
font=schriftart
fontsize=8

framelines=0 -- no frameline=0, frameline=1
linethick=0.5 -- thick of the line

width=20 -- width of the bar
height=80 -- height of the bar

-- color frameline
linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

-- color bar
facered=dnc(165,217)/255
facegreen=dnc(61,199)/255
faceblue=dnc(6,184)/255
facealpha=0.6

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

-- color txt value
valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=35 -- position bar horizontal
bar_down=bar_vertical -- position bar vertical

txt_across=30-- position title horizontal
txt_down=txt_vertical -- position title vertical

value_across=0 -- position txt value horizontal
value_down=15 -- position txt value vertical

-- call of the function
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down,value_pos)


--###################################
--### Prozessor (CPU #2) ############
--###################################
conkyobject=conky_parse('${cpu cpu1}')

title="cpu2"
font=schriftart
fontsize=8

width=20
height=80

framelines=0
linethick=0.5

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(165,217)/255
facegreen=dnc(61,199)/255
faceblue=dnc(6,184)/255
facealpha=0.6

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=75
bar_down=bar_vertical

txt_across=70
txt_down=txt_vertical

value_across=0
value_down=15

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)

-- #################################################
-- #### Arbeitsspeicher RAM  #######################
-- #################################################
conkyobject=conky_parse('${memperc}')
title="ram"
font=schriftart
fontsize=8

framelines=0
linethick=0.5

width=20
height=80

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(250,217)/255
facegreen=dnc(236,199)/255
faceblue=dnc(114,184)/255
facealpha=0.6

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=115
bar_down=bar_vertical

txt_across=115
txt_down=txt_vertical

value_across=-5
value_down=15

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down, txtred, txtgreen, txtblue, txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)


-- #####################################################
-- ######### Heimat-Verzeichnis  (HDD - HOME) ##########
-- #####################################################

conkyobject=conky_parse('${fs_used_perc /home/alexander}')
title="home"
font=schriftart
fontsize=8

framelines=0
linethick=0.6

width=20
height=80

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(163,171)/255
facegreen=dnc(162,171)/255
faceblue=dnc(63,158)/255
facealpha=0.6

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=155
bar_down=bar_vertical

txt_across=150
txt_down=txt_vertical

value_across=1 -- position txt value horizontal
value_down=15 -- position txt value vertical

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)


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

-- #####################################################
-- ######### Batterie ######################################
-- #####################################################

conkyobject=conky_parse('${battery_percent BAT0}')
title="akku"
font=schriftart
fontsize=8

framelines=0
linethick=0.6

width=20
height=80

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(163,171)/255
facegreen=dnc(162,171)/255
faceblue=dnc(63,158)/255
facealpha=0.6

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=195
bar_down=bar_vertical

txt_across=190
txt_down=txt_vertical

value_across=1 -- position txt value horizontal
value_down=15 -- position txt value vertical

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)

end
end




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

function linie(breite,posx_1,posx_2,posy_1,posy_2)

line_width=breite
line_cap=CAIRO_LINE_CAP_BUTT

linered=dnc(128,157)/255
linegreen=dnc(136,145)/255
lineblue=dnc(195,135)/255
linealpha=0.3

startx=posx_1
endx=posx_2

starty=posy_1
endy=posy_2

----------------------------
cairo_set_line_width (cr,line_width)
cairo_set_line_cap  (cr, line_cap)
cairo_set_source_rgba (cr,linered,linegreen,lineblue,linealpha)
cairo_move_to (cr,startx,starty)
cairo_line_to (cr,endx,endy)
cairo_stroke (cr)

end


--[[ 
wordwrap_rss by arclance 
Created: 2012-08-22
Updated: 2012-10-15
Changelog
v1.2.1 2012-10-15
    simple alternating entry colors

v1.2 2012-10-13
    wrap each line on the last space (" ") so words don't get cut in half.

v1.1 2012-09-18
    Fix escaping of " characters in the RSS feed data
########################################################################
wraps a line "longLine" to the charachter length defined by "wrapLength"
returns a list containg each wraped line in order
]]

function wordwrap(longLine, wrapLength)
    if #longLine <= wrapLength then --# return list containing input line if it is shorter than the wrap length
        return {longLine}
    end --# if #longLine <= wrapLength then
    local wrapedLines = {}
    local remLine = longLine
    local lineNum = 1
    while #remLine > 0 do
        if #remLine <= wrapLength then
            wrapedLines[lineNum] = remLine
            break
        else
            local s,f,front,back = string.find(remLine:sub(1,(1 + wrapLength)), "(.*)%s(.+)")
            wrapedLines[lineNum] = front
            remLine = back..remLine:sub((2 + wrapLength),#remLine)
        end --# if #remLine <= wrapLength then
        lineNum = lineNum + 1
    end --# while #remLine > 0 do
    return wrapedLines
end --# function wordwrap(longLine, wrapLength)

function conky_rss_wrap(uri, interval_in_minutes, action, wrapLength, num_par, spaces_in_front)
    local rssCommand = "${rss "..uri.." "..interval_in_minutes.." "..action
    if num_par ~= nil then
        rssCommand = rssCommand.." "..num_par
    end --# if num_par ~= nil then
    if spaces_in_front ~= nil then
        rssCommand = rssCommand.." "..spaces_in_front
    end --# if spaces_in_front ~= nil then
    local rssText = (conky_parse((rssCommand.."}"))):gsub(",",""):gsub('"','\\"'):gsub("\n",'","')
    local rssSplit = assert(loadstring('return {"'..rssText..'"}'))()
    local output = ""
    for j = 1, #rssSplit do
        local color = nil
        if math.mod(j, 2) ~= 0 then
            color = "${color1}"
        else
            color = "${color0}"
        end --# if math.mod(j, 2) == 0 then
        local wrapedText = wordwrap(rssSplit[j], tonumber(wrapLength))
        for i = 1, #wrapedText do
            if output ~= "" then
                if i == 1 then
                    output = output.."\n"..color..wrapedText[i]
                else
                    output = output.."\n"..wrapedText[i]
                end --# if i == 1 then
            else
                output = color..wrapedText[i]
            end --# if i ~= 1 then
        end --# for i = 1, #wrapedText do
    end --# for j = 1, #rssSplit do
    return string.lower(output)
end --# function rss_wrap()


-- ####################################################################
-- ## Funktion zum Zeichnen des Hintergrunds ##########################
-- ####################################################################

function conky_draw_bg(r,x,y,w,h,color,alpha)
local function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end


-- ################################################
-- ## umwandeln von zahlen in wörter ########################
-- ################################################

function n2w(number)
--by mrpeachy 11-4-2012
number=tonumber(number)
local n_len=string.len(number)
if number<0 then
number=tonumber(string.sub(number,2,n_len))
minus="minus "
else
number=number
minus=""
end
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn",}
n2_tab={"zehn","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"}
if number>0 then n0="" else n0="null" end
if tu<20 and tu~=10 and tu~=0 then 
	out=n1_tab[tu]
elseif tu==10 then
	out="zehn"
elseif tu==0 then
	out="null"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	g=string.sub(number,2,2)
--	out=joinu..'lang:'..tu..' geschn.: '..g..' '..n2_tab[t]..'('..string.sub(tu,1,1)..','..string.sub(tu,2,2)..')'
	out=international(tu,g,n2_tab[t])
--	out=n2_tab[t]..joinu..u -- original
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return minus..h.." hundred and "..out
elseif number==100 then
	return "einhundert"
elseif number<100 then
	return minus..out
end
end--function

function international(lang,geschnitten,wort)

local anzahl=tonumber(lang) -- ganze zahl, z.b. 21
local kurzezahl=tonumber(geschnitten) -- letzte zahl, z.b. 1 von 21

if kurzezahl==1 or anzahl==1 then

 if string.len(anzahl)>1  then
 nummer='einund'..n2_tab[t]     -- gives me for example 21, 31 etc
 elseif string.len(anzahl)==1 then
 nummer='eins'			           -- gives me the number 1
 end

elseif kurzezahl~=1 or anzahl ~=1 then

   if anzahl==0 then
   nummer=wort                                     -- should give me the word 'null' (zero)
   elseif tonumber(string.sub(anzahl,1,1)) and tonumber(string.sub(anzahl,2,2))==0 then   --
   nummer=wort                                     -- gives me numbers like 10,20,30 etc.
--   elseif anzahl<0 then
--     nummer=minus..' '..wort
   else 
    nummer=n2w(kurzezahl)..'und'..wort         --  gives me such numbers like 22,23,24 etc.
    end

end

return nummer

end -- der fun ktion


--################################################

-- ################################################
-- ## umwandeln von zahlen in wörter ########################
-- ################################################

function n2w(number)

number=tonumber(number)
local n_len=string.len(number)
if number<0 then
number=tonumber(string.sub(number,2,n_len))
minus="minus "
else
number=number
minus=""
end
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn",}
n2_tab={"zehn","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"}
if number>0 then n0="" else n0="null" end
if tu<20 and tu~=10 and tu~=0 then 
	out=n1_tab[tu]
elseif tu==10 then
	out="zehn"
elseif tu==0 then
	out="null"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	g=string.sub(number,2,2)
--	out=joinu..'lang:'..tu..' geschn.: '..g..' '..n2_tab[t]..'('..string.sub(tu,1,1)..','..string.sub(tu,2,2)..')'
	out=international(tu,g,n2_tab[t])
--	out=n2_tab[t]..joinu..u -- original
end

if number>99 and number~=100 and number~=1 then
	h=n1_tab[h]
	return minus..h.." hundred and "..out
elseif number==100 then
	return "einhundert"
elseif number<100 then
	return minus..out
elseif number==1 then
       if minus=="minus " then
       return "minus ein grad"
       else
       return "whatever it should be for one"
       end
end
end--function

function international(lang,geschnitten,wort)

local anzahl=tonumber(lang) -- ganze zahl, z.b. 21
local kurzezahl=tonumber(geschnitten) -- letzte zahl, z.b. 1 von 21

if kurzezahl==1 or anzahl==1 then

 if string.len(anzahl)>1  then
 nummer='einund'..n2_tab[t]     -- gives me for example 21, 31 etc
 elseif string.len(anzahl)==1 then
 nummer='eins'			           -- gives me the number 1
 end

elseif kurzezahl~=1 or anzahl ~=1 then

   if anzahl==0 then
   nummer=wort                                     -- should give me the word 'null' (zero)
   elseif tonumber(string.sub(anzahl,1,1)) and tonumber(string.sub(anzahl,2,2))==0 then   --
   nummer=wort                                     -- gives me numbers like 10,20,30 etc.
   else 
    nummer=n2w(kurzezahl)..'und'..wort         --  gives me such numbers like 22,23,24 etc.
    end

end

return nummer

end -- der fun ktion


-- #################################################################



 local numbers =	{
 	unity		={ "ein", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"},
 	decimal		= {"zehn", "zwanzig", "dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"},
 	n		= {nil, nil, nil},
 			}

 local function n2w4d(number)
 	local i, j, s = nil, 1, ''
 	for i in pairs(numbers.n) do numbers.n[i] = nil end
 	for i = string.len(number), 1, -1 do numbers.n[j]=tonumber(string.sub(number, i, i)); j=j+1 end
 	if not numbers.n[3] and not numbers.n[2] and numbers.n[1]==0 then return 'null' end
 	if numbers.n[3] then s = numbers.unity[numbers.n[3]] .. 'hundert' end
 	if numbers.n[3] and numbers.n[2]>0 or numbers.n[3] and numbers.n[1]>0 then s = s .. ' ' end
 	if numbers.n[2] and numbers.n[2]*10+numbers.n[1]<20 then s = s .. numbers.unity[numbers.n[2]*10+numbers.n[1]]; return s end
 	if numbers.n[1]>0 then s=s .. numbers.unity[numbers.n[1]] end
 	if numbers.n[2] and numbers.n[2]>1 and numbers.n[1]>0 then s = s .. 'und' end
 	if numbers.n[2] and numbers.n[2]>0 then s = s .. numbers.decimal[numbers.n[2]] elseif numbers.n[1]==1 then s = s .. 's' end
 	return s
 end

and this is my current template:

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/

 the file:
 http://dl.dropbox.com/u/19008369/weatheragain9000.lua.tar.gz

 mrppeachys LUA Tutorial
 http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
]]

_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
--default_font="04b08" --font must be in quotes
default_font="PF Tempesta Seven"
--default_font="mono"
default_font_size=8
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

local posx=0
local posy=170
local hell=dnc(0xd1cf3d,0x988a8a)
local dunkel=dnc(0xa3a23f,0x988a8a)
local wetter_1=dnc(0x431305,0xb3a7a7)
local wetter_2=dnc(0x5D0200,0x988a8a)

--[[
-- actual date
local datum=now["day_lc"]..", "..dropZero(now["date"])..". "..now["month_lc"].." "..now["year"]
xout({x=posx,y=220,c=dunkel,txt=datum})

-- aktuelle Temperatur
xout({x=240,y=240,c=wetter_1,txt='h:'})
xout({x=260,y=240,c=wetter_2,txt=high_temp[1]})

-- gefühlte Temperatur
xout({x=240,y=255,c=wetter_1,txt='t:'})
xout({x=260,y=255,c=wetter_2,txt=low_temp[1]})

-- Niederschlagswahrscheinlichkeit
xout({x=295,y=240,c=wetter_1,txt='n:'})
xout({x=330,y=240,c=wetter_2,txt=precipitation[1]..'%',j='r'})

-- Bewölkungswahrscheinlichkeit
xout({x=295,y=255,c=wetter_1,txt='b:'})
xout({x=330,y=255,c=wetter_2,txt=cloud_cover[1]..'%',j='r'})

xout({x=0,y=240,c=dunkel,txt=now["conditions_short_lc"]})

-- Windgeschwindigkeit
local windgeschw=wind_speed_text(now['wind_km'])
xout({x=0,y=255,c=dunkel,txt=string.lower(windgeschw)})


-- #################################################################
-- ### Trennlinien zeichnen ########################################
-- #################################################################

local abstandhalter=10
local position_1=laenge(datum)+abstandhalter
local position_2=320-(laenge(laenge_mond)+abstandhalter)
local position_3=laenge(ueberschrift)+abstandhalter

--linie(1,position_3,320,28,28) -- linie news
-- linie(breite,posx_1,posx_2,posy_1,posy_2)

linie(1,position_1,330,215,215) -- linie wetter datum
-- linie(breite,posx_1,posx_2,posy_1,posy_2)

linie(1,0,position_2,270,270) -- linie mondphase
-- linie(breite,posx_1,posx_2,posy_1,posy_2)
]]--



local posx_1=25
local posx_2=220

local zahl=now["temp"]
--local zahl=1

xout({x=posx_1,y=35,c=wetter_1,txt='aktuell:'})
xout({x=posx_2,y=35,c=wetter_2,txt=n2w(zahl)..' grad ('..now["temp"]..')',j='r'})

xout({x=posx_1,y=50,c=wetter_1,txt='gefühlt:'})
xout({x=posx_2,y=50,c=wetter_2,txt=n2w(now["feels_like"])..' grad ('..now["feels_like"]..')',j='r'})

xout({x=posx_1,y=65,c=wetter_1,txt='bewölkung:'})
xout({x=posx_2,y=65,c=wetter_2,txt=n2w(cloud_cover[1])..' %',j='r'})

xout({x=posx_1,y=80,c=wetter_1,txt='niederschlag:'})
xout({x=posx_2,y=80,c=wetter_2,txt=n2w(precipitation[1])..' %',j='r'})

local posy_sonne=110
local posy_mond=125

-- Sonne

xout({x=posx_1,y=posy_sonne,c=wetter_1,txt='sonne:'})
xout({x=145,y=posy_sonne,c=wetter_2,txt=dropZero(sun_rise_24[1])..' uhr',j='r'})
xout({x=posx_2,y=posy_sonne,c=wetter_2,txt=dropZero(sun_set_24[1])..' uhr',j='r'})

xout({x=155,y=posy_sonne,c=wetter_1,txt='<'})
xout({x=160,y=posy_sonne,c=wetter_2,txt='>'})

-- Mond
xout({x=posx_1,y=posy_mond,c=wetter_1,txt='mond:'})
xout({x=145,y=posy_mond,c=wetter_2,txt=dropZero(moon_rise_24[1])..' uhr',j='r'})
xout({x=posx_2,y=posy_mond,c=wetter_2,txt=dropZero(moon_set_24[1])..' uhr',j='r'})

xout({x=155,y=posy_mond,c=wetter_1,txt='<'})
xout({x=160,y=posy_mond,c=wetter_2,txt='>'})

xout({x=posx_1,y=140,c=wetter_1,txt='mondphase:'})
xout({x=posx_2,y=140,c=wetter_2,txt=string.lower(moon_phase[1]),j='r'})


-- #################################################################
-- ## Conky-Befehle ################################################
-- #################################################################
--xout({x=posx_2,y=50,c=wetter_2,txt=n2w(now["feels_like"])..' grad ('..now["feels_like"]..')',j='r'})
--xout({f="ConkyWeather",fs=32,x=180,y=70,w=50,h=50,txt=now["weather_font"],j='r'})
--xout({x=posx_2,y=45,c=dunkel,txt=now["temp"]..' °',j='r'})
--xout({x=posx_2,y=60,c=dunkel,txt=now["feels_like"]..' °',j='r'})



local zeit=conky_parse('${time %k:%M:%S}')
local datum=now["day_lc"]..", "..dropZero(now["date"]).."."..month_number(now["month"]).." "..now["year"]

xout({x=posx_1,y=170,c=dunkel,txt='datum:'})
xout({x=posx_2,y=170,c=hell,txt=datum,j='r'})

xout({x=posx_1,y=185,c=dunkel,txt='uhrzeit:'})
xout({x=posx_2,y=185,c=hell,txt=dropZero(zeit)..' uhr',j='r'})

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

local up=conky_parse('${uptime}')

xout({x=posx_1,y=200,c=dunkel,txt='uptime:'})
xout({x=posx_2,y=200,c=hell,txt=up,j='r'})

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

local ram=conky_parse('${memmax}')

xout({x=posx_1,y=230,c=dunkel,txt='ram:'})
xout({x=posx_2,y=230,c=hell,txt=aendern(ram,'mb').." total",j='r'})

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

local cpu_core_1=conky_parse('${freq_g 1}')
local cpu_core_2=conky_parse('${freq_g 2}')

xout({x=posx_1,y=245,c=dunkel,txt='cpu #1:'})
xout({x=posx_2,y=245,c=hell,txt=string.gsub(tostring(cpu_core_1),"%.",",").." ghz",j='r'})

xout({x=posx_1,y=260,c=dunkel,txt='cpu #2:'})
xout({x=posx_2,y=260,c=hell,txt=string.gsub(tostring(cpu_core_2),"%.",",").." ghz",j='r'})


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

local fs_folder_home=conky_parse('${fs_free /home/alexander/Downloads}')
local typ_hdd_home=conky_parse("${fs_type /home/alexander/Downloads}")

local fs_folder_root=conky_parse('${fs_free /}')
local typ_hdd_root=conky_parse("${fs_type /}")

xout({x=posx_1,y=275,c=dunkel,txt='root:'})
xout({x=posx_2,y=275,c=hell,txt=aendern(fs_folder_root,'gb')..' ('..typ_hdd_root..')',j='r'})

xout({x=posx_1,y=290,c=dunkel,txt='downloads:'})
xout({x=posx_2,y=290,c=hell,txt=aendern(fs_folder_home,'gb')..' ('..typ_hdd_home..')',j='r'})

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

local speed_1=conky_parse('${downspeedf wlan0}')
local speed_2=conky_parse('${upspeedf wlan0}')
local geschw_1=string.gsub(tostring(speed_1),"%.",",")
local geschw_2=string.gsub(tostring(speed_2),"%.",",")

local anzahl_1=conky_parse('${tcp_portmon 1 32767 count}')
local anzahl_2=conky_parse('${tcp_portmon 32768 61000 count}')

--local umts_1=conky_parse('${wireless_essid ppp0}')

local total_down=conky_parse('${totaldown wlan0}')
local total_up=conky_parse('${totalup wlan0}')

----

xout({x=posx_1,y=325,c=dunkel,txt='eingehend:'})
xout({x=posx_2,y=325,c=hell,txt=n2w(anzahl_2)..' ('..anzahl_2..')',j='r'})

xout({x=posx_1,y=340,c=dunkel,txt='ausgehend:'})
xout({x=posx_2,y=340,c=hell,txt=n2w(anzahl_1)..' ('..anzahl_1..')',j='r'})

--xout({x=posx_1,y=355,c=dunkel,txt='download:'})
out({x=posx_1,y=355,c=0xffffff,face='bold',txt='download:'})
out({x=posx_2,y=355,c=0xaa6028,txt=geschw_1..' kb/s - '..total_down,face='bold'})
--out({x=astro,y=feedposy,c=farbe_head,face='bold',txt=ueberschrift_1})

out({x=posx_1,y=370,c=dunkel,txt='upload:'})
out({x=posx_2,y=370,c=hell,txt=geschw_2..' kb/s - '..total_aendern(total_up),hj='r'})

-- #################################################################
-- ## Aufruf isometric bars ########################################
-- #################################################################

conky_draw_shape()

-- #################################################################

local breite=conky_window.width
local hoehe=conky_window.height
local farbe=0x000000
local rundung=25
local bg_alpha=0.4

conky_draw_bg(rundung,0,0,breite,hoehe,farbe,bg_alpha)

--linie(1,posx_1,posx_2,90,90)
--linie(1,posx_1,posx_2,215,215)

--start or weather forecast table section
--set start forecast day
start_day=2
--set total forecast days you want to display
number_of_days=5
topy=100
gapy=65 -- topy+(gapy*1)

--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=10,topy
   top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,topy+(gapy*1)
   top_left_x_coordinate[4],top_left_y_coordinate[4]=120,topy+(gapy*1)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,topy+(gapy*2)
   top_left_x_coordinate[6],top_left_y_coordinate[6]=120,topy+(gapy*2)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,topy+(gapy*3)
   top_left_x_coordinate[8],top_left_y_coordinate[8]=120,topy+(gapy*3)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,topy+(gapy*4)
   top_left_x_coordinate[10],top_left_y_coordinate[10]=120,topy+(gapy*4)
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i]+10 --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################


--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################

the problem is that the function doesn't work. but it works with another template?!

this is the code of the other template:

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/

 the file:
 http://dl.dropbox.com/u/19008369/weatheragain9000.lua.tar.gz

 mrppeachys LUA Tutorial
 http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
]]

_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="PF Tempesta Seven" --font must be in quotes
default_font_size=8
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

local posx=0
local posy=250
--local hell=dnc(0x9ea3cd,0x988a8a)
--local dunkel=dnc(0x8088c3,0x988a8a)
--local farbe_head=dnc(0x585f8d,0xb3a7a7)
local hell=dnc(0xd1cf3d,0x988a8a)
local dunkel=dnc(0xa3a23f,0x988a8a)
local farbe_head=dnc(0xaa6028,0xb3a7a7)
------------------------

local datum=dropZero(now["date"]).."."..month_number(now["month"])..'. '..now['year']
local ueberschrift_1="rss-feed (astronews.com) vom "..datum
local astro=0
local feedposy=10

--local laenge_ueberschrift_1=laenge(ueberschrift_1)+20
--linie(1,laenge_ueberschrift_1,455,feedposy,feedposy) -- linie ueberschrift rss oben

local rss_1=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 0}") 
local rss_2=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 1}")
local rss_3=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 2}")
local rss_4=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 3}")
local rss_5=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 4}")

--local laenge_ueberschrift_2=laenge(rss_5)+20
--linie(1,laenge_ueberschrift_2,455,feedposy+80,feedposy+80) -- linie ueberschrift rss unten

out({x=astro,y=feedposy,c=farbe_head,f='mono',fs='10',face='bold',hj="l",txt=ueberschrift_1})
out({x=astro,y=feedposy+15,c=farbe_head,face='normal',hj="l",txt=string.lower(rss_1)})
xout({x=astro,y=feedposy+30,c=dunkel,txt=string.lower(rss_2),j="l"})
xout({x=astro,y=feedposy+45,c=farbe_head,txt=string.lower(rss_3),j="l"})
xout({x=astro,y=feedposy+60,c=dunkel,txt=string.lower(rss_4),j="l"})
xout({x=astro,y=feedposy+75,c=farbe_head,txt=string.lower(rss_5),j="l"})


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

--start or weather forecast table section
--set start forecast day
start_day=2
--set total forecast days you want to display
number_of_days=5
topy=100
gapy=65 -- topy+(gapy*1)

--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=10,topy
   top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,topy+(gapy*1)
   top_left_x_coordinate[4],top_left_y_coordinate[4]=120,topy+(gapy*1)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,topy+(gapy*2)
   top_left_x_coordinate[6],top_left_y_coordinate[6]=120,topy+(gapy*2)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,topy+(gapy*3)
   top_left_x_coordinate[8],top_left_y_coordinate[8]=120,topy+(gapy*3)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,topy+(gapy*4)
   top_left_x_coordinate[10],top_left_y_coordinate[10]=120,topy+(gapy*4)
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i]+10 --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################

local taglang=forecast_day[i]
local tagkurz=forecast_day_short[i]
--local tagzahl=dropZero(forecast_date[i])
local tagzahl=forecast_date[i]
local monatname=forecast_month[i]
local monatnummer=month_number(monatname)
local jahr=now["year"] -- actual year
local datum=tagzahl.."."..monatnummer.."."..jahr

--[[
xout({x=tlx+100,y=tly,c=dunkel,txt=tagkurz..','})
xout({x=tlx+170,y=tly,c=dunkel,txt=datum,j='r'})

xout({x=tlx+50,y=tly+40,f='ConkyWeather',fs=32,c=dunkel,txt=weather_font[i]})

xout({x=tlx+170,y=tly+20,c=dunkel,txt=high_temp[i].."°C",j='r'})
xout({x=tlx+170,y=tly+35,c=dunkel,txt=low_temp[i].."°C",j='r'})
]]--


--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################

Last edited by lionhead (2012-11-25 16:28:17)

Offline

#853 2012-11-25 18:10:54

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

Re: weather in conky (LUA scripts) updated 12/26/13!

DrakarNoir wrote:
mrpeachy wrote:

@sector11 or other willing volunteers

All is well with my setup! Had to restart the conky twice however to get the click function to work (though I know not if this is a result of the new code or some other issue).
Thanks for the hard work mrpeachy!

thanks for testing DrakarNoi.  I'll get around to updating the main archive in a bit

Offline

#854 2012-11-25 18:15:39

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

Re: weather in conky (LUA scripts) updated 12/26/13!

lionhead wrote:

is it possible that the new function (text-features) doesn't work because of the additional functions that i load at the same time?

xout({x=posx_2,y=340,c=hell,txt=n2w(anzahl_1)..' ('..anzahl_1..')',j='r'})

this is why i think, i havnt updated the xout function
its just as easy as changing the out function
paste this into xout above "    local function col(c,a)"

local face=txj.face		or default_face			or "normal"
--set face
if face=="normal" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
elseif face=="bold" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
elseif face=="italic" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
elseif face=="bolditalic" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
else
print ('face not set correctly - "normal","bold","italic","bolditalic"')
end

Offline

#855 2012-11-25 18:24:02

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 892

Re: weather in conky (LUA scripts) updated 12/26/13!

lionhead wrote:

@mrpeachy

would u please add the possibility to add a shadow (similar like the built in function 'draw_shades yes')?

This is how I do shaded text in lua

function draw_shaded_text(CR, text, xpos, ypos, COLOR, shade_color)
	cairo_set_source_rgba (CR,shade_color[1],shade_color[2],shade_color[3],shade_color[4]) --# set shade color
	cairo_move_to (CR,(xpos + 1),(ypos + 1))
	cairo_show_text (CR,text)
	cairo_stroke (CR)
	cairo_set_source_rgba (CR,COLOR[1],COLOR[2],COLOR[3],COLOR[4]) --# set font color
	cairo_move_to (CR,xpos,ypos)
	cairo_show_text (CR,text)
	cairo_stroke (CR)
	return CR
end --# function cr = draw_shaded_text(cr, )

If mrpeachy does not add the option maybe that can help you to add it yourself.

Offline

#856 2012-11-28 03:57:51

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 101
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

I'm having a really odd issue, the v9000 has been working with no issues at all, and all of a sudden, while running, it just stopped, and disappeared, so I downloaded the latest one from the download link in the first post, and did the configuration I needed to call on to my username, and location at intellicast, but it still wil not run, when I try to start from a terminal the only error I get is

Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value

so I really have no idea what is going on here, any ideas?


monkey Got /? | My Blog, nothing special monkey
The first GUI, and "on-line" system was created in 1968 by Douglas Engelbart, the system included modern day innovations such as video conferencing, and on-line file sharing.

Offline

#857 2012-11-28 04:17:11

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

Re: weather in conky (LUA scripts) updated 12/26/13!

^still working for me

when you launch the conky in the terminal and get the nil value error
killall conky and then scroll back up to where conky was initially launched

there is usually something there to help track down the problem

Offline

#858 2012-11-28 04:49:34

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 101
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

nevermind, I fixed it, I saw this in the terminal, which I didn't see at first for some reason or another,

Conky: llua_load: /home/mclovin/v9000/v9000.lua:8: attempt to concatenate local 'username' (a nil value)

So what I did was change

local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"
local username = mclovin  
package.path = '/home/'..username..'v9000/.v9000_config.lua'
require '.v9000_config'

to

local username = os.getenv("mclovin")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"
local username = mclovin  
package.path = '/home/mclovin/v9000/.v9000_config.lua'
require '.v9000_config'

In the start of the .lua script, as for the reason that is all of a sudden just stopped, I have no idea

this was the error I was getting from the terminal

┌─( mclovin ) ~@~ ( tweaker-sid ) kernel ( 3.6.0-4.dmz.1-liquorix-amd64 ) ~/chrono-9000
└─> ./start
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
Conky: forked to background, pid is 11837
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
Conky: llua_load: /home/mclovin/v9000/v9000.lua:8: attempt to concatenate local 'username' (a nil value)
Conky: forked to background, pid is 11839
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
Conky: llua_load: /home/mclovin/v9000/v9000.lua:8: attempt to concatenate local 'username' (a nil value)

Conky: forked to background, pid is 11851
Conky: desktop window (12000bd) is subwindow of root window (297)
Conky: window type - override
Conky: drawing to created window (0x3200001)
Conky: drawing to double buffer
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
Conky: forked to background, pid is 11853
┌─( mclovin ) ~@~ ( tweaker-sid ) kernel ( 3.6.0-4.dmz.1-liquorix-amd64 ) ~/chrono-9000
└─> 
Conky: desktop window (12000bd) is subwindow of root window (297)
Conky: window type - override
Conky: drawing to created window (0x3400001)
Conky: drawing to double buffer

sh: 1: aptitude: not found
Conky: desktop window (12000bd) is subwindow of root window (297)
Conky: window type - override
Conky: drawing to created window (0x3800001)
Conky: drawing to double buffer
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value

Conky: desktop window (12000bd) is subwindow of root window (297)
Conky: window type - override
Conky: drawing to created window (0x3a00001)
Conky: drawing to double buffer
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
--2012-11-27 23:44:10--  https://slaughter.dave:*password*@mail.google.com/mail/feed/atom
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
--2012-11-27 23:44:10--  https://slaughter.dave:*password*@mail.google.com/mail/feed/atom
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
--2012-11-27 23:44:10--  https://slaughter.dave:*password*@mail.google.com/mail/feed/atom
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Resolving mail.google.com (mail.google.com)... 74.125.226.246, 74.125.226.245, 2607:f8b0:4006:803::1015
Connecting to mail.google.com (mail.google.com)|74.125.226.246|:443... connected.
Resolving mail.google.com (mail.google.com)... 74.125.226.245, 74.125.226.246, 2607:f8b0:4006:803::1015
Connecting to mail.google.com (mail.google.com)|74.125.226.245|:443... Resolving mail.google.com (mail.google.com)... 74.125.226.246, 74.125.226.245, 2607:f8b0:4006:803::1015
Connecting to mail.google.com (mail.google.com)|74.125.226.246|:443... connected.
connected.
HTTP request sent, awaiting response... Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
401 Unauthorized
Reusing existing connection to mail.google.com:443.
HTTP request sent, awaiting response... HTTP request sent, awaiting response... HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to mail.google.com:443.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to mail.google.com:443.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/xml]
Saving to: ‘STDOUT’

    [ <=>                                 ] 947         --.-K/s   in 0s      

2012-11-27 23:44:11 (42.8 MB/s) - written to stdout [947]

200 OK
Length: unspecified [text/xml]
Saving to: ‘STDOUT’

    [ <=>                                 ] 947         --.-K/s   in 0s      

2012-11-27 23:44:11 (58.5 MB/s) - written to stdout [947]

200 OK
Length: unspecified [text/xml]
Saving to: ‘STDOUT’

    [ <=>                                 ] 947         --.-K/s   in 0s      

2012-11-27 23:44:11 (35.7 MB/s) - written to stdout [947]

Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
ERROR: TransmissionInfo Init:Unexpected error: Original exception: HTTPHandlerError, "HTTPHandlerError 111: Connection refused"
ERROR: writeOutput:Unexpected error:TransmissionInfo instance has no attribute 'client'
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
--2012-11-27 23:44:11--  https://slaughter.dave:*password*@mail.google.com/mail/feed/atom
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
--2012-11-27 23:44:11--  https://slaughter.dave:*password*@mail.google.com/mail/feed/atom
WARNING: gnome-keyring:: couldn't connect to: /home/mclovin/.cache/keyring-YfatWK/pkcs11: No such file or directory
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Resolving mail.google.com (mail.google.com)... 74.125.226.245, 74.125.226.246, 2607:f8b0:4006:803::1015
Connecting to mail.google.com (mail.google.com)|74.125.226.245|:443... Resolving mail.google.com (mail.google.com)... 74.125.226.246, 74.125.226.245, 2607:f8b0:4006:803::1015
Connecting to mail.google.com (mail.google.com)|74.125.226.246|:443... connected.
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
connected.
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
HTTP request sent, awaiting response... HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to mail.google.com:443.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to mail.google.com:443.
HTTP request sent, awaiting response... Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
200 OK
Length: unspecified [text/xml]
Saving to: ‘STDOUT’

    [ <=>                                 ] 947         --.-K/s   in 0s      

2012-11-27 23:44:12 (19.5 MB/s) - written to stdout [947]

200 OK
Length: unspecified [text/xml]
Saving to: ‘STDOUT’

    [ <=>                                 ] 947         --.-K/s   in 0s      

2012-11-27 23:44:12 (27.5 MB/s) - written to stdout [947]

Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
ERROR: TransmissionInfo Init:Unexpected error: Original exception: HTTPHandlerError, "HTTPHandlerError 111: Connection refused"
ERROR: writeOutput:Unexpected error:TransmissionInfo instance has no attribute 'client'
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_weather execution failed: attempt to call a nil value
Conky: received SIGINT or SIGTERM to terminate. bye!
Conky: received SIGINT or SIGTERM to terminate. bye!
Conky: received SIGINT or SIGTERM to terminate. bye!
Conky: received SIGINT or SIGTERM to terminate. bye!

monkey Got /? | My Blog, nothing special monkey
The first GUI, and "on-line" system was created in 1968 by Douglas Engelbart, the system included modern day innovations such as video conferencing, and on-line file sharing.

Offline

#859 2012-11-28 07:12:23

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

Re: weather in conky (LUA scripts) updated 12/26/13!

so is it working?

this may have been the reason:
local username = mclovin

needs to be

local username = "mclovin"

Offline

#860 2012-11-28 07:47:24

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 101
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

yeah, i got it working, though I'm not sure why it suddenly just stopped, it was working fine, and then wham, but it is all fixed up and running now, after I noticed that error in the terminal, I went in and fixed it, just don;t know why it was working with config i had, and still using the same config, it stopped working.


monkey Got /? | My Blog, nothing special monkey
The first GUI, and "on-line" system was created in 1968 by Douglas Engelbart, the system included modern day innovations such as video conferencing, and on-line file sharing.

Offline

#861 2012-11-28 16:13:46

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,691
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

Glad to see it working McL.  maybe a recent update require that the:

local username = "mclovin"

was needed.  As soon as that appeared, I added it by default because like it says:

--you can enter your username here in case of errors,

and in my mind I heard that really old commercial:

Why wait for Spring, do it now!

Why wait for Errors, do it now!  big_smile


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Online

#862 2012-11-28 19:56:51

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

i have problems to format a bit of the text into italic.

as you can see in the screenshot it's just possible to use bold text. i already tried several fonts but nothing worked.

this is my v9000 main-file:

--weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
require 'cairo'
require 'imlib2'
local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"

local username = "alexander"
package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

start=1
--INITIALIZE SETTINGS-- need only be run once
settings_table=weather_settings()
--##################################
--######## main function ########### 
function conky_weather()--##########
--##################################
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}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
--################################################
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]
--################################################
print ("gathering data with curl")
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section
--#########################################################################

--#########################################################################
--in case curl craps up it should retry until it works
if testall==nil or  alerttest==nil then
print ("curl attempt timed out, trying again")
local web=settings_table[2]
local alert_check=settings_table[13]
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert_check
processall=1
end--if testall==nil
--end or curl reruns ######################################################

--START PROCESSING ###########################################################################
if testall~=nil and alerttest~=nil and processall==1 then
local weathericons=settings_table[3]
local con_short=settings_table[4]
local visibility_unit=settings_table[6]
local wind_mph_unit=settings_table[7]
local wind_km_unit=settings_table[8]
local wind_kts_unit=settings_table[9]
local ceiling_unit=settings_table[10]
local wind_degrees_unit=settings_table[11]
local translate=settings_table[12]
local alert_check=settings_table[13]
--#########################################################################
--LOAD TRANSLATE TABLES IF TRANSLATE SETTING = 1
	if translate==1 then
	monthshort=settings_table[21]
	monthnames=settings_table[20]
	dayhort=settings_table[19]
	daynames=settings_table[18]
	neswtext=settings_table[14]
	tsuffix=settings_table[15]
	uvindextext=settings_table[16]
	moonphases=settings_table[17]
	additional=settings_table[22]
	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort

	dayshort={Monday="Mon",Tuesday="Tue",Wednesday="Wed",Thursday="Thu",Friday="Fri",Saturday="Sat",Sunday="Sun"}
	monthshort={January="Jan",February="Feb",March="Mar",April="Apr",May="May",June="Jun",July="Jul",August="Aug",September="Sep",October="Oct",November="Nov",December="Dec"}
	end--end if translate =1
--#########################################################################
--process data tables
--intellicast to conky weather icon conversion
wimage={
wx_65="32",  -- Clear
wx_66="30",  -- Partly Cloudy
wx_67="26",  -- Cloudy
wx_68="32",  -- Clear
wx_69="28",  -- Mostly Cloudy
wx_70="20",  -- Fog
wx_71="32",  -- Clear
wx_72="21",  -- Haze
wx_73="36",  -- Hot
wx_74="14",  -- Light Snow Showers
wx_75="28",  -- Mostly Cloudy
wx_76="18",  -- Sleet
wx_77="14",  -- Light Snow Showers
wx_78="23",  -- Blustery
wx_79="05",  -- Mixed Rain and Snow
wx_80="15",  -- Drifting Snow
wx_81="15",  -- Drifting Snow
wx_82="11",  -- Light Rain
wx_83="16",  -- Snow
wx_84="00",  -- Tornado
wx_85="32",  -- Clear
wx_86="25",  -- N/A
wx_87="09",  -- Drizzle
wx_88="05",  -- Mixed Rain and Snow
wx_89="18",  -- Sleet
wx_90="18",  -- Sleet
wx_91="39",  -- Scattered Showers
wx_92="39",  -- Scattered Showers
wx_93="39",  -- Scattered Showers
wx_94="39",  -- Scattered Showers
wx_95="37",  -- Isolated Thunderstorms
wx_96="37",  -- Isolated Thunderstorms
wx_97="31",  -- Clear
wx_98="29",  -- Partly Cloudy
wx_99="27",  -- Mostly Cloudy
wx_100="47",  -- Isolated Thunderstorms
wx_101="47",  -- Isolated Thunderstorms
wx_102="33",  -- Fair
wx_103="26",  -- Cloudy
wx_104="20",  -- Fog
wx_105="45",  -- Scattered Showers
wx_106="45",  -- Scattered Showers
wx_107="11",  -- Light Rain
wx_108="46",  -- Snow Showers
wx_109="46",  -- Snow Showers
wx_110="06",  -- Mixed Rain and Sleet
wx_111="18",  -- Sleet
wx_112="06",  -- Mixed Rain and Sleet
wx_113="46",  -- Snow Showers
wx_114="46",  -- Snow Showers
wx_115="31",  -- Clear
wx_116="47",  -- Isolated Thunderstorms
}--end w image table
--convert intellicast icons to weather font
wfont={
wx_65="a",
wx_66="c",
wx_67="f",
wx_68="a",
wx_69="d",
wx_70="0",
wx_71="a",
wx_72="9",
wx_73="5",
wx_74="p",
wx_75="d",
wx_76="w",
wx_77="p",
wx_78="6",
wx_79="x",
wx_80="8",
wx_81="8",
wx_82="h",
wx_83="q",
wx_84="m",
wx_85="a",
wx_86="-",
wx_87="h",
wx_88="x",
wx_89="w",
wx_90="w",
wx_91="g",
wx_92="g",
wx_93="g",
wx_94="g",
wx_95="k",
wx_96="k",
wx_97="A",
wx_98="C",
wx_99="D",
wx_100="K",
wx_101="K",
wx_102="B",
wx_103="f",
wx_104="0",
wx_105="G",
wx_106="G",
wx_107="h",
wx_108="O",
wx_109="O",
wx_110="x",
wx_111="w",
wx_112="x",
wx_113="O",
wx_114="O",
wx_115="A",
wx_116="K",
}--end w font table
--conversion day and month tables
moonfontt={
["New"]="@",
["Full"]="=",
["First Quarter"]="T",
["Last Quarter"]="G",
["Waning Gibbous"]="D",
["Waning Crescent"]="J",
["Waxing Crescent"]="Q",
["Waxing Gibbous"]="W",
}--end of moon font table
moonicont={
["New"]=weathericons.."moon_new.png",
["Full"]=weathericons.."moon_full.png",
["First Quarter"]=weathericons.."moon_first_quarter.png",
["Last Quarter"]=weathericons.."moon_last_quarter.png",
["Waning Gibbous"]=weathericons.."moon_waning_gibbous.png",
["Waning Crescent"]=weathericons.."moon_waning_crescent.png",
["Waxing Crescent"]=weathericons.."moon_waxing_crescent.png",
["Waxing Gibbous"]=weathericons.."moon_waxing_gibbous.png",
}--end of moon icon table
windfontt={
S="9",
SSW=":",
SW=";",
WSW="<",
W="=",
WNW=">",
NW="?",
NNW="@",
N="1",
NNE="2",
NE="3",
ENE="4",
E="5",
ESE="6",
SE="7",
SSE="8"
}--end of wind direction font table
--#########################################################################

--#########################################################################
--setup tables for forecast weather
forecast_day={}
forecast_day_caps={}
forecast_day_lc={}
forecast_day_short={}
forecast_day_short_caps={}
forecast_day_short_lc={}
forecast_month={}
forecast_month_caps={}
forecast_month_lc={}
forecast_month_short={}
forecast_month_short_caps={}
forecast_month_short_lc={}
forecast_date={}
weather_icon={}
weather_font={}
high_temp={}
low_temp={}
conditions={}
conditions_caps={}
conditions_lc={}
conditions_short={}
conditions_short_caps={}
conditions_short_lc={}
sun_rise={}
sun_rise_lc={}
sun_rise_time={}
sun_rise_24={}
moon_rise={}
moon_rise_lc={}
moon_rise_time={}
moon_rise_24={}
moon_rise_ampm={}
moon_rise_ampm_lc={}
sun_set={}
sun_set_lc={}
sun_set_time={}
sun_set_24={}
moon_set={}
moon_set_lc={}
moon_set_time={}
moon_set_24={}
moon_set_ampm={}
moon_set_ampm_lc={}
humidity={}
precipitation={}
snow={}
cloud_cover={}
moon_phase={}
moon_phase_caps={}
moon_phase_lc={}
moon_font={}
moon_icon={}
wind_mph={}
wind_km={}
wind_kts={}
wind_font={}
wind_icon={}
wind_deg={}
wind_nesw={}
uv_index_num={}
uv_index_txt={}
uv_index_txt_caps={}
uv_index_txt_lc={}
--#########################################################################

--#########################################################################
--get forecast chunk
local a,b,allweather=string.find(allweatherdata,">10 Day Forecast&nbsp(.*)>More from Intellicast</div>")
--extract information into tables
local start=0
local f=1
while f~=nil do
--match forecast day name and date
local s,f,t=string.find(allweather,"<td colspan=\"2\"><strong>([%a,%s%d]*)</strong></td>",start)
	if t~=nil then
	--split name from month and date
	local a,b,day=string.find(t,"(%a*),%s")
	local a,b,month=string.find(t,",%s(%a*)%s")
	local a,b,date=string.find(t,"(%d*)$")
	--ser day names, regular, caps, lowercase and short
	table.insert(forecast_day_short,dayshort[day])
	table.insert(forecast_day_short_caps,string.upper(dayshort[day]))
	table.insert(forecast_day_short_lc,string.lower(dayshort[day]))
		if translate==1 then
		day=daynames[day]
		else
		day=day
		end
	table.insert(forecast_day,day)
	table.insert(forecast_day_caps,string.upper(day))
	table.insert(forecast_day_lc,string.lower(day))
	--set month types
	table.insert(forecast_month_short,monthshort[month])
	table.insert(forecast_month_short_caps,string.upper(monthshort[month]))
	table.insert(forecast_month_short_lc,string.lower(monthshort[month]))
		if translate==1 then
		month=monthnames[month]
		else
		month=month
		end
	table.insert(forecast_month,month)
	table.insert(forecast_month_caps,string.upper(month))
	table.insert(forecast_month_lc,string.lower(month))
	--set date
	table.insert(forecast_date,date)
	end--if t~= nil
--intellicast weather icon match
local s,f,t=string.find(allweather,"40_white/(wx_[%d]*).png\"",start)
--convert to conkyweather icon
	if t~=nil then
	table.insert(weather_icon,weathericons..wimage[t]..".png")
	--convert to weather font
	table.insert(weather_font,wfont[t])
	end
--match conditions
local s,f,t=string.find(allweather," /><br />([%a%s%p]*)</td>",start)
	if t~=nil then
	table.insert(conditions,t)
	table.insert(conditions_caps,string.upper(t))
	table.insert(conditions_lc,string.lower(t))
	--set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	table.insert(conditions_short,cons)
	table.insert(conditions_short_caps,string.upper(cons))
	table.insert(conditions_short_lc,string.lower(cons))
	-----------------------------------------------------
	end
--match high temp
local s,f,t=string.find(allweather,"\"Hi\">([%p%d]*)&deg",start)
table.insert(high_temp,t)
--match low temp
local s,f,t=string.find(allweather,"\"Lo\">([%p%d]*)&deg",start)
table.insert(low_temp,t)
--match sun rise times
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",start)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(sun_rise_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_rise,tm.." "..suf)
	table.insert(sun_rise_lc,string.lower(tm.." "..suf))
	table.insert(sun_rise_time,tm)
	end
--match sun set times
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then	
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(sun_set_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_set,tm.." "..suf)
	table.insert(sun_set_lc,string.lower(tm.." "..suf))
	table.insert(sun_set_time,tm)
	end
--moon rise
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(moon_rise_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_rise,tm.." "..suf)
	table.insert(moon_rise_lc,string.lower(tm.." "..suf))
	table.insert(moon_rise_time,tm)
	table.insert(moon_rise_ampm,suf)
	table.insert(moon_rise_ampm_lc,string.lower(suf))
	end
--moon set
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(moon_set_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_set,tm.." "..suf)
	table.insert(moon_set_lc,string.lower(tm.." "..suf))
	table.insert(moon_set_time,tm)
	table.insert(moon_set_ampm,suf)
	table.insert(moon_set_ampm_lc,string.lower(suf))
	end
--match uv index
local s,f,tuv=string.find(allweather,"UV Index:</strong>%s*(%d*%s*%([%a%s]*%))%s*<br />",start)
if tuv~=nil then
	--get just number
	local a,b,unm=string.find(tuv,"(%d*)%s*%([%a%s]*%)")
	--get just text
	local a,b,utx=string.find(tuv,"%d*%s*%(([%a%s]*)%)")
	table.insert(uv_index_num,unm)
		if translate==1 then
		utx=uvindextext[utx]
		else
		utx=utx
		end
	table.insert(uv_index_txt,utx)
	table.insert(uv_index_txt_caps,string.upper(utx))
	table.insert(uv_index_txt_lc,string.lower(utx))
	end
--match humidity
local s,f,t=string.find(allweather,"Humidity:</strong> (%d*)<br />",start)
table.insert(humidity,t)
--match ppt
local s,f,t=string.find(allweather,"Precipitation:</strong> (%d*)<br />",start)
table.insert(precipitation,t)
--match snow %
local s,f,t=string.find(allweather,"Snow Probability:</strong>%s*(%d*)<br />",start)
table.insert(snow,t)
--match cloud coveage
local s,f,t=string.find(allweather,"Cloud Coverage:</strong> (%d*)<br />",start)
table.insert(cloud_cover,t)
--match moon phase
local s,f,t=string.find(allweather,"Moon Phase:</strong> ([%a%s]*) <br />",start)
--set moon phase text
	if t~= nil then
	--set moon phase font and icon
	table.insert(moon_font,moonfontt[t])
	table.insert(moon_icon,moonicont[t])
		if translate==1 then
		t=moonphases[t]
		else
		t=t
		end
	table.insert(moon_phase,t)
	table.insert(moon_phase_caps,string.upper(t))
	table.insert(moon_phase_lc,string.lower(t))
	end
--match wind speeds
local s,f,tmph=string.find(allweather,"Wind Speed:</strong> (%d*)Mph",start)
local tmph=tonumber(tmph)
table.insert(wind_mph,tmph)
local s,f,t=string.find(allweather,"Mph%s*%((%d*)Km,",start)
table.insert(wind_km,t)
local s,f,t=string.find(allweather,"Km,%s*(%d*)Kts%)",start)
table.insert(wind_kts,t)
--match wind direction
local s,f,twd=string.find(allweather,"Wind Direction:</strong> ([%d&;%s%(%a%)]*)%s*</div>",start)
	if twd~=nil then
	local a,b,tdeg=string.find(twd,"(%d*)&deg;")
	table.insert(wind_deg,tdeg)
	--match wind font and nesw   
	local a,b,tnesw=string.find(twd,"%((%a*)%)")
	table.insert(wind_font,windfontt[tnesw])
		if tmph>0 and tmph<19 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph>18 and tmph<38 then
		table.insert(wind_icon,weathericons.."yellow_"..string.lower(tnesw)..".png")
		elseif tmph>37 and tmph<64 then
		table.insert(wind_icon,weathericons.."orange_"..string.lower(tnesw)..".png")
		elseif tmph>63 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph==0 then
		table.insert(wind_icon,weathericons.."no_wind.png")
		end
		if translate==1 then
		tnesw=neswtext[tnesw]
		else
		tnesw=tnesw
		end
	table.insert(wind_nesw,tnesw)
	end
if f==nil then break end
start=f
end--while
--#########################################################################################################################################

--#########################################################################
--get location
local a,b,wl=string.find(allweatherdata,"<title>%s*Intellicast%s%p%s(.*)</title>")
weather_location=string.gsub(wl," Extended Forecast in",",")
--#########################################################################

--#########################################################################
--format now weather
--extract current data
--get now weather chunk
local a,b,nowweather=string.find(allweatherdata,">Current Conditions&nbsp(.*)>View Detailed Observations for the last<br />")
now={}
monthlong={Jan="January",Feb="February",Mar="March",Apr="April",May="May",Jun="June",Jul="July",Aug="August",Sep="September",Oct="October",Nov="November",Dec="December"}
local s,f,tnow=string.find(nowweather,"<div style=\"float:right;color:#666;\">  As of ([%d%p%a%s]*) %(Local Time%)")
local s,f,t=string.find(tnow,"(%d*%p%d*%s%a*) on")
--get time only
local a,b,ntm=string.find(t,"(%d*%p%d*)")
--get suffix only
local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
now["time_24"]=convert24(ntm,suf)
--###############################
if translate==1 then
suf=tsuffix[suf]
else
suf=suf
end
now["time"]=ntm.." "..suf
now["time_lc"]=string.lower(ntm.." "..suf)
now["time_num"]=ntm
now["time_ampm"]=suf
now["time_ampm_lc"]=string.lower(suf)
--get day
local s,f,t=string.find(tnow,"on (%a*)%s%d*")
if translate==1 then
day=daynames[t]
else
day=t
end
now["day"]=day
now["day_caps"]=string.upper(day)
now["day_lc"]=string.lower(day)
--short day names
local ds=dayshort[t]
now["day_short"]=ds
now["day_short_caps"]=string.upper(ds)
now["day_short_lc"]=string.lower(ds)
--get date
local s,f,t=string.find(tnow,"%s(%d%d)%s")
now["date"]=t
--get months
local s,f,t=string.find(tnow,"%d%d%s(%a*)%s%d")
if translate==1 then
mnth=monthlong[t]
now["month_short"]=monthshort[mnth]
now["month_short_caps"]=string.upper(monthshort[mnth])
now["month_short_lc"]=string.lower(monthshort[mnth])
mnth=monthnames[mnth]
else
now["month_short"]=t
now["month_short_caps"]=string.upper(t)
now["month_short_lc"]=string.lower(t)
mnth=monthlong[t]
end
now["month"]=mnth
now["month_caps"]=string.upper(mnth)
now["month_lc"]=string.lower(mnth)
--get year
local s,f,t=string.find(tnow,"%a%a%a%s(%d%d%d%d)")
now["year"]=t
--get weather icon
local s,f,t=string.find(nowweather,"40_white/(wx_[%d]*)%ppng%p%stitle=%p")
now["weather_icon"]=weathericons..wimage[t]..".png"
now["weather_font"]=wfont[t]
--class=%pIcon%p /> ([%a%s]*)%s*</td>
local s,f,t=string.find(nowweather,"class=%pIcon%p /> ([%a%s%p]*)%s*%s*</td>%s*<td class=%pEmpty%p>&nbsp;")
now["conditions"]=t
now["conditions_caps"]=string.upper(t)
now["conditions_lc"]=string.lower(t)
--set short versions------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["conditions_short"]=cons
	now["conditions_short_caps"]=string.upper(cons)
	now["conditions_short_lc"]=string.lower(cons)
--------------------------------------------
local s,f,t=string.find(nowweather,"Temperature\">([%p%d]*)&deg")
now["temp"]=t
local s,f,t=string.find(nowweather,">Feels Like: ([%p%d]*)&deg;</a>")
now["feels_like"]=t
local s,f,t=string.find(nowweather,">Wind Chill: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["wind_chill"]=t
local s,f,t=string.find(nowweather,">Ceiling: </a></td>%s*<td>([%a%d]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tc=t..ceiling_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tc=unlset
end
now["ceiling"]=tc
now["ceiling_caps"]=string.upper(tc)
now["ceiling_lc"]=string.lower(tc)
--get heat index
local s,f,t=string.find(nowweather,">Heat Index: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["heat_index"]=t
--get visibility
local s,f,t=string.find(nowweather,">Visibility: </a></td>%s*<td>([%a%d%p]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tv=t..visibility_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tv=unlset
end
now["visibility"]=tv
now["visibility_caps"]=string.upper(tv)
--get dew point
local s,f,t=string.find(nowweather,">Dew Point: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["dew_point"]=t
--get wind speed
local s,f,t=string.find(nowweather,">Wind: </a></td>%s*<td>(%d*)mph</td>")
local tmph=tonumber(t)
now["wind_mph"]=t..wind_mph_unit
now["wind_mph_caps"]=string.upper(t..wind_mph_unit)
--convert mph to km and knots #################################################
--[[1 mile per hour = 0.869 international nautical mile per hour (knot)
     1 mile per hour = 1.609 kilometers per hour
     1 mile per hour = 0.4470 meter per second
     1 knot = 1.852 kilometers per hour
     1 knot = 0.5144 meter per second
     1 meter per second = 3.6 kilometers per hour]]
now["wind_km"]=round(tonumber(t)*1.609)..wind_km_unit
now["wind_km_caps"]=string.upper(round(tonumber(t)*1.609)..wind_km_unit)
now["wind_kts"]=round(tonumber(t)*0.869)..wind_kts_unit
now["wind_kts_caps"]=string.upper(round(tonumber(t)*0.869)..wind_kts_unit)
--#############################################################################
local s,f,t=string.find(nowweather,">Humidity: </a></td>%s*<td>(%d*)</td>")
now["humidity"]=t
--get wind direction #######################################################
local s,f,twd=string.find(nowweather,">Direction: </a></td>%s*<td style=[%p%a]*>([%d&;%s%(%a%)]*)</td>%s*</tr>")
--check for NA
local a,b,t=string.find(twd,"(%a*)")
local tnesw=t
if tnesw~="NA" then
local a,b,t=string.find(twd,"(%d*)&deg;")
now["wind_deg"]=t..wind_degrees_unit
local a,b,tnesw=string.find(twd,"%((%a*)%)")
	if tmph>0 and tmph<19 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	elseif tmph>18 and tmph<38 then
	now["wind_icon"]=weathericons.."yellow_"..string.lower(tnesw)..".png"
	elseif tmph>37 and tmph<64 then
	now["wind_icon"]=weathericons.."orange_"..string.lower(tnesw)..".png"
	elseif tmph>63 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	end
now["wind_font"]=windfontt[tnesw]
--################################
	if translate==1 then
	tnesw=neswtext[tnesw]
	else
	tnesw=tnesw
	end
--################################
now["wind_nesw"]=tnesw		
else
	if translate==1 then naset=additional.NA else naset="NA" end
now["wind_deg"]=naset
now["wind_icon"]=weathericons.."no_wind.png"
now["wind_nesw"]=naset
now["wind_font"]=windfontt["N"]
end
--END WIND DIRECTION #######################################################
--get pressure
local s,f,t=string.find(nowweather,">Pressure: </a></td>%s*<td>([%d%p]*)\"</td>")
now["pressure"]=t
--convert pressures ########################################################
--[[ 1 inch of mercury = 25.4 mm of mercury = 33.86 millibars
     = 33.86 hectoPascals]]
now["pressure_mb"]=round(tonumber(t)*33.86)
--##########################################################################
local s,f,t=string.find(nowweather,">Gusts: </a></td>%s*<td>([%d%a]*)</td>")
if t~="NA" then
local s,f,t=string.find(t,"(%d*)")
tg=t..wind_mph_unit
tgkm=round(tonumber(t)*1.609)..wind_km_unit
tgkts=round(tonumber(t)*0.869)..wind_kts_unit
else
	if translate==1 then naset=additional.NA else naset="NA" end
tg=naset
tgkm=naset
tgkts=naset
end
now["wind_gusts"]=tg
now["wind_gusts_caps"]=string.upper(tg)
now["wind_gusts_km"]=tgkm
now["wind_gusts_km_caps"]=string.upper(tgkm)
now["wind_gusts_kts"]=tgkts
now["wind_gusts_kts_caps"]=string.upper(tgkts)
--##########################################################################
--get hourly forecast options hour1--------------------
--get day 1 bit
local s,f,hfc=string.find(nowweather,"<td class=%pHour%p%sstyle=%ppadding%pleft([%a%d%p%s]*)%pdeg%p</strong>",1)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",1)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",1)
--24 hour conversion ######################
now["fc_hour1_time_24"]=convert24(tm,suf)
--#########################################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour1_time"]=tm
now["fc_hour1_ampm"]=suf
now["fc_hour1_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%p%s%a]*)%s*</td>%s*<td class=%pHour%p",1)
now["fc_hour1_cond"]=t
now["fc_hour1_cond_lc"]=string.lower(t)
now["fc_hour1_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour1_cond_short"]=cons
	now["fc_hour1_cond_short_caps"]=string.upper(cons)
	now["fc_hour1_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",1)
now["fc_hour1_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour1_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",1)
now["fc_hour1_temp"]=t
--end of hour1 data gathering--repeat 2 more times
--get hourly forecast options hour2--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion ######################
now["fc_hour2_time_24"]=convert24(tm,suf)
--#########################################	
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour2_time"]=tm
now["fc_hour2_ampm"]=suf
now["fc_hour2_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour2_cond"]=t
now["fc_hour2_cond_lc"]=string.lower(t)
now["fc_hour2_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour2_cond_short"]=cons
	now["fc_hour2_cond_short_caps"]=string.upper(cons)
	now["fc_hour2_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour2_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour2_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",start)
now["fc_hour2_temp"]=t
--end of hour2 data gathering--repeat 1 more times
--get hourly forecast options hour3--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion ######################
now["fc_hour3_time_24"]=convert24(tm,suf)
--#########################################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour3_time"]=tm
now["fc_hour3_ampm"]=suf
now["fc_hour3_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour3_cond"]=t
now["fc_hour3_cond_lc"]=string.lower(t)
now["fc_hour3_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour3_cond_short"]=cons
	now["fc_hour3_cond_short_caps"]=string.upper(cons)
	now["fc_hour3_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour3_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour3_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)",start)
now["fc_hour3_temp"]=t
--end of hour3 data gathering--finished for all hours
--ALERTS###############################################################
if alert_check==1 then
--set tables
alert_type={}
alert_issued={}
if alerttest~=0 then
alert_icon=weathericons.."icon_alert_1.gif"
--extract information into tables
local start=0
local f=1
while f~=nil do
local s,f,t=string.find(alertdata,"><strong class='Alert'>([%a%s]*)</strong><br/>",start)
	if t~=nil then
	table.insert(alert_type,string.upper(t))
	end--if t~=nil
local s,f,t=string.find(alertdata,"<br />([%d%a%s:]*)<br /><br />",start)
	if t~=nil then
	table.insert(alert_issued,t)
	end--if t~=nil
if f==nil then break end
start=f
alert_number=#alert_type
end--while
else
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"NO ALERTS")
table.insert(alert_issued,"")
alert_number=0
end--alerttest~=nil
else
alert_type={}
alert_issued={}
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"alerts turned off")
table.insert(alert_issued,"")
alert_number=0
end--if alert check ###########################################
--###############end of data processing########################

--#########################################################################
if testing==0 then
processall=0
print ("processing complete")
elseif testing==1 then
processall=1
end--if testing ==0
--###################################################################################
end--of data processing section #####################################################
--###################################################################################
if processall==0 or testing==1 then
_G.weather_script()
end
--#########################################################################################################
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--end--####### end of if updates>5 #############################
--#########################################################################################################

cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--######################################
end-- end main function ################
--######################################
function round(num)
	local idp=tonumber(settings_table[5])
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end--of round function #################################################################
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--string split #######################################################################

function xout(txj)--c,a,f,fs,x,y,txt,j ##################################################
c=nil
c=(txj.c or default_color)
a=nil
a=(txj.a or default_alpha)
f=nil
f=(txj.f or default_font)
fs=nil
fs=(txj.fs or default_font_size)
x=nil
x=(txj.x or 0)
y=nil
y=(txj.y or 0)
txt=nil
txt=(txj.txt or "set txt")
j=nil
j=(txj.j or "l")
	local function col(c,a)
	return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
	end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local text=string.gsub(txt," ","_")
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local wx=extents.width
cairo_set_source_rgba (cr,col(c,a))
if j=="l" then
cairo_move_to (cr,x,y)
adx=wx
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
adx=wx/2
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
adx=0
end
cairo_show_text (cr,txt)
cairo_stroke (cr)
nextx=nil
nextx=adx+x
return nextx
end--function xout ###################################################################


function out(txj)--c,a,f,fs,face,x,y,txt,hj,vj,ro ##################################################
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
--#########################################################################################################
local function color(col,alp)
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
--#########################################################################################################
local c=txj.c 			or default_color		or 0xffffff
local a=txj.a 			or default_alpha		or 1
local f=txj.f 			or default_font			or "mono"
local fs=txj.fs 		or default_font_size		or 12
local x=txj.x 			or 100
local y=txj.y 			or 100
local txt=txj.txt 		or "set txt"
local hj=txj.hj 		or default_hj			or "l"
local vj=txj.vj 		or default_vj			or "n"
local ro=txj.ro			or defaukt_ro			or 0
local face=txj.face		or default_face			or "normal"
--set face
if face=="normal" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
elseif face=="bold" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
elseif face=="italic" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
elseif face=="bolditalic" then
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
else
print ('face not set correctly - "normal","bold","italic","bolditalic"')
end
cairo_set_font_size (cr, fs)
cairo_text_extents(cr,txt,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
local tx=x
local ty=y
--set horizontal alignment - l, c, r
if hj=="l" then
x=x-bx
rad=0
elseif hj=="c" then
x=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
x=x-wx
rad=wx-bx
else
print ("hj not set correctly - l, c, r")
end
--vj. n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
y=y
rad2=0
ry=by
elseif vj=="nb" then
y=y-by
rad2=-by
ry=by
elseif vj=="m" then
y=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
y=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
y=y+hy-by
rad2=hy-by
ry=0+by
else
print ("vj not set correctly - n, nb, m, mb, t")
end
--rotation
if ro~=0 then
local point2=(math.pi/180)*(ro-180)
local x2=tx+rad2*(math.sin(point2))
local y2=ty-rad2*(math.cos(point2))
local point=(math.pi/180)*(ro-90)
local x1=x2+rad*(math.sin(point))
local y1=y2-rad*(math.cos(point))
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*ro)
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,x,y)
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--if ro
end--function out ###################################################################

function image(im)--#################################################################
x=nil
x=(im.x or 0)
y=nil
y=(im.y or 0)
w=nil
w=(im.w or default_image_width)
h=nil
h=(im.h or default_image_height)
file=nil
file=tostring(im.file)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(w)
end
if tonumber(h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x, y)
imlib_free_image()
show=nil
end--function image ##################################################################
function convert24(tm,suf)
local tmlen=string.len(tm)
local colon=string.find(tm,":")
	if colon~=nil then
	tmhr=string.sub(tm,1,colon-1)
	tmmn=string.sub(tm,colon+1,tmlen)
	else
	tmhr=tm
	tmmn=""
	end
if suf=="PM" and tonumber(tmhr)~=12 then
tmhr=tmhr+12
elseif suf=="PM" and tonumber(tmhr)==12  then
tmhr=12
elseif suf=="AM" and tonumber(tmhr)<10 then
tmhr="0"..tmhr
elseif suf=="AM" and tonumber(tmhr)>=10 and tonumber(tmhr)~=12 then
tmhr=tmhr
elseif suf=="AM" and tonumber(tmhr)==12 then
tmhr="00"
end
if colon~=nil then
return tmhr..":"..tmmn
else
return tmhr
end--if colon~=nil
end--of function
--END OF SCRIPT

this my current template:

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/

 the file:
 http://dl.dropbox.com/u/19008369/weatheragain9000.lua.tar.gz

 mrppeachys LUA Tutorial
 http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
]]

_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="PF Tempesta Seven" --font must be in quotes
default_font_size=8
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

local posx=0
local posy=250
--local hell=dnc(0x9ea3cd,0x988a8a)
--local dunkel=dnc(0x8088c3,0x988a8a)
--local farbe_head=dnc(0x585f8d,0xb3a7a7)
local hell=dnc(0xd1cf3d,0x988a8a)
local dunkel=dnc(0xa3a23f,0x988a8a)

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



local astro=30
local posx_1=30
local posx_2=230


local zeit=now["time_24"]
local datum=now["day_lc"]..", "..dropZero(now["date"]).."."..month_number(now["month"])..". "..now["year"]

out({x=posx_1,y=35,c=dunkel,face='normal',txt='datum:'})
out({x=posx_2,y=35,c=hell,face='normal',txt=datum,hj='r'})

out({x=posx_1,y=50,c=dunkel,face='normal',txt='uhrzeit:'})
out({x=posx_2,y=50,c=hell,f="PF Tempesta Seven",fs=8,face='italic',txt=dropZero(zeit)..' uhr',hj='r'})

local up=conky_parse('${uptime_short}')

out({x=posx_1,y=65,c=dunkel,face='normal',txt='uptime:'})
out({x=posx_2,y=65,c=hell,txt=up,hj='r'})

local fs_folder_home=conky_parse('${fs_free /home/alexander/Downloads}')
local typ_hdd_home=conky_parse("${fs_type /home/alexander/Downloads}")

local fs_folder_root=conky_parse('${fs_free /}')
local typ_hdd_root=conky_parse("${fs_type /}")

out({x=posx_1,y=80,c=dunkel,face='normal',txt='root:'})
out({x=posx_2,y=80,c=hell,txt=aendern(fs_folder_root,'gb')..' ('..typ_hdd_root..')',hj='r'})

out({x=posx_1,y=95,c=dunkel,face='normal',txt='downloads:'})
out({x=posx_2,y=95,c=hell,txt=aendern(fs_folder_home,'gb')..' ('..typ_hdd_home..')',hj='r'})

out({x=posx_1,y=125,c=dunkel,face='bold',txt='kabelloses internet',hj='l'})


local speed_1=conky_parse('${downspeedf wlan0}')
local speed_2=conky_parse('${upspeedf wlan0}')

local gesamt_1=conky_parse('${totaldown wlan0}')
local gesamt_2=conky_parse('${totalup wlan0}')

local geschw_1=string.gsub(tostring(speed_1),"%.",",")
local geschw_2=string.gsub(tostring(speed_2),"%.",",")

local router_name=conky_parse('${wireless_essid wlan0}')
local qualitaet=conky_parse('${wireless_link_qual_perc wlan0}')
out({x=posx_1,y=140,c=dunkel,txt='wlan router:',hj='l'})
out({x=posx_2,y=140,c=hell,face='normal',txt=router_name..' ('..qualitaet..'%)',hj='r'})

out({x=posx_1,y=155,c=dunkel,txt='downspeed:',hj='l'})
out({x=posx_2,y=155,c=hell,face='normal',txt=geschw_1..' kb/s',hj='r'})

out({x=posx_1,y=170,c=dunkel,txt='upspeed:'})
out({x=posx_2,y=170,c=hell,face='normal',txt=geschw_2..' kb/s',hj='r'})

out({x=posx_1,y=185,c=dunkel,txt='gesamt down:'})
out({x=posx_2,y=185,c=hell,face='normal',txt= total_aendern(gesamt_1),hj='r'})

out({x=posx_1,y=200,c=dunkel,txt='gesamt up:'})
out({x=posx_2,y=200,c=hell,face='normal',txt=total_aendern(gesamt_2),hj='r'})

local ip_1=conky_parse('${addr wlan0}')
local ip_2=conky_parse('${execi 7200 ~/v9000/publicip.sh}')

out({x=posx_1,y=215,c=dunkel,txt='lokale ip:'})
out({x=posx_2,y=215,c=hell,face='normal',txt=ip_1,hj='r'})

out({x=posx_1,y=230,c=dunkel,txt='globale ip:'})
out({x=posx_2,y=230,c=hell,face='normal',txt=ip_2,hj='r'})

local text='wlan verbindungen:'
out({x=posx_1,y=260,c=dunkel,face='bold',txt=text})


local anzahl_1=conky_parse('${tcp_portmon 1 32767 count}')
local anzahl_2=conky_parse('${tcp_portmon 32768 61000 count}')

out({x=posx_1,y=275,c=dunkel,txt='ausgehend:'})
out({x=posx_2,y=275,c=hell,face='bold',txt=n2w(anzahl_1),hj='r'})

out({x=posx_1,y=290,c=dunkel,txt='eingehend:'})
out({x=posx_2,y=290,c=hell,face='bold',txt=n2w(anzahl_2),hj='r'})


-- #################################################################
-- ## Aufruf isometric bars ########################################
-- #################################################################

conky_draw_shape()




local breite=conky_window.width
local hoehe=conky_window.height
local farbe=0x000000
local rundung=25
local bg_alpha=0.4

conky_draw_bg(rundung,0,0,breite,hoehe,farbe,bg_alpha)

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

--start or weather forecast table section
--set start forecast day
start_day=2
--set total forecast days you want to display
number_of_days=5
topy=100
gapy=65 -- topy+(gapy*1)

--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=10,topy
   top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,topy+(gapy*1)
   top_left_x_coordinate[4],top_left_y_coordinate[4]=120,topy+(gapy*1)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,topy+(gapy*2)
   top_left_x_coordinate[6],top_left_y_coordinate[6]=120,topy+(gapy*2)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,topy+(gapy*3)
   top_left_x_coordinate[8],top_left_y_coordinate[8]=120,topy+(gapy*3)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,topy+(gapy*4)
   top_left_x_coordinate[10],top_left_y_coordinate[10]=120,topy+(gapy*4)
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i]+10 --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################

local taglang=forecast_day[i]
local tagkurz=forecast_day_short[i]
--local tagzahl=dropZero(forecast_date[i])
local tagzahl=forecast_date[i]
local monatname=forecast_month[i]
local monatnummer=month_number(monatname)
local jahr=now["year"] -- actual year
local datum=tagzahl.."."..monatnummer.."."..jahr

--[[
xout({x=tlx+100,y=tly,c=dunkel,txt=tagkurz..','})
xout({x=tlx+170,y=tly,c=dunkel,txt=datum,j='r'})

xout({x=tlx+50,y=tly+40,f='ConkyWeather',fs=32,c=dunkel,txt=weather_font[i]})

xout({x=tlx+170,y=tly+20,c=dunkel,txt=high_temp[i].."°C",j='r'})
xout({x=tlx+170,y=tly+35,c=dunkel,txt=low_temp[i].."°C",j='r'})
]]--


--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################

vZ2hrMA

please help me to format the text.

regards, alex

Offline

#863 2012-11-28 20:38:50

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

Re: weather in conky (LUA scripts) updated 12/26/13!

italic is working for me
here is s11template
normal on the left and italic on the right
some fonts, like Zekton either don't have an italic version or don't respond to the CAIRO_FONT_SLANT_ITALIC option

Screenshot_at_2012_11_28_14_33_49.jpg

i made everything italic by setting

default_face="italic"

in the default setup area at the top of the template

also using v9000.lua straight out of the archive, no additional modifications

Last edited by mrpeachy (2012-11-28 20:42:38)

Offline

#864 2012-11-28 21:04:24

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

what font do u use? i do not wanna use the same format for all words! just vor 'values' on the right side!
i do not know what's going on. i use the original v9000 with the last update. but it will not work!

could it be that my operation system (lubuntu 12.10) causes this problem? or do i use the wrong conky-version?

could anyone please try to run my template + my main-file? i wanna compare smile

@mrpeachy

could u please post the template (on the right side of your screenshot).

Offline

#865 2012-11-28 21:44:24

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

Re: weather in conky (LUA scripts) updated 12/26/13!

i was only setting the default to italic so the effect could be seen in the whole conky, individual calls of the out function with face="italic" also work for me
this is the template

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/

 the file:
http://dl.dropbox.com/u/19008369/v9000.tar.gz

 mrppeachys LUA Tutorial
 http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
]]
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="Anonymous Pro:bold"--font must be in quotes
default_font_size=11
default_color=0xffffff--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
default_face="italic"
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
out({c=0x00BFFF,a=1,x=10,y=15,txt=now["date"].." "..now["month_short"].." "..now["year"]..": Fetched @ "..now["time"]})
image({x=20,y=20,h=40,w=40,file=now["weather_icon"]})
-- Temp / FeelsLike & CONDITIONS TEXT
out({c=0x48D1CC,a=1,f="Digital-7",fs=50,x=80,y=60,txt=now["temp"]})
out({c=0x00BFFF,a=1,f="Digital-7",fs=50,x=140,y=60,txt=now["feels_like"]})
out({c=0xA4FFA4,a=1,x=81,y=72,txt="Temp          WC · HI"})

out({c=0x48D1CC,a=1,f="Zekton",fs=18,x=10,y=94,txt=now["conditions"]})

-- data titles
--    data output 
datay=110   -- y=datay or
datayy=15   -- y=datay+(datayy*1) use 1 or more

out({c=0xFAFAEC,a=1,x=10,y=datay,txt="Wind Chill:",face='italic'})
   out({c=0x48D1CC,a=1,x=70,y=datay,txt=now["wind_chill"].."°"})
out({c=0xFAFAEC,a=1,x=100,y=datay,txt="Heat Index:"})
   out({c=0xFF8C00,a=1,x=165,y=datay,txt=now["heat_index"].."°"})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*1),txt="Today's Hi·Lo:"})
   out({c=0xFF8C00,a=1,x=100,y=datay+(datayy*1),txt=high_temp[1].."°"})
   out({c=0x48D1CC,a=1,x=140,y=datay+(datayy*1),txt=low_temp[1].."°"})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*2),txt="Wind:"})
   out({c=0x48D1CC,a=1,x=60,y=datay+(datayy*2),txt=now["wind_km"]})
   out({c=0x48D1CC,a=1,x=110,y=datay+(datayy*2),txt=now["wind_nesw"]})
   out({c=0xFAFAEC,a=1,x=140,y=datay+(datayy*2),txt="@"})
   out({c=0x48D1CC,a=1,x=165,y=datay+(datayy*2),txt=now["wind_deg"]})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*3),txt="Hum:"})
   out({c=0x48D1CC,a=1,x=60,y=datay+(datayy*3),txt=now["humidity"].."%"})
out({c=0xFAFAEC,a=1,x=110,y=datay+(datayy*3),txt="DP:"})
   out({c=0x48D1CC,a=1,x=145,y=datay+(datayy*3),txt=now["dew_point"].."°"})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*4),txt="Bar:"})
   out({c=0x48D1CC,a=1,x=60,y=datay+(datayy*4),txt=now["pressure_mb"]})
out({c=0xFAFAEC,a=1,x=110,y=datay+(datayy*4),txt="Vis:"})
   out({c=0x48D1CC,a=1,x=145,y=datay+(datayy*4),txt=now["visibility"]})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*5),txt="Ceil:"})
   out({c=0x48D1CC,a=1,x=60,y=datay+(datayy*5),txt=now["ceiling"]})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*6),txt="Precip:"})
   out({c=0x48D1CC,a=1,x=60,y=datay+(datayy*6),txt=precipitation[1].."%"})
out({c=0xFAFAEC,a=1,x=110,y=datay+(datayy*6),txt="Cloud:"})
   out({c=0x48D1CC,a=1,x=150,y=datay+(datayy*6),txt=cloud_cover[1].."%"})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*7),txt="UV:"})
   out({c=0x48D1CC,a=1,x=60,y=datay+(datayy*7),txt=uv_index_num[1]})
   out({c=0x48D1CC,a=1,x=110,y=datay+(datayy*7),txt=uv_index_txt[1]})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*8),txt="Sun:"})
   out({c=0xFAFAEC,a=1,x=60,y=datay+(datayy*8),txt=sun_rise_lc[1]})
   out({c=0x48D1CC,a=1,x=120,y=datay+(datayy*8),txt=sun_set_lc[1]})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*9),txt="Moon:"})
   out({c=0xFAFAEC,a=1,x=60,y=datay+(datayy*9),txt=moon_rise_lc[1]})
   out({c=0x48D1CC,a=1,x=120,y=datay+(datayy*9),txt=moon_set_lc[1]})
out({c=0xFAFAEC,a=1,x=10,y=datay+(datayy*10),txt="Phase:"})
   out({c=0x48D1CC,a=1,x=55,y=datay+(datayy*10),txt=moon_phase[1]})

-- line
image({x=205,y=5,w=1,h=260,file="/home/sector11/Conky/images/cyan-1.png"})
-- 3 hour output
out({c=0x48D1CC,a=1,f="Anonymous Pro:bold",fs=12,x=220,y=15,txt="Next 3"})
out({c=0x48D1CC,a=1,f="Anonymous Pro:bold",fs=12,x=220,y=30,txt="Hours"})
-- 1st hour
out({c=0xA4FFA4,x=220,y=50,txt=now["fc_hour1_time"].."  "..now["fc_hour1_ampm"]})
image({w=30,h=30,x=223,y=55,file=now["fc_hour1_wicon"]}) -- image({w=30,h=30,x=223,y=55,file="/home/sector11/Conky/images/red-1.png"})
out({x=228,y=100,txt=now["fc_hour1_temp"] .."°"})
-- 2nd hour
out({c=0xA4FFA4,x=220,y=datay+(datayy*1),txt=now["fc_hour2_time"].."  "..now["fc_hour2_ampm"]})
image({w=30,h=30,x=223,y=130,file=now["fc_hour2_wicon"]}) -- image({w=30,h=30,x=223,y=130,file="/home/sector11/Conky/images/red-1.png"})
out({x=228,y=180,txt=now["fc_hour2_temp"] .."°"})
-- 3rd hour
out({c=0xA4FFA4,x=220,y=210,txt=now["fc_hour3_time"].."  "..now["fc_hour3_ampm"]})
image({w=30,h=30,x=223,y=215,file=now["fc_hour3_wicon"]}) -- image({w=30,h=30,x=223,y=215,file="/home/sector11/Conky/images/red-1.png"})
out({x=228,y=datay+(datayy*10),txt=now["fc_hour3_temp"] .."°"})
-- line
image({x=275,y=5,w=1,h=260,file="/home/sector11/Conky/images/cyan-1.png"})

--start or weather forecast table section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=5
topy=15
topyy=135 -- topy+(topyy*1)
topx=285
topxx=137.5
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]        =topx            ,topy
   top_left_x_coordinate[2],top_left_y_coordinate[2]     =topx ,150
top_left_x_coordinate[3],top_left_y_coordinate[3]        =10  ,290
   top_left_x_coordinate[4],top_left_y_coordinate[4]     =10+(topxx*1) ,290
top_left_x_coordinate[5],top_left_y_coordinate[5]        =10+(topxx*2)  ,290
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i] --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################
out({c=0xA4FFA4,a=1,x=tlx,y=tly,txt=forecast_day_short[i].."  "..forecast_date[i].."  "..forecast_month_short[i]})
image({x=tlx,y=tly+5,h=30,w=30,file=weather_icon[i]})
out({c=0xFF8C00,a=1,x=tlx+35,y=tly+15,txt=high_temp[i].."°"})
out({c=0x48D1CC,a=1,x=tlx+35,y=tly+30,txt=low_temp[i].."°"})
out({c=0x48D1CC,a=1,x=tlx,y=tly+50,txt=conditions_short[i]})

out({c=0xFAFAEC,a=1,x=tlx,y=tly+65,txt="P: "..precipitation[i].."%"})
   out({c=0xFAFAEC,a=1,x=tlx+50,y=tly+65,txt="UV: "..uv_index_num[i]})
out({c=0xFAFAEC,a=1,x=tlx,y=tly+80,txt="H: "..humidity[i].."%"})
out({c=0xFAFAEC,a=1,x=tlx,y=tly+95,txt="S: "..sun_rise_lc[i]})
   out({c=0x48D1CC,a=1,x=tlx+73,y=tly+95,txt=sun_set_lc[i]})
out({c=0xFAFAEC,a=1,x=tlx,y=tly+110,txt="M: "..moon_rise_lc[i]})
   out({c=0x48D1CC,a=1,x=tlx+73,y=tly+110,txt=moon_set_lc[i]})
--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################AAA

Offline

#866 2012-11-29 11:29:04

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

i tested a bit:

vZ2hzZg

both conditions use this code:

now["conditions_short_lc"]

and both conditions use the option to right align the word! the rest of the weather template is still german! i use the template: weather_testing.lua to compare.

it seems that there is a bug in the new update.

Last edited by lionhead (2012-11-29 11:30:16)

Offline

#867 2012-12-02 14:08:47

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

i've updated my v9000.lua. this update contains several new features (small characters, big characters, shadow). the user arclance helped me to create the shadow! big thanks for his help.

the update works. i've tested it several days. here is a new screenshot:

Bildschirmfoto_03_12_2012_22_17_16.jpg

there is only a change within the out-function. all existing features still WORK. there are just more features to format the text (weather- and conky-output).

if u want to use shaded text you can use this code:

shaded='yes'

this is the default-code. if u want to use a black shaded text. but you can use a custom color of the shadow (for example red):

shade_color=0xff0000

black shaded text is very helpful if u use a bright wallpaper. the contrast is better and u can read the shaded text better then without the shadow. you can also use a different alpha for the shadow. the default value is 1

shade_alpha=2

here is an example if u want to use all this features:

shaded="yes",shaded_color=0xff0000,shade_alpha=2

you can also use small characters:

size="small_c"

also big characters:

size="big_c"

the default value is:

size="normal_c"

this is the complete code:

--weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
-- update by mrpeachy
-- additional features (shadow, big characters, low characters) by lionhead and arclance
require 'cairo'
require 'imlib2'
local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"

local username = "alexander"
package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

start=1
--INITIALIZE SETTINGS-- need only be run once
settings_table=weather_settings()
--##################################
--######## main function ########### 
function conky_weather()--##########
--##################################
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}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
--################################################
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]
--################################################
print ("gathering data with curl")
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section
--#########################################################################

--#########################################################################
--in case curl craps up it should retry until it works
if testall==nil or  alerttest==nil then
print ("curl attempt timed out, trying again")
local web=settings_table[2]
local alert_check=settings_table[13]
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert_check
processall=1
end--if testall==nil
--end or curl reruns ######################################################

--START PROCESSING ###########################################################################
if testall~=nil and alerttest~=nil and processall==1 then
local weathericons=settings_table[3]
local con_short=settings_table[4]
local visibility_unit=settings_table[6]
local wind_mph_unit=settings_table[7]
local wind_km_unit=settings_table[8]
local wind_kts_unit=settings_table[9]
local ceiling_unit=settings_table[10]
local wind_degrees_unit=settings_table[11]
local translate=settings_table[12]
local alert_check=settings_table[13]
--#########################################################################
--LOAD TRANSLATE TABLES IF TRANSLATE SETTING = 1
	if translate==1 then
	monthshort=settings_table[21]
	monthnames=settings_table[20]
	dayhort=settings_table[19]
	daynames=settings_table[18]
	neswtext=settings_table[14]
	tsuffix=settings_table[15]
	uvindextext=settings_table[16]
	moonphases=settings_table[17]
	additional=settings_table[22]
	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort

	dayshort={Monday="Mon",Tuesday="Tue",Wednesday="Wed",Thursday="Thu",Friday="Fri",Saturday="Sat",Sunday="Sun"}
	monthshort={January="Jan",February="Feb",March="Mar",April="Apr",May="May",June="Jun",July="Jul",August="Aug",September="Sep",October="Oct",November="Nov",December="Dec"}
	end--end if translate =1
--#########################################################################
--process data tables
--intellicast to conky weather icon conversion
wimage={
wx_65="32",  -- Clear
wx_66="30",  -- Partly Cloudy
wx_67="26",  -- Cloudy
wx_68="32",  -- Clear
wx_69="28",  -- Mostly Cloudy
wx_70="20",  -- Fog
wx_71="32",  -- Clear
wx_72="21",  -- Haze
wx_73="36",  -- Hot
wx_74="14",  -- Light Snow Showers
wx_75="28",  -- Mostly Cloudy
wx_76="18",  -- Sleet
wx_77="14",  -- Light Snow Showers
wx_78="23",  -- Blustery
wx_79="05",  -- Mixed Rain and Snow
wx_80="15",  -- Drifting Snow
wx_81="15",  -- Drifting Snow
wx_82="11",  -- Light Rain
wx_83="16",  -- Snow
wx_84="00",  -- Tornado
wx_85="32",  -- Clear
wx_86="25",  -- N/A
wx_87="09",  -- Drizzle
wx_88="05",  -- Mixed Rain and Snow
wx_89="18",  -- Sleet
wx_90="18",  -- Sleet
wx_91="39",  -- Scattered Showers
wx_92="39",  -- Scattered Showers
wx_93="39",  -- Scattered Showers
wx_94="39",  -- Scattered Showers
wx_95="37",  -- Isolated Thunderstorms
wx_96="37",  -- Isolated Thunderstorms
wx_97="31",  -- Clear
wx_98="29",  -- Partly Cloudy
wx_99="27",  -- Mostly Cloudy
wx_100="47",  -- Isolated Thunderstorms
wx_101="47",  -- Isolated Thunderstorms
wx_102="33",  -- Fair
wx_103="26",  -- Cloudy
wx_104="20",  -- Fog
wx_105="45",  -- Scattered Showers
wx_106="45",  -- Scattered Showers
wx_107="11",  -- Light Rain
wx_108="46",  -- Snow Showers
wx_109="46",  -- Snow Showers
wx_110="06",  -- Mixed Rain and Sleet
wx_111="18",  -- Sleet
wx_112="06",  -- Mixed Rain and Sleet
wx_113="46",  -- Snow Showers
wx_114="46",  -- Snow Showers
wx_115="31",  -- Clear
wx_116="47",  -- Isolated Thunderstorms
}--end w image table
--convert intellicast icons to weather font
wfont={
wx_65="a",
wx_66="c",
wx_67="f",
wx_68="a",
wx_69="d",
wx_70="0",
wx_71="a",
wx_72="9",
wx_73="5",
wx_74="p",
wx_75="d",
wx_76="w",
wx_77="p",
wx_78="6",
wx_79="x",
wx_80="8",
wx_81="8",
wx_82="h",
wx_83="q",
wx_84="m",
wx_85="a",
wx_86="-",
wx_87="h",
wx_88="x",
wx_89="w",
wx_90="w",
wx_91="g",
wx_92="g",
wx_93="g",
wx_94="g",
wx_95="k",
wx_96="k",
wx_97="A",
wx_98="C",
wx_99="D",
wx_100="K",
wx_101="K",
wx_102="B",
wx_103="f",
wx_104="0",
wx_105="G",
wx_106="G",
wx_107="h",
wx_108="O",
wx_109="O",
wx_110="x",
wx_111="w",
wx_112="x",
wx_113="O",
wx_114="O",
wx_115="A",
wx_116="K",
}--end w font table
--conversion day and month tables
moonfontt={
["New"]="@",
["Full"]="=",
["First Quarter"]="T",
["Last Quarter"]="G",
["Waning Gibbous"]="D",
["Waning Crescent"]="J",
["Waxing Crescent"]="Q",
["Waxing Gibbous"]="W",
}--end of moon font table
moonicont={
["New"]=weathericons.."moon_new.png",
["Full"]=weathericons.."moon_full.png",
["First Quarter"]=weathericons.."moon_first_quarter.png",
["Last Quarter"]=weathericons.."moon_last_quarter.png",
["Waning Gibbous"]=weathericons.."moon_waning_gibbous.png",
["Waning Crescent"]=weathericons.."moon_waning_crescent.png",
["Waxing Crescent"]=weathericons.."moon_waxing_crescent.png",
["Waxing Gibbous"]=weathericons.."moon_waxing_gibbous.png",
}--end of moon icon table
windfontt={
S="9",
SSW=":",
SW=";",
WSW="<",
W="=",
WNW=">",
NW="?",
NNW="@",
N="1",
NNE="2",
NE="3",
ENE="4",
E="5",
ESE="6",
SE="7",
SSE="8"
}--end of wind direction font table
--#########################################################################

--#########################################################################
--setup tables for forecast weather
forecast_day={}
forecast_day_caps={}
forecast_day_lc={}
forecast_day_short={}
forecast_day_short_caps={}
forecast_day_short_lc={}
forecast_month={}
forecast_month_caps={}
forecast_month_lc={}
forecast_month_short={}
forecast_month_short_caps={}
forecast_month_short_lc={}
forecast_date={}
weather_icon={}
weather_font={}
high_temp={}
low_temp={}
conditions={}
conditions_caps={}
conditions_lc={}
conditions_short={}
conditions_short_caps={}
conditions_short_lc={}
sun_rise={}
sun_rise_lc={}
sun_rise_time={}
sun_rise_24={}
moon_rise={}
moon_rise_lc={}
moon_rise_time={}
moon_rise_24={}
moon_rise_ampm={}
moon_rise_ampm_lc={}
sun_set={}
sun_set_lc={}
sun_set_time={}
sun_set_24={}
moon_set={}
moon_set_lc={}
moon_set_time={}
moon_set_24={}
moon_set_ampm={}
moon_set_ampm_lc={}
humidity={}
precipitation={}
snow={}
cloud_cover={}
moon_phase={}
moon_phase_caps={}
moon_phase_lc={}
moon_font={}
moon_icon={}
wind_mph={}
wind_km={}
wind_kts={}
wind_font={}
wind_icon={}
wind_deg={}
wind_nesw={}
uv_index_num={}
uv_index_txt={}
uv_index_txt_caps={}
uv_index_txt_lc={}
--#########################################################################

--#########################################################################
--get forecast chunk
local a,b,allweather=string.find(allweatherdata,">10 Day Forecast&nbsp(.*)>More from Intellicast</div>")
--extract information into tables
local start=0
local f=1
while f~=nil do
--match forecast day name and date
local s,f,t=string.find(allweather,"<td colspan=\"2\"><strong>([%a,%s%d]*)</strong></td>",start)
	if t~=nil then
	--split name from month and date
	local a,b,day=string.find(t,"(%a*),%s")
	local a,b,month=string.find(t,",%s(%a*)%s")
	local a,b,date=string.find(t,"(%d*)$")
	--ser day names, regular, caps, lowercase and short
	table.insert(forecast_day_short,dayshort[day])
	table.insert(forecast_day_short_caps,string.upper(dayshort[day]))
	table.insert(forecast_day_short_lc,string.lower(dayshort[day]))
		if translate==1 then
		day=daynames[day]
		else
		day=day
		end
	table.insert(forecast_day,day)
	table.insert(forecast_day_caps,string.upper(day))
	table.insert(forecast_day_lc,string.lower(day))
	--set month types
	table.insert(forecast_month_short,monthshort[month])
	table.insert(forecast_month_short_caps,string.upper(monthshort[month]))
	table.insert(forecast_month_short_lc,string.lower(monthshort[month]))
		if translate==1 then
		month=monthnames[month]
		else
		month=month
		end
	table.insert(forecast_month,month)
	table.insert(forecast_month_caps,string.upper(month))
	table.insert(forecast_month_lc,string.lower(month))
	--set date
	table.insert(forecast_date,date)
	end--if t~= nil
--intellicast weather icon match
local s,f,t=string.find(allweather,"40_white/(wx_[%d]*).png\"",start)
--convert to conkyweather icon
	if t~=nil then
	table.insert(weather_icon,weathericons..wimage[t]..".png")
	--convert to weather font
	table.insert(weather_font,wfont[t])
	end
--match conditions
local s,f,t=string.find(allweather," /><br />([%a%s%p]*)</td>",start)
	if t~=nil then
	table.insert(conditions,t)
	table.insert(conditions_caps,string.upper(t))
	table.insert(conditions_lc,string.lower(t))
	--set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	table.insert(conditions_short,cons)
	table.insert(conditions_short_caps,string.upper(cons))
	table.insert(conditions_short_lc,string.lower(cons))
	-----------------------------------------------------
	end
--match high temp
local s,f,t=string.find(allweather,"\"Hi\">([%p%d]*)&deg",start)
table.insert(high_temp,t)
--match low temp
local s,f,t=string.find(allweather,"\"Lo\">([%p%d]*)&deg",start)
table.insert(low_temp,t)
--match sun rise times
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",start)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(sun_rise_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_rise,tm.." "..suf)
	table.insert(sun_rise_lc,string.lower(tm.." "..suf))
	table.insert(sun_rise_time,tm)
	end
--match sun set times
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then	
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(sun_set_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_set,tm.." "..suf)
	table.insert(sun_set_lc,string.lower(tm.." "..suf))
	table.insert(sun_set_time,tm)
	end
--moon rise
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(moon_rise_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_rise,tm.." "..suf)
	table.insert(moon_rise_lc,string.lower(tm.." "..suf))
	table.insert(moon_rise_time,tm)
	table.insert(moon_rise_ampm,suf)
	table.insert(moon_rise_ampm_lc,string.lower(suf))
	end
--moon set
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(moon_set_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_set,tm.." "..suf)
	table.insert(moon_set_lc,string.lower(tm.." "..suf))
	table.insert(moon_set_time,tm)
	table.insert(moon_set_ampm,suf)
	table.insert(moon_set_ampm_lc,string.lower(suf))
	end
--match uv index
local s,f,tuv=string.find(allweather,"UV Index:</strong>%s*(%d*%s*%([%a%s]*%))%s*<br />",start)
if tuv~=nil then
	--get just number
	local a,b,unm=string.find(tuv,"(%d*)%s*%([%a%s]*%)")
	--get just text
	local a,b,utx=string.find(tuv,"%d*%s*%(([%a%s]*)%)")
	table.insert(uv_index_num,unm)
		if translate==1 then
		utx=uvindextext[utx]
		else
		utx=utx
		end
	table.insert(uv_index_txt,utx)
	table.insert(uv_index_txt_caps,string.upper(utx))
	table.insert(uv_index_txt_lc,string.lower(utx))
	end
--match humidity
local s,f,t=string.find(allweather,"Humidity:</strong> (%d*)<br />",start)
table.insert(humidity,t)
--match ppt
local s,f,t=string.find(allweather,"Precipitation:</strong> (%d*)<br />",start)
table.insert(precipitation,t)
--match snow %
local s,f,t=string.find(allweather,"Snow Probability:</strong>%s*(%d*)<br />",start)
table.insert(snow,t)
--match cloud coveage
local s,f,t=string.find(allweather,"Cloud Coverage:</strong> (%d*)<br />",start)
table.insert(cloud_cover,t)
--match moon phase
local s,f,t=string.find(allweather,"Moon Phase:</strong> ([%a%s]*) <br />",start)
--set moon phase text
	if t~= nil then
	--set moon phase font and icon
	table.insert(moon_font,moonfontt[t])
	table.insert(moon_icon,moonicont[t])
		if translate==1 then
		t=moonphases[t]
		else
		t=t
		end
	table.insert(moon_phase,t)
	table.insert(moon_phase_caps,string.upper(t))
	table.insert(moon_phase_lc,string.lower(t))
	end
--match wind speeds
local s,f,tmph=string.find(allweather,"Wind Speed:</strong> (%d*)Mph",start)
local tmph=tonumber(tmph)
table.insert(wind_mph,tmph)
local s,f,t=string.find(allweather,"Mph%s*%((%d*)Km,",start)
table.insert(wind_km,t)
local s,f,t=string.find(allweather,"Km,%s*(%d*)Kts%)",start)
table.insert(wind_kts,t)
--match wind direction
local s,f,twd=string.find(allweather,"Wind Direction:</strong> ([%d&;%s%(%a%)]*)%s*</div>",start)
	if twd~=nil then
	local a,b,tdeg=string.find(twd,"(%d*)&deg;")
	table.insert(wind_deg,tdeg)
	--match wind font and nesw   
	local a,b,tnesw=string.find(twd,"%((%a*)%)")
	table.insert(wind_font,windfontt[tnesw])
		if tmph>0 and tmph<19 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph>18 and tmph<38 then
		table.insert(wind_icon,weathericons.."yellow_"..string.lower(tnesw)..".png")
		elseif tmph>37 and tmph<64 then
		table.insert(wind_icon,weathericons.."orange_"..string.lower(tnesw)..".png")
		elseif tmph>63 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph==0 then
		table.insert(wind_icon,weathericons.."no_wind.png")
		end
		if translate==1 then
		tnesw=neswtext[tnesw]
		else
		tnesw=tnesw
		end
	table.insert(wind_nesw,tnesw)
	end
if f==nil then break end
start=f
end--while
--#########################################################################################################################################

--#########################################################################
--get location
local a,b,wl=string.find(allweatherdata,"<title>%s*Intellicast%s%p%s(.*)</title>")
weather_location=string.gsub(wl," Extended Forecast in",",")
--#########################################################################

--#########################################################################
--format now weather
--extract current data
--get now weather chunk
local a,b,nowweather=string.find(allweatherdata,">Current Conditions&nbsp(.*)>View Detailed Observations for the last<br />")
now={}
monthlong={Jan="January",Feb="February",Mar="March",Apr="April",May="May",Jun="June",Jul="July",Aug="August",Sep="September",Oct="October",Nov="November",Dec="December"}
local s,f,tnow=string.find(nowweather,"<div style=\"float:right;color:#666;\">  As of ([%d%p%a%s]*) %(Local Time%)")
local s,f,t=string.find(tnow,"(%d*%p%d*%s%a*) on")
--get time only
local a,b,ntm=string.find(t,"(%d*%p%d*)")
--get suffix only
local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
now["time_24"]=convert24(ntm,suf)
--###############################
if translate==1 then
suf=tsuffix[suf]
else
suf=suf
end
now["time"]=ntm.." "..suf
now["time_lc"]=string.lower(ntm.." "..suf)
now["time_num"]=ntm
now["time_ampm"]=suf
now["time_ampm_lc"]=string.lower(suf)
--get day
local s,f,t=string.find(tnow,"on (%a*)%s%d*")
if translate==1 then
day=daynames[t]
else
day=t
end
now["day"]=day
now["day_caps"]=string.upper(day)
now["day_lc"]=string.lower(day)
--short day names
local ds=dayshort[t]
now["day_short"]=ds
now["day_short_caps"]=string.upper(ds)
now["day_short_lc"]=string.lower(ds)
--get date
local s,f,t=string.find(tnow,"%s(%d%d)%s")
now["date"]=t
--get months
local s,f,t=string.find(tnow,"%d%d%s(%a*)%s%d")
if translate==1 then
mnth=monthlong[t]
now["month_short"]=monthshort[mnth]
now["month_short_caps"]=string.upper(monthshort[mnth])
now["month_short_lc"]=string.lower(monthshort[mnth])
mnth=monthnames[mnth]
else
now["month_short"]=t
now["month_short_caps"]=string.upper(t)
now["month_short_lc"]=string.lower(t)
mnth=monthlong[t]
end
now["month"]=mnth
now["month_caps"]=string.upper(mnth)
now["month_lc"]=string.lower(mnth)
local s,f,t=string.find(tnow,"%a%a%a%s(%d%d%d%d)")
now["year"]=t
local s,f,t=string.find(nowweather,"40_white/(wx_[%d]*)%ppng%p%stitle=%p")
now["weather_icon"]=weathericons..wimage[t]..".png"
now["weather_font"]=wfont[t]
local s,f,t=string.find(nowweather,"class=%pIcon%p /> ([%a%s%p]*)%s*%s*</td>%s*<td class=%pEmpty%p>&nbsp;")
local t=t:gsub("^%s*(.-)%s*$", "%1")
now["conditions"]=t
now["conditions_caps"]=string.upper(t)
now["conditions_lc"]=string.lower(t)
--set short versions------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["conditions_short"]=cons
	now["conditions_short_caps"]=string.upper(cons)
	now["conditions_short_lc"]=string.lower(cons)
--------------------------------------------
local s,f,t=string.find(nowweather,"Temperature\">([%p%d]*)&deg")
now["temp"]=t
local s,f,t=string.find(nowweather,">Feels Like: ([%p%d]*)&deg;</a>")
now["feels_like"]=t
local s,f,t=string.find(nowweather,">Wind Chill: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["wind_chill"]=t
local s,f,t=string.find(nowweather,">Ceiling: </a></td>%s*<td>([%a%d]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tc=t..ceiling_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tc=unlset
end
now["ceiling"]=tc
now["ceiling_caps"]=string.upper(tc)
now["ceiling_lc"]=string.lower(tc)
--get heat index
local s,f,t=string.find(nowweather,">Heat Index: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["heat_index"]=t
--get visibility
local s,f,t=string.find(nowweather,">Visibility: </a></td>%s*<td>([%a%d%p]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tv=t..visibility_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tv=unlset
end
now["visibility"]=tv
now["visibility_caps"]=string.upper(tv)
--get dew point
local s,f,t=string.find(nowweather,">Dew Point: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["dew_point"]=t
--get wind speed
local s,f,t=string.find(nowweather,">Wind: </a></td>%s*<td>(%d*)mph</td>")
local tmph=tonumber(t)
now["wind_mph"]=t..wind_mph_unit
now["wind_mph_caps"]=string.upper(t..wind_mph_unit)
--convert mph to km and knots #################################################
--[[1 mile per hour = 0.869 international nautical mile per hour (knot)
     1 mile per hour = 1.609 kilometers per hour
     1 mile per hour = 0.4470 meter per second
     1 knot = 1.852 kilometers per hour
     1 knot = 0.5144 meter per second
     1 meter per second = 3.6 kilometers per hour]]
now["wind_km"]=round(tonumber(t)*1.609)..wind_km_unit
now["wind_km_caps"]=string.upper(round(tonumber(t)*1.609)..wind_km_unit)
now["wind_kts"]=round(tonumber(t)*0.869)..wind_kts_unit
now["wind_kts_caps"]=string.upper(round(tonumber(t)*0.869)..wind_kts_unit)
--#############################################################################
local s,f,t=string.find(nowweather,">Humidity: </a></td>%s*<td>(%d*)</td>")
now["humidity"]=t
--get wind direction #######################################################
local s,f,twd=string.find(nowweather,">Direction: </a></td>%s*<td style=[%p%a]*>([%d&;%s%(%a%)]*)</td>%s*</tr>")
--check for NA
local a,b,t=string.find(twd,"(%a*)")
local tnesw=t
if tnesw~="NA" then
local a,b,t=string.find(twd,"(%d*)&deg;")
now["wind_deg"]=t..wind_degrees_unit
local a,b,tnesw=string.find(twd,"%((%a*)%)")
	if tmph>0 and tmph<19 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	elseif tmph>18 and tmph<38 then
	now["wind_icon"]=weathericons.."yellow_"..string.lower(tnesw)..".png"
	elseif tmph>37 and tmph<64 then
	now["wind_icon"]=weathericons.."orange_"..string.lower(tnesw)..".png"
	elseif tmph>63 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	end
now["wind_font"]=windfontt[tnesw]
--################################
	if translate==1 then
	tnesw=neswtext[tnesw]
	else
	tnesw=tnesw
	end
--################################
now["wind_nesw"]=tnesw		
else
	if translate==1 then naset=additional.NA else naset="NA" end
now["wind_deg"]=naset
now["wind_icon"]=weathericons.."no_wind.png"
now["wind_nesw"]=naset
now["wind_font"]=windfontt["N"]
end
--END WIND DIRECTION #######################################################
--get pressure
local s,f,t=string.find(nowweather,">Pressure: </a></td>%s*<td>([%d%p]*)\"</td>")
now["pressure"]=t
--convert pressures ########################################################
--[[ 1 inch of mercury = 25.4 mm of mercury = 33.86 millibars
     = 33.86 hectoPascals]]
now["pressure_mb"]=round(tonumber(t)*33.86)
--##########################################################################
local s,f,t=string.find(nowweather,">Gusts: </a></td>%s*<td>([%d%a]*)</td>")
if t~="NA" then
local s,f,t=string.find(t,"(%d*)")
tg=t..wind_mph_unit
tgkm=round(tonumber(t)*1.609)..wind_km_unit
tgkts=round(tonumber(t)*0.869)..wind_kts_unit
else
	if translate==1 then naset=additional.NA else naset="NA" end
tg=naset
tgkm=naset
tgkts=naset
end
now["wind_gusts"]=tg
now["wind_gusts_caps"]=string.upper(tg)
now["wind_gusts_km"]=tgkm
now["wind_gusts_km_caps"]=string.upper(tgkm)
now["wind_gusts_kts"]=tgkts
now["wind_gusts_kts_caps"]=string.upper(tgkts)
--##########################################################################
--get hourly forecast options hour1--------------------
--get day 1 bit
local s,f,hfc=string.find(nowweather,"<td class=%pHour%p%sstyle=%ppadding%pleft([%a%d%p%s]*)%pdeg%p</strong>",1)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",1)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",1)
--24 hour conversion ######################
now["fc_hour1_time_24"]=convert24(tm,suf)
--#########################################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour1_time"]=tm
now["fc_hour1_ampm"]=suf
now["fc_hour1_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%p%s%a]*)%s*</td>%s*<td class=%pHour%p",1)
now["fc_hour1_cond"]=t
now["fc_hour1_cond_lc"]=string.lower(t)
now["fc_hour1_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour1_cond_short"]=cons
	now["fc_hour1_cond_short_caps"]=string.upper(cons)
	now["fc_hour1_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",1)
now["fc_hour1_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour1_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",1)
now["fc_hour1_temp"]=t
--end of hour1 data gathering--repeat 2 more times
--get hourly forecast options hour2--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion ######################
now["fc_hour2_time_24"]=convert24(tm,suf)
--#########################################	
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour2_time"]=tm
now["fc_hour2_ampm"]=suf
now["fc_hour2_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour2_cond"]=t
now["fc_hour2_cond_lc"]=string.lower(t)
now["fc_hour2_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour2_cond_short"]=cons
	now["fc_hour2_cond_short_caps"]=string.upper(cons)
	now["fc_hour2_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour2_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour2_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",start)
now["fc_hour2_temp"]=t
--end of hour2 data gathering--repeat 1 more times
--get hourly forecast options hour3--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion ######################
now["fc_hour3_time_24"]=convert24(tm,suf)
--#########################################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour3_time"]=tm
now["fc_hour3_ampm"]=suf
now["fc_hour3_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour3_cond"]=t
now["fc_hour3_cond_lc"]=string.lower(t)
now["fc_hour3_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour3_cond_short"]=cons
	now["fc_hour3_cond_short_caps"]=string.upper(cons)
	now["fc_hour3_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour3_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour3_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)",start)
now["fc_hour3_temp"]=t
--end of hour3 data gathering--finished for all hours
--ALERTS###############################################################
if alert_check==1 then
--set tables
alert_type={}
alert_issued={}
if alerttest~=0 then
alert_icon=weathericons.."icon_alert_1.gif"
--extract information into tables
local start=0
local f=1
while f~=nil do
local s,f,t=string.find(alertdata,"><strong class='Alert'>([%a%s]*)</strong><br/>",start)
	if t~=nil then
	table.insert(alert_type,string.upper(t))
	end--if t~=nil
local s,f,t=string.find(alertdata,"<br />([%d%a%s:]*)<br /><br />",start)
	if t~=nil then
	table.insert(alert_issued,t)
	end--if t~=nil
if f==nil then break end
start=f
alert_number=#alert_type
end--while
else
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"NO ALERTS")
table.insert(alert_issued,"")
alert_number=0
end--alerttest~=nil
else
alert_type={}
alert_issued={}
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"alerts turned off")
table.insert(alert_issued,"")
alert_number=0
end--if alert check ###########################################
--###############end of data processing########################

--#########################################################################
if testing==0 then
processall=0
print ("processing complete")
elseif testing==1 then
processall=1
end--if testing ==0
--###################################################################################
end--of data processing section #####################################################
--###################################################################################
if processall==0 or testing==1 then
_G.weather_script()
end
--#########################################################################################################
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--end--####### end of if updates>5 #############################
--#########################################################################################################

cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--######################################
end-- end main function ################
--######################################
function round(num)
	local idp=tonumber(settings_table[5])
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end--of round function #################################################################
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--string split #######################################################################
function xout(txj)--c,a,f,fs,x,y,txt,j ##################################################
c=nil
c=(txj.c or default_color)
a=nil
a=(txj.a or default_alpha)
f=nil
f=(txj.f or default_font)
fs=nil
fs=(txj.fs or default_font_size)
x=nil
x=(txj.x or 0)
y=nil
y=(txj.y or 0)
txt=nil
txt=(txj.txt or "set txt")
j=nil
j=(txj.j or "l")
	local function col(c,a)
	return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
	end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local text=string.gsub(txt," ","_")
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local wx=extents.width
cairo_set_source_rgba (cr,col(c,a))
if j=="l" then
cairo_move_to (cr,x,y)
adx=wx
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
adx=wx/2
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
adx=0
end
cairo_show_text (cr,txt)
cairo_stroke (cr)
nextx=nil
nextx=adx+x
return nextx
end--function xout ###################################################################
-- ###### function out ########################################################################
function out(txj)--c,a,f,fs,face,x,y,txt,hj,vj,ro ##################################################
	local extents=cairo_text_extents_t:create()
	tolua.takeownership(extents)
	--#########################################################################################################
	local function color(col,alp)
		return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
	end
	--#########################################################################################################
	local c=txj.c						or default_color		or 0xffffff
	local a=txj.a						or default_alpha		or 1
	local f=txj.f						or default_font			or "mono"
	local fs=txj.fs						or default_font_size	or 12
	local x=txj.x						or 100
	local y=txj.y						or 100
	local txt=txj.txt					or "set txt"
	local hj=txj.hj						or default_hj			or "l"
	local vj=txj.vj						or default_vj			or "n"
	local ro=txj.ro						or defaukt_ro			or 0
	local face=txj.face					or default_face			or "normal"
	local size=txj.size     or default_size         or "normal_c"
	--################ ADD SHADES ###########################################
	local shaded=txj.shaded				or default_shaded		or "no" --## shades are drawn if shaded="yes"
	local shade_color=txj.shade_color	or default_shade_color	or 0x000000
	local shade_alpha=txj.shade_alpha	or default_shade_alpha	or 1
	--#######################################################################
	--set face
	if face=="normal" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	elseif face=="bold" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
	elseif face=="italic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
	elseif face=="bolditalic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
	else
		print ('face not set correctly - "normal","bold","italic","bolditalic"')
	end
-- #######################
-- set size of letters
if size=="big_c" then
txt=string.upper(txt)
elseif size=="small_c" then
txt=string.lower(txt)
elseif size=="normal_c" then
txt=txt
else
print ('size not set correctly - "normal_c","big_c","small_c"')
end
----------------------
	cairo_set_font_size (cr, fs)
	cairo_text_extents(cr,txt,extents)
	local wx=extents.x_advance
	local wd=extents.width
	local hy=extents.height
	local bx=extents.x_bearing
	local by=extents.y_bearing+hy
	local tx=x
	local ty=y
	--set horizontal alignment - l, c, r
	if hj=="l" then
		x=x-bx
		rad=0
	elseif hj=="c" then
		x=x-((wx-bx)/2)-bx
		rad=(wx-bx)/2
	elseif hj=="r" then
		x=x-wx
		rad=wx-bx
	else
		print ("hj not set correctly - l, c, r")
	end
	--vj. n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
	if vj=="n" then
		y=y
		rad2=0
		ry=by
	elseif vj=="nb" then
		y=y-by
		rad2=-by
		ry=by
	elseif vj=="m" then
		y=y+((hy-by)/2)
		rad2=((hy-by)/2)
		ry=((hy-by)/2)-by
	elseif vj=="mb" then
		y=y+(hy/2)-by
		rad2=(hy/2)-by
		ry=((hy-by)/2)-by
	elseif vj=="t" then
		y=y+hy-by
		rad2=hy-by
		ry=0+by
	else
		print ("vj not set correctly - n, nb, m, mb, t")
	end
	--rotation
	if ro~=0 then
		--################ ADD SHADES ###########################################
		--## I don't know if the rotation shading is correct. It needs tested by someone with a working v9000 setup.
		if shaded == "yes" then
			local point2=(math.pi/180)*(ro-180)
			local x2=(tx + 1)+rad2*(math.sin(point2))
			local y2=(ty + 1)-rad2*(math.cos(point2))
			local point=(math.pi/180)*(ro-90)
			local x1=x2+rad*(math.sin(point))
			local y1=y2-rad*(math.cos(point))
			cairo_save (cr)
			cairo_translate (cr,x1,y1)
			cairo_rotate(cr,(math.pi/180)*ro)
			cairo_set_source_rgba (cr,color(shade_color,shade_alpha))
			cairo_show_text (cr,txt)
			cairo_stroke (cr)
			cairo_restore (cr)
		end --# if shaded == "yes" then
		--#######################################################################
		local point2=(math.pi/180)*(ro-180)
		local x2=tx+rad2*(math.sin(point2))
		local y2=ty-rad2*(math.cos(point2))
		local point=(math.pi/180)*(ro-90)
		local x1=x2+rad*(math.sin(point))
		local y1=y2-rad*(math.cos(point))
		cairo_save (cr)
		cairo_translate (cr,x1,y1)
		cairo_rotate(cr,(math.pi/180)*ro)
		cairo_set_source_rgba (cr,color(c,a))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
		cairo_restore (cr)
	else
		--################ ADD SHADES ###########################################
		if shaded == "yes" then
			cairo_move_to (cr,(x + 1),(y + 1))
			cairo_set_source_rgba (cr,color(shade_color,shade_alpha))
			cairo_show_text (cr,txt)
			cairo_stroke (cr)
		end --# if shaded == "yes" then
		--#######################################################################
		cairo_move_to (cr,x,y)
		cairo_set_source_rgba (cr,color(c,a))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	end--if ro
end--function out ###################################################################
function image(im)--#################################################################
x=nil
x=(im.x or 0)
y=nil
y=(im.y or 0)
w=nil
w=(im.w or default_image_width)
h=nil
h=(im.h or default_image_height)
file=nil
file=tostring(im.file)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(w)
end
if tonumber(h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x, y)
imlib_free_image()
show=nil
end--function image ##################################################################
function convert24(tm,suf)
local tmlen=string.len(tm)
local colon=string.find(tm,":")
	if colon~=nil then
	tmhr=string.sub(tm,1,colon-1)
	tmmn=string.sub(tm,colon+1,tmlen)
	else
	tmhr=tm
	tmmn=""
	end
if suf=="PM" and tonumber(tmhr)~=12 then
tmhr=tmhr+12
elseif suf=="PM" and tonumber(tmhr)==12  then
tmhr=12
elseif suf=="AM" and tonumber(tmhr)<10 then
tmhr="0"..tmhr
elseif suf=="AM" and tonumber(tmhr)>=10 and tonumber(tmhr)~=12 then
tmhr=tmhr
elseif suf=="AM" and tonumber(tmhr)==12 then
tmhr="00"
end
if colon~=nil then
return tmhr..":"..tmmn
else
return tmhr
end--if colon~=nil
end--of function
--END OF SCRIPT

this is my current template with a lot of examples. there u can see how u use the new features:

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbanglinux.org/forums/topic/16100/weather-in-conky/

 the file:
 http://dl.dropbox.com/u/19008369/weatheragain9000.lua.tar.gz

 mrppeachys LUA Tutorial
 http://crunchbanglinux.org/forums/topic/17246/how-to-using-lua-scripts-in-conky/
]]

_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="PF Tempesta Seven" --font must be in quotes
default_font_size=10
default_face="normal"
default_size="normal_c"
default_color=0xffffff --white
default_alpha=1 --fully opaque
default_image_width=50
default_image_height=50
default_ro=0
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

local posx=0
local posy=250
--local hell=dnc(0x9ea3cd,0x988a8a)
--local dunkel=dnc(0x8088c3,0x988a8a)
--local farbe_head=dnc(0x585f8d,0xb3a7a7)


--local hell=dnc(0xE1C6B5,0x988a8a)
--local dunkel=dnc(0xa3a23f,0x988a8a)

local hell=0xE1C6B5
local dunkel=0xa3a23f

local posx_1=0
local posx_2=conky_window.width

local zeit=conky_parse('${time %k:%M:%S}')
local wochentag=now["day_lc"]..','
local datum=wochentag..dropZero(now["date"]).."."..month_number(now["month"]).."."..now["year"]



out({x=conky_window.width/2,y=55,c=0xE1C6B5,f='Digital-7',fs=30,face='normal',shaded='no',txt=zeit,hj='c'})


out({x=posx_1,y=85,c=dunkel,f='mono',fs=10,shaded="yes",face='normal',txt='datum:'})
out({x=posx_2,y=85,c=hell,f='mono',fs=10,face='italic',shaded='no',txt=datum,hj='r'})


out({x=posx_1,y=120,c=dunkel,shaded="yes",f="mono",fs=10,txt='aktuell:'})
out({x=posx_2,y=120,c=hell,face='italic',f="mono",fs=10,shaded='no',size="small_c",txt=n2w(now["temp"]).." grad",hj='r'})

out({x=posx_1,y=135,c=dunkel,shaded="yes",f="mono",fs=10,txt='wetter:'})
out({x=posx_2,y=135,c=hell,face='italic',f="mono",fs=10,txt=now["conditions_short_lc"],hj='r'})

out({x=posx_1,y=150,c=dunkel,shaded="yes",f="mono",fs=10,txt='bewölkung:'})
out({x=posx_2,y=150,c=hell,face='italic',f="mono",fs=10,txt=n2w(cloud_cover[1]),hj='r'})

out({x=posx_1,y=165,f="mono",shaded="yes",fs=10,face='normal',c=dunkel,txt='mond:'})
out({x=posx_2,y=165,c=hell,shaded="no",face="italic",size='normal_c',f="mono",fs=10,txt=moon_phase_lc[1],hj='r'})

out({f="ConkyWeather",fs=32,x=posx_2-60,y=220,w=50,h=50,c=dunkel,txt=weather_font[1],hj="r"})
--out({f="ConkyWindNESW",fs=32,x=posx_2-50,y=220,w=50,h=50,c=hell,txt=wind_font[1],hj="r"})
out({f="Moon Phases",fs=32,x=posx_2,y=220,w=50,h=50,c=dunkel,txt=moon_font[1],hj="r"})

-- #################################################################
-- ## Aufruf isometric bars ########################################
-- #################################################################

conky_draw_shape()



-- ########################################################
-- ## Hintergrund zeichnen #######################################
-- ########################################################


local breite=conky_window.width
local hoehe=conky_window.height
local farbe=0x000000
local rundung=25
local bg_alpha=0.4

--conky_draw_bg(rundung,0,0,breite,hoehe,farbe,bg_alpha)

---------------------------
--start or weather forecast table section
--set start forecast day
start_day=2
--set total forecast days you want to display
number_of_days=5
topy=100
gapy=65 -- topy+(gapy*1)

--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=10,topy
   top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,topy+(gapy*1)
   top_left_x_coordinate[4],top_left_y_coordinate[4]=120,topy+(gapy*1)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,topy+(gapy*2)
   top_left_x_coordinate[6],top_left_y_coordinate[6]=120,topy+(gapy*2)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,topy+(gapy*3)
   top_left_x_coordinate[8],top_left_y_coordinate[8]=120,topy+(gapy*3)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,topy+(gapy*4)
   top_left_x_coordinate[10],top_left_y_coordinate[10]=120,topy+(gapy*4)
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do --start of day repeat, do not edit #######
tlx=top_left_x_coordinate[i]+10 --sets top left x position for each repeat ##################
tly=top_left_y_coordinate[i] --sets top left y position for each repeat ##################
--########################################################################################


--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################

this is the file were i store the additional functions:

-- ###################################################################
-- ## Dateisystem ####################################################
-- ###################################################################

function total_aendern(wert)

local laenge=tonumber(string.len(wert))
local str_endung=string.sub(wert,laenge-2,laenge)

if str_endung=='GiB' then
meinstring=string.sub(wert,0,laenge-3)..' gb'
elseif str_endung=='MiB' then
meinstring=string.sub(wert,0,laenge-3)..' mb'
elseif str_endung=='KiB' then
meinstring=string.sub(wert,0,laenge-3)..' kb'

end

convert_string=string.gsub(tostring(meinstring),"%.",",")

return convert_string
end


function aendern(wert,zeichen)

local str_laenge=string.len(wert)
local str_wert=string.sub(wert,0,str_laenge-3)
local str_null=add0(str_wert)
local convert_str=string.gsub(tostring(str_null),"%.",",")..' '..zeichen

return convert_str

end -- of function


-- ###################################################################
-- ## Entferne führende Nullen #######################################
-- ###################################################################

function dropZero(wert)

local erstezahl=tonumber(string.sub(wert,1,1))

if erstezahl == 0 then
ausgabe=string.sub(wert,2,8)
else
ausgabe=string.sub(wert,1,8)
end -- of if

return ausgabe

end -- of function






--##################################################################
--###### Tag-/ Nachtmodus (day-/night mode) ########################
--################################################################## 

function dnc(wert1,wert2)

-- time of the sunrise
local Stunden1=string.sub(sun_rise_24[1],1,2)
local UmrechnungStundenMinuten1=tonumber(Stunden1)*60
local Minuten1=string.sub(sun_rise_24[1],4,5)
local Gesamt1=tonumber(Minuten1)+UmrechnungStundenMinuten1

-- time of the sunset
local Stunden2=string.sub(sun_set_24[1],1,2)
local UmrechnungStundenMinuten2=tonumber(Stunden2)*60
local Minuten2=string.sub(sun_set_24[1],4,5)
local Gesamt2=tonumber(Minuten2)+UmrechnungStundenMinuten2

-- actual time
local AktuelleStunde=tonumber(os.date("%H"))*60
local AktuelleMinuten=tonumber(os.date("%M"))
local AktuelleZeit=AktuelleStunde+AktuelleMinuten

if AktuelleZeit>Gesamt1 and AktuelleZeit<Gesamt2 then
-- Funktion für den Tag
farbe=maya(wert1)
else
-- Funktion für die Nacht
farbe=wert2
end -- end of the if-section

return farbe

end -- end of function


-- ##########################################################
-- ### Maya-Uhr #############################################
-- ##########################################################

function maya(wert)

-- actual date (intellicast)
local intTag=now["date"]
local intTagNummer=tonumber(intTag)*365
local intMonat=month_number(now["month"])
local intMonatNummer=tonumber(intMonat)*12
local intJahr=now["year"]
local intJahrNummer=tonumber(intJahr)
local intDatumNummer=intTagNummer+intMonatNummer+intJahrNummer

-- Am Tag des 'Weltunterganges' wird der gesamte Text in roter Farbe
-- dargestellt. An diesem Tag endet der Maya-Kalender und laut
-- Überlieferung soll an diesem Tag die Welt untergehen.

local Tag=21
local Monat=12
local Jahr=2012
local Datum=(Tag*365)+(Monat*12)+Jahr

if intDatumNummer == Datum then
farbe=0xff0000
elseif intDatumNummer ~= Datum then
farbe=wert
end -- if schleife

return farbe

end -- the function


-- #################################################################



-- #################################################################
-- ## Funktion zum Umwandeln der Windwerte (beaufort scala) ########
-- #################################################################

function wind_speed_text(uebergabe)

local a,b,x=string.find(uebergabe,"(%d*).*")
local x=tonumber(x)

local laenge=string.len(uebergabe)-5
local teil=string.sub(uebergabe,0,laenge)
local wert=add0(teil).." km/h"

if x < 1.85  then
wind_text = "windstill"
elseif x >= 1.85 and x < 9.0 then
wind_text = "geringer Wind mit "..wert
elseif x >= 9.0 and x < 19.0 then
wind_text = "leichter Wind mit "..wert
elseif x >= 19.0 and x < 28.0 then
wind_text = "schwacher Wind mit "..wert
elseif x >= 28.0 and x < 37.0 then
wind_text = "mäßiger Wind mit "..wert
elseif x >= 37.0 and x < 46.0 then
wind_text = "frischer Wind mit "..wert
elseif x >= 46.0 and x < 56.0 then
wind_text = "starker Wind mit "..wert
end--of if x = section

mitkomma=string.gsub(tostring(wind_text),"%.",",")

return mitkomma

end--of function wind_speed_text


-- ##################################################################
-- ## Nachkommastelle bei Windstärke hinzufügen #####################
-- ##################################################################

function add0(input)

if string.find(input,"%a")==nil then
        if string.find(input,"%p")==nil then        
        input=input..',0'
        end
end
return input
end

--#####################################################################
--### Name des Monats wird in die entsprechende Zahl umgewandelt ######
--#####################################################################

function month_number(input)

month_to_num={
"Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember", 
}

for i,v in ipairs(month_to_num) do

    if tostring(input)==tostring(v) then

      -- null hinzufügen
	  if tonumber(i)<=9 then
	  output="0"..tonumber(i)
	  elseif tonumber(i)>=10 then
	  output=tonumber(i)
	  end
	  -- ende 'null hinzufügen'

    end
end--for loop

return output -- return number of month

end--function


-- ####################################################################
-- ## Webcam auslesen #################################################
-- ####################################################################

function meinewebcam()

updates=tonumber(conky_parse("${updates}"))
interval=10
timer=(updates % interval)

if timer==0 then
os.execute("curl -s -m 5 http://www.centennialbulb.org/ctbulb.jpg -o /tmp/bulb.jpg &>/dev/null")
end

end


function laenge(wert)

--set up and show text
font="PF Tempesta Seven"
fsize=8
text=wert
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.x_advance --supposed to measure spaces also

return width

end


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


-- #########################################################
-- ## isometric bars by mrpeachy ###########################
-- ## modified by lionhead #################################
-- #########################################################

require 'cairo'

function bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down,value_pos)

--line 1 settings end  
local a_num1=tonumber(conkyobject)
--local a_num=(height/100)*a_num1
local a_num=(height/100)*a_num1

if framelines == 1 then
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_set_line_width (cr, linethick)
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, width*0.5, -width*0.5)
cairo_rel_line_to (cr, 0, -height)
cairo_stroke (cr)
cairo_translate (cr, -bar_across, -bar_down)
end

--line 1 indicator front face
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, 0, 0);
cairo_rectangle (cr, 0, 0, width, -a_num);
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill (cr)
cairo_translate (cr, -bar_across, -bar_down)
--line 1 indicator side face
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, 0, (linethick*0.1));
cairo_rel_line_to (cr, 0, -a_num)
cairo_rel_line_to (cr, -1*(width*0.5), -1*(width*0.5))
cairo_rel_line_to (cr, 0, a_num)
cairo_rel_line_to (cr, (width*0.5), (width*0.5))
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill (cr)
cairo_translate (cr, -bar_across, -bar_down)

--line 1 indicator top face
cairo_translate (cr, bar_across, bar_down)
cairo_move_to (cr, 0, -a_num);
cairo_rel_line_to (cr, width, 0)
cairo_rel_line_to (cr, -1*(width*0.5), -1*(width*0.5))
cairo_rel_line_to (cr, -width, 0)
cairo_rel_line_to (cr, (width*0.5), (width*0.5))
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill (cr)
cairo_translate (cr, -bar_across, -bar_down)

--line 1 indicator lines
cairo_set_line_width (cr, linethick);
cairo_translate (cr, bar_across, bar_down)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
--vertical, middle
cairo_move_to (cr, 0, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -a_num-(linethick*0.5))
cairo_stroke (cr)
--vertical right
cairo_move_to (cr, width, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -a_num-(linethick*0.5))
cairo_stroke (cr)
--left line
cairo_move_to (cr, -1*(width*0.5), (-1*(width*0.5))+(linethick));
cairo_rel_line_to (cr, 0, -a_num)
cairo_stroke (cr)
--bottom line
cairo_move_to (cr, -1*(linethick*0.5), (linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top of indicator
cairo_move_to (cr, 0, -a_num+(linethick*0.5))
cairo_rel_line_to (cr, width, 0)
cairo_stroke (cr)
--bottom diagonal
cairo_move_to (cr, -1*(linethick*0.15), (linethick*0.65))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--topline
cairo_move_to (cr, (-1*(width*0.5))-(linethick*0.5), ((-1*(width*0.5))-a_num)+(linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top left diagonal
cairo_move_to (cr, 0, -a_num+(linethick*0.5))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--top right diagonal
cairo_move_to (cr, width+(linethick*0.15), -a_num+(linethick*0.35))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
cairo_translate (cr, -bar_across, -bar_down)

-- txt title
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fontsize);
cairo_set_source_rgba (cr,txtred,txtgreen,txtblue,txtalpha);
cairo_translate (cr, txt_across,txt_down)
cairo_move_to (cr, 0,0)
cairo_show_text (cr,title)
-- end txt title

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

--[[ 

-- absolute position below title (no framelines)
cairo_set_source_rgba (cr,valuered,valuegreen,valueblue,valuealpha);
cairo_move_to (cr, value_across,value_down)
cairo_show_text (cr,conkyobject..'%')

]]--

-- relative position above bar (no framelines)
ypos=(-a_num+(linethick*0.5))-40

cairo_set_source_rgba (cr,valuered,valuegreen,valueblue,valuealpha);
cairo_move_to (cr, value_across,ypos)
cairo_show_text (cr,conkyobject..'%')


--------------------------------------
cairo_translate (cr, -txt_across, -txt_down)

if framelines == 1 then
--frame lines
cairo_set_line_width (cr, linethick);
cairo_translate (cr, bar_across, bar_down)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
--vertical, middle
cairo_move_to (cr, 0, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -height-(linethick*0.5))
cairo_stroke (cr)
--vertical right
cairo_move_to (cr, width, 1*(linethick*0.5));
cairo_rel_line_to (cr, 0, -height-(linethick*0.5))
cairo_stroke (cr)
--left line
cairo_move_to (cr, -1*(width*0.5), (-1*(width*0.5))+(linethick));
cairo_rel_line_to (cr, 0, -height)
cairo_stroke (cr)
--bottom line
cairo_move_to (cr, -1*(linethick*0.5), (linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top of indicator
cairo_move_to (cr, 0, -height+(linethick*0.5))
cairo_rel_line_to (cr, width, 0)
cairo_stroke (cr)
--bottom diagonal
cairo_move_to (cr, -1*(linethick*0.15), (linethick*0.65))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--topline
cairo_move_to (cr, (-1*(width*0.5))-(linethick*0.5), ((-1*(width*0.5))-height)+(linethick*0.5))
cairo_rel_line_to (cr, width+linethick, 0)
cairo_stroke (cr)
--top left diagonal
cairo_move_to (cr, 0, -height+(linethick*0.5))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
--top right diagonal
cairo_move_to (cr, width+(linethick*0.15), -height+(linethick*0.35))
cairo_rel_line_to (cr, (-1*(width*0.5)), (-1*(width*0.5)))
cairo_stroke (cr)
cairo_translate (cr, -bar_across, -bar_down)
end
end

function conky_draw_shape ()

local schriftart="PF Tempesta Seven" -- font
local updates=conky_parse('${updates}')

local bar_vertical=510
local txt_vertical=530

update_num=tonumber(updates)

if update_num > 5 then
if conky_window==nil then return end
local w=tonumber(conky_window.width)
local h=tonumber(conky_window.height)
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
cr=cairo_create(cs)

-- ##############################################
-- ### Prozessor (CPU #1) #######################
-- ##############################################

conkyobject=conky_parse('${cpu}')

title="cpu1"
font=schriftart
fontsize=8

framelines=0 -- no frameline=0, frameline=1
linethick=0.5 -- thick of the line

width=20 -- width of the bar
height=80 -- height of the bar

-- color frameline
linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

-- color bar
facered=dnc(165,217)/255
facegreen=dnc(61,199)/255
faceblue=dnc(6,184)/255
facealpha=0.6

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

-- color txt value
valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=10 -- position bar horizontal
bar_down=bar_vertical -- position bar vertical

txt_across=10-- position title horizontal
txt_down=txt_vertical -- position title vertical

value_across=0 -- position txt value horizontal
value_down=15 -- position txt value vertical

-- call of the function
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down,value_pos)


--###################################
--### Prozessor (CPU #2) ############
--###################################
conkyobject=conky_parse('${cpu cpu1}')

title="cpu2"
font=schriftart
fontsize=8

width=20
height=80

framelines=0
linethick=0.5

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(165,217)/255
facegreen=dnc(61,199)/255
faceblue=dnc(6,184)/255
facealpha=0.6

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=50
bar_down=bar_vertical

txt_across=50
txt_down=txt_vertical

value_across=0
value_down=15

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)

-- #################################################
-- #### Arbeitsspeicher RAM  #######################
-- #################################################
conkyobject=conky_parse('${memperc}')
title="ram"
font=schriftart
fontsize=8

framelines=0
linethick=0.5

width=20
height=80

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(250,217)/255
facegreen=dnc(236,199)/255
faceblue=dnc(114,184)/255
facealpha=0.6

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=95
bar_down=bar_vertical

txt_across=95
txt_down=txt_vertical

value_across=-5
value_down=15

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down, txtred, txtgreen, txtblue, txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)


-- #####################################################
-- ######### Heimat-Verzeichnis  (HDD - HOME) ##########
-- #####################################################

conkyobject=conky_parse('${wireless_link_qual_perc wlan0}')
title="wlan"
font=schriftart
fontsize=8

framelines=0
linethick=0.6

width=20
height=80

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(163,171)/255
facegreen=dnc(162,171)/255
faceblue=dnc(63,158)/255
facealpha=0.6

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=135
bar_down=bar_vertical

txt_across=130
txt_down=txt_vertical

value_across=1 -- position txt value horizontal
value_down=15 -- position txt value vertical

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)


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

-- #####################################################
-- ######### Batterie ######################################
-- #####################################################

conkyobject=conky_parse('${fs_used_perc /home/alexander}')
title="home"
font=schriftart
fontsize=8

framelines=0
linethick=0.6

width=20
height=80

txtred=dnc(164,171)/255
txtgreen=dnc(95,171)/255
txtblue=dnc(45,158)/255
txtalpha=1

linered=231/255
linegreen=226/255
lineblue=226/255
linealpha=0.3

facered=dnc(163,171)/255
facegreen=dnc(162,171)/255
faceblue=dnc(63,158)/255
facealpha=0.6

valuered=dnc(163,171)/255
valuegreen=dnc(162,171)/255
valueblue=dnc(63,158)/255
valuealpha=1

bar_across=175
bar_down=bar_vertical

txt_across=170
txt_down=txt_vertical

value_across=1 -- position txt value horizontal
value_down=15 -- position txt value vertical

bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, bar_across, bar_down, title, framelines, font, fontsize, txt_across, txt_down,txtred,txtgreen,txtblue,txtalpha,valuered,valuegreen,valueblue,valuealpha,value_across,value_down)

end
end




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

function linie(breite,posx_1,posx_2,posy_1,posy_2)

line_width=breite
line_cap=CAIRO_LINE_CAP_BUTT

linered=dnc(128,157)/255
linegreen=dnc(136,145)/255
lineblue=dnc(195,135)/255
linealpha=0.3

startx=posx_1
endx=posx_2

starty=posy_1
endy=posy_2

----------------------------
cairo_set_line_width (cr,line_width)
cairo_set_line_cap  (cr, line_cap)
cairo_set_source_rgba (cr,linered,linegreen,lineblue,linealpha)
cairo_move_to (cr,startx,starty)
cairo_line_to (cr,endx,endy)
cairo_stroke (cr)

end


--[[ 
wordwrap_rss by arclance 
Created: 2012-08-22
Updated: 2012-10-15
Changelog
v1.2.1 2012-10-15
    simple alternating entry colors

v1.2 2012-10-13
    wrap each line on the last space (" ") so words don't get cut in half.

v1.1 2012-09-18
    Fix escaping of " characters in the RSS feed data
########################################################################
wraps a line "longLine" to the charachter length defined by "wrapLength"
returns a list containg each wraped line in order
]]

function wordwrap(longLine, wrapLength)
    if #longLine <= wrapLength then --# return list containing input line if it is shorter than the wrap length
        return {longLine}
    end --# if #longLine <= wrapLength then
    local wrapedLines = {}
    local remLine = longLine
    local lineNum = 1
    while #remLine > 0 do
        if #remLine <= wrapLength then
            wrapedLines[lineNum] = remLine
            break
        else
            local s,f,front,back = string.find(remLine:sub(1,(1 + wrapLength)), "(.*)%s(.+)")
            wrapedLines[lineNum] = front
            remLine = back..remLine:sub((2 + wrapLength),#remLine)
        end --# if #remLine <= wrapLength then
        lineNum = lineNum + 1
    end --# while #remLine > 0 do
    return wrapedLines
end --# function wordwrap(longLine, wrapLength)

function conky_rss_wrap(uri, interval_in_minutes, action, wrapLength, num_par, spaces_in_front)
    local rssCommand = "${rss "..uri.." "..interval_in_minutes.." "..action
    if num_par ~= nil then
        rssCommand = rssCommand.." "..num_par
    end --# if num_par ~= nil then
    if spaces_in_front ~= nil then
        rssCommand = rssCommand.." "..spaces_in_front
    end --# if spaces_in_front ~= nil then
    local rssText = (conky_parse((rssCommand.."}"))):gsub(",",""):gsub('"','\\"'):gsub("\n",'","')
    local rssSplit = assert(loadstring('return {"'..rssText..'"}'))()
    local output = ""
    for j = 1, #rssSplit do
        local color = nil
        if math.mod(j, 2) ~= 0 then
            color = "${color1}"
        else
            color = "${color0}"
        end --# if math.mod(j, 2) == 0 then
        local wrapedText = wordwrap(rssSplit[j], tonumber(wrapLength))
        for i = 1, #wrapedText do
            if output ~= "" then
                if i == 1 then
                    output = output.."\n"..color..wrapedText[i]
                else
                    output = output.."\n"..wrapedText[i]
                end --# if i == 1 then
            else
                output = color..wrapedText[i]
            end --# if i ~= 1 then
        end --# for i = 1, #wrapedText do
    end --# for j = 1, #rssSplit do
    return string.lower(output)
end --# function rss_wrap()


-- ####################################################################
-- ## Funktion zum Zeichnen des Hintergrunds ##########################
-- ####################################################################

function conky_draw_bg(r,x,y,w,h,color,alpha)
local function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end


-- ################################################
-- ## umwandeln von zahlen in wörter ########################
-- ################################################

function n2w(number)
--by mrpeachy 11-4-2012
number=tonumber(number)
local n_len=string.len(number)
if number<0 then
number=tonumber(string.sub(number,2,n_len))
minus="minus "
else
number=number
minus=""
end
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn",}
n2_tab={"zehn","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"}
if number>0 then n0="" else n0="null" end
if tu<20 and tu~=10 and tu~=0 then 
	ausgabe=n1_tab[tu]
elseif tu==10 then
	ausgabe="zehn"
elseif tu==0 then
	ausgabe="null"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	g=string.sub(number,2,2)
--	out=joinu..'lang:'..tu..' geschn.: '..g..' '..n2_tab[t]..'('..string.sub(tu,1,1)..','..string.sub(tu,2,2)..')'
	ausgabe=international(tu,g,n2_tab[t])
--	out=n2_tab[t]..joinu..u -- original
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return minus..h.." hundred and "..ausgabe
elseif number==100 then
	return "einhundert"
elseif number<100 then
	return minus..ausgabe
end
end--function

function international(lang,geschnitten,wort)

local anzahl=tonumber(lang) -- ganze zahl, z.b. 21
local kurzezahl=tonumber(geschnitten) -- letzte zahl, z.b. 1 von 21

if kurzezahl==1 or anzahl==1 then

 if string.len(anzahl)>1  then
 nummer='einund'..n2_tab[t]     -- gives me for example 21, 31 etc
 elseif string.len(anzahl)==1 then
 nummer='eins'			           -- gives me the number 1
 end

elseif kurzezahl~=1 or anzahl ~=1 then

   if anzahl==0 then
   nummer=wort                                     -- should give me the word 'null' (zero)
   elseif tonumber(string.sub(anzahl,1,1)) and tonumber(string.sub(anzahl,2,2))==0 then   --
   nummer=wort                                     -- gives me numbers like 10,20,30 etc.
--   elseif anzahl<0 then
--     nummer=minus..' '..wort
   else 
    nummer=n2w(kurzezahl)..'und'..wort         --  gives me such numbers like 22,23,24 etc.
    end

end

return nummer

end -- der fun ktion


--################################################

-- ################################################
-- ## umwandeln von zahlen in wörter ########################
-- ################################################

function n2w(number)

number=tonumber(number)
local n_len=string.len(number)
if number<0 then
number=tonumber(string.sub(number,2,n_len))
minus="minus "
else
number=number
minus=""
end
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn",}
n2_tab={"zehn","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"}
if number>0 then n0="" else n0="null" end
if tu<20 and tu~=10 and tu~=0 then 
	ausgabe=n1_tab[tu]
elseif tu==10 then
	out="zehn"
elseif tu==0 then
	ausgabe="null"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	g=string.sub(number,2,2)
--	out=joinu..'lang:'..tu..' geschn.: '..g..' '..n2_tab[t]..'('..string.sub(tu,1,1)..','..string.sub(tu,2,2)..')'
	ausgabe=international(tu,g,n2_tab[t])
--	out=n2_tab[t]..joinu..u -- original
end

if number>99 and number~=100 and number~=1 then
	h=n1_tab[h]
	return minus..h.." hundred and "..ausgabe
elseif number==100 then
	return "einhundert"
elseif number<100 then
	return minus..ausgabe
elseif number==1 then
       if minus=="minus " then
       return "minus ein grad"
       else
       return "whatever it should be for one"
       end
end
end--function

function international(lang,geschnitten,wort)

local anzahl=tonumber(lang) -- ganze zahl, z.b. 21
local kurzezahl=tonumber(geschnitten) -- letzte zahl, z.b. 1 von 21

if kurzezahl==1 or anzahl==1 then

 if string.len(anzahl)>1  then
 nummer='einund'..n2_tab[t]     -- gives me for example 21, 31 etc
 elseif string.len(anzahl)==1 then
 nummer='eins'			           -- gives me the number 1
 end

elseif kurzezahl~=1 or anzahl ~=1 then

   if anzahl==0 then
   nummer=wort                                     -- should give me the word 'null' (zero)
   elseif tonumber(string.sub(anzahl,1,1)) and tonumber(string.sub(anzahl,2,2))==0 then   --
   nummer=wort                                     -- gives me numbers like 10,20,30 etc.
   else 
    nummer=n2w(kurzezahl)..'und'..wort         --  gives me such numbers like 22,23,24 etc.
    end

end

return nummer

end -- der fun ktion


-- #################################################################



 local numbers =	{
 	unity		={ "ein", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"},
 	decimal		= {"zehn", "zwanzig", "dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"},
 	n		= {nil, nil, nil},
 			}

 local function n2w4d(number)
 	local i, j, s = nil, 1, ''
 	for i in pairs(numbers.n) do numbers.n[i] = nil end
 	for i = string.len(number), 1, -1 do numbers.n[j]=tonumber(string.sub(number, i, i)); j=j+1 end
 	if not numbers.n[3] and not numbers.n[2] and numbers.n[1]==0 then return 'null' end
 	if numbers.n[3] then s = numbers.unity[numbers.n[3]] .. 'hundert' end
 	if numbers.n[3] and numbers.n[2]>0 or numbers.n[3] and numbers.n[1]>0 then s = s .. ' ' end
 	if numbers.n[2] and numbers.n[2]*10+numbers.n[1]<20 then s = s .. numbers.unity[numbers.n[2]*10+numbers.n[1]]; return s end
 	if numbers.n[1]>0 then s=s .. numbers.unity[numbers.n[1]] end
 	if numbers.n[2] and numbers.n[2]>1 and numbers.n[1]>0 then s = s .. 'und' end
 	if numbers.n[2] and numbers.n[2]>0 then s = s .. numbers.decimal[numbers.n[2]] elseif numbers.n[1]==1 then s = s .. 's' end
 	return s
 end

this is the neccesary conkyrc:

#-----Conky settings
background no
no_buffers yes
#	out_to_console yes
top_cpu_separate no
#	cpu_avg_samples 10
#	net_avg_samples 10
#	max_port_monitor_connections 10
update_interval 1
total_run_times 0

#-----Text setings
use_xft yes
xftfont Mono:bold:size=10
xftalpha 0.8
#	uppercase no
override_utf8_locale yes
#	format_human_readable no
#	short_units
#	max_user_text 64
#	text_buffer_size 1024

#-----Window settings
own_window yes
own_window_type desktop
#	own_window_argb_visual no
#	own_window_argb_value 0
own_window_transparent yes
own_window_colour black
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_class Conky
own_window_title Conky

#----Layout settings
minimum_size 200 550
maximum_width 200

alignment tr
use_spacer right

gap_x 30
gap_y 30

#-----Graphics settings
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
stippled_borders 0
#	border_inner_margin 16
border_width 1
double_buffer yes
#	max_specials 64
#	imlib_cache_size 0

#-----Color settings
default_color white
default_shade_color black
default_outline_color black

#-----LUA
lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
#lua_load ~/v9000/weather_testing.lua
lua_load ~/v9000/template-shadow.lua

lua_load ~/v9000/additional.lua
lua_load ~/v9000/countdown.lua

TEXT

#${font mono:bold:size=10}${alignc}${color ff0000}London Film and Comic Con${color}${font}
#${lua conky_countdown {t={year=2013, month=7, day=5, hour=11, min=11}, x=0, y=conky_window.height/2, color=0xff0000, alpha=1, font="mono", size=10, style="normal", weight="normal", alignH="left", alignV="top"} }

if u have further questions then just feel free to ask smile remember the new code HASN'T effect to your template! it's just an update for the file v9000.lua

Moderator Edit - Image resize - VastOne

----------------------------------------------------------------------------------------------------------------------------
Please use thumbnails (please try to avoid the large thumbnail imgur.com code) linking to the larger image to help those of us with slow connections. An example of the code needed is below. Most image hosting sites will automatically generate this for you as well. Users have been using postimage.org lately which does a nice job.

[url=http://link.to.your.fullsized.image][img]http://link.to.your.thumbnail.image[/img][/url]

Last edited by lionhead (2012-12-22 10:25:54)

Offline

#868 2012-12-20 14:58:43

DrakarNoir
#! CrunchBanger
From: just beyond the sign post
Registered: 2011-09-02
Posts: 132
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

Greets all


I am having a bit of difficulty with this v9000 template. Every thing works as I want EXCEPT when the Next 3 Hours button is activated. The Alert section doesn't move to the proper place. I have poked and prodded at this ad nauseam and cannot figure it out. Any help much appreciated.

weather_interactive.lua:

click_start=1
weatherbutton=0
--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION-
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--#######################################################################
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="DroidSans"--font must be in quotes
default_font_size=11
default_color=0xffffff--white
default_alpha=5--fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--start clickfunction and resturn coordinates
localx,localy=clickfunction()
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
--####################################
--MAIN WEATHER BUTTON ################
--####################################
--weatherbutton button
local weatherbuttonx=10.5
local weatherbuttony=5.5
local weatherbuttonw=45
local weatherbuttonh=45
--calculate if click was inside box
if localx>=weatherbuttonx and localx<=weatherbuttonx+weatherbuttonw and localy>=weatherbuttony and localy<=weatherbuttony+weatherbuttonh and weatherbutton~=1 then 
weatherbutton=1 
elseif localx>=weatherbuttonx and localx<=weatherbuttonx+weatherbuttonw and localy>=weatherbuttony and localy<=weatherbuttony+weatherbuttonh and weatherbutton==1 then 
weatherbutton=0
end
if weatherbutton==0 then
alsx=15
alsy=75
out ({c=0x71A1DF,f="DroidSans",fs=11,x=weatherbuttonx+45,y=weatherbuttony+8,txt=now["conditions"]})
out ({c=0x2C3949,f="DroidSans:bold",fs=24,x=weatherbuttonx+44,y=weatherbuttony+32,txt=now["temp"].."°"})
out ({c=0x6f99b4,f="DroidSans:bold",fs=24,x=weatherbuttonx+43,y=weatherbuttony+31,txt=now["temp"].."°"})
out ({c=0xFFFFFF,f="DroidSans",fs=10,x=weatherbuttonx+45,y=weatherbuttony+43,txt="Feels Like: "})
  out ({c=0xFFFFFF,f="DroidSans",fs=10,x=weatherbuttonx+92,y=weatherbuttony+43,txt=now["temp"].."°"})
image({x=weatherbuttonx,y=weatherbuttony+2,h=40,w=40,file=now["weather_icon"]})
out({c=0x00BFFF,a=1,f="DroidSans",fs=11,x=weatherbuttonx,y=weatherbuttony+60,txt=weather_location})
end
--###########################################################
--THIS SECTION TURNED ON BY MAIN WEATHER BUTTON #############
--###########################################################
if weatherbutton==1 then
out ({c=0xFFFFFF,f="DroidSans",fs=11,x=weatherbuttonx+45,y=weatherbuttony+8,txt=now["conditions"]})
out ({c=0xFAFAEC,f="DroidSans:bold",fs=24,x=weatherbuttonx+44,y=weatherbuttony+32,txt=now["temp"].."°"})
out ({c=0x48D1CC,f="DroidSans:bold",fs=24,x=weatherbuttonx+43,y=weatherbuttony+31,txt=now["temp"].."°"})
out ({c=0xFFFFFF,f="DroidSans",fs=10,x=weatherbuttonx+45,y=weatherbuttony+43,txt="Feels Like: "})
  out ({c=0xFFFFFF,f="DroidSans",fs=10,x=weatherbuttonx+92,y=weatherbuttony+43,txt=now["temp"].."°"})
image({x=weatherbuttonx,y=weatherbuttony+2,h=40,w=40,file=now["weather_icon"]})
out({c=0x00BFFF,a=1,f="DroidSans",fs=11,x=weatherbuttonx,y=weatherbuttony+60,txt=weather_location})

--Display Weather Information
x1=15--Start of column 1 (Data Label)
x2=85--Start of column 2 (Data)
x3=140--Start of column 3 (Data Label)
x4=200--Start of column 4 (Data)
ypos=85
yypos=12
gap=15

--image({x=x1-7,y=ypos-12,h=210,w=260,file="~/.conky/NightDrive/images/1_pixel/bk_20.png"})
--data titles
  --output of data options
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos,txt="Wind Chill:"})
  out({c=0x00BFFF,a=1,f="DroidSans",fs=11,x=x2,y=ypos,txt=now["wind_chill"].."°"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos,txt="Heat Index:"})
  out({c=0xFF8C00,a=1,f="DroidSans",fs=11,x=x4,y=ypos,txt=now["heat_index"].."°"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*1),txt="Today's Hi:"})
  out({c=0xFF8C00,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*1),txt=high_temp[1].."°"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*1),txt="Today's Lo:"})
  out({c=0x00BFFF,a=1,f="DroidSans",fs=11,x=x4,y=ypos+(yypos*1),txt=low_temp[1].."°"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*2),txt="Dew Point:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*2),txt=now["dew_point"].."°"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*2),txt="Humidity:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x4,y=ypos+(yypos*2),txt=now["humidity"].."%"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*3),txt="Pressure:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*3),txt=round((now["pressure_mb"]*0.0295301), 2).."\""})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*4),txt="Wind:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*4),txt=now["wind_nesw"].." @ "..now["wind_mph"]..", ".."gusting to: "..now["wind_gusts"]})
ypos=ypos+2
yypos=12
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*5),txt="Visibility:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*5),txt=now["visibility"]})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*5),txt="Ceiling:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x4,y=ypos+(yypos*5),txt=now["ceiling"]})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*6),txt="Cloud Cover:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*6),txt=cloud_cover[1].."%"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*6),txt="UV Index:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x4,y=ypos+(yypos*6),txt=uv_index_num[1].." ".."("..uv_index_txt[1]..")"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*7),txt="Chance of Precipitation:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*7),txt=precipitation[1].."%"})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*8),txt="Snow Probability:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*8),txt=snow[1].."%"})
ypos=ypos+2
yypos=12
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*9),txt="Sun Rise:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*9),txt=sun_rise_lc[1]})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*9),txt="Sun Set:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x4,y=ypos+(yypos*9),txt=sun_set_lc[1]})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*10),txt="Moon Rise:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*10),txt=moon_rise_lc[1]})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x3,y=ypos+(yypos*10),txt="Moon Set:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x4,y=ypos+(yypos*10),txt=moon_set_lc[1]})
out({c=0xFAFAEC,a=1,f="DroidSans",fs=11,x=x1,y=ypos+(yypos*11),txt="Moon Phase:"})
  out({c=0x48D1CC,a=1,f="DroidSans",fs=11,x=x2,y=ypos+(yypos*11),txt=moon_phase[1]})
  image({x=x4,y=ypos+(yypos*10),h=20,w=20,file=moon_icon[1]})

--next 3 hour forecast button
--next3button button
local next3buttonx=10.5
local next3buttony=230
local next3buttonw=70
local next3buttonh=15
local next3buttononc={1,0,0,1}
local next3buttonoffc={1,1,1,1}
if localx>=next3buttonx and localx<=next3buttonx+next3buttonw and localy>=next3buttony and localy<=next3buttony+next3buttonh and next3button~=1 then next3button=1 elseif localx>=next3buttonx and localx<=next3buttonx+next3buttonw and localy>=next3buttony and localy<=next3buttony+next3buttonh and next3button==1 then next3button=0 end
if next3button==1 then cairo_set_source_rgba (cr,next3buttononc[1],next3buttononc[2],next3buttononc[3],next3buttononc[4]) else cairo_set_source_rgba (cr,next3buttonoffc[1],next3buttonoffc[2],next3buttonoffc[3],next3buttonoffc[4]) end;cairo_set_line_width (cr,1);cairo_rectangle (cr,next3buttonx,next3buttony,next3buttonw,next3buttonh);cairo_stroke (cr)
out ({f="DroidSans",fs=10,x=next3buttonx+5,y=next3buttony+next3buttonh-4,txt="Next 3 Hours"})font="DroidSans"
--THIS SECTION CONTROLLED BY NEXT3 BUTTON
--set adjustments for forecast buttons when next 3 on or off
if next3button==1 then
fcb=355
alsy=355
fcb1x=10.5
fcb1y=330
n3x=20
nxy=next3buttony+45

--image({x=x1-7,y=ypos-12,h=210,w=260,file="~/.conky/NightDrive/images/1_pixel/bk_20.png"})
--Hour 1
image({w=30,h=30,x=n3x+15,y=nxy-5,file=now["fc_hour1_wicon"]})--good
out({c=0xFF8C00,x=n3x+18,y=nxy-13,txt=now["fc_hour1_time"].." "..now["fc_hour1_ampm_lc"]})
out({c=0x48D1CC,x=n3x,y=nxy+40,txt=now["fc_hour1_temp"].."°".." / "..now["fc_hour1_cond_short"]})
--Hour 2
n3x=112
image({w=30,h=30,x=n3x+15,y=nxy-5,file=now["fc_hour2_wicon"]})--good
out({c=0xFF8C00,x=n3x+18,y=nxy-13,txt=now["fc_hour2_time"].." "..now["fc_hour2_ampm_lc"]})
out({c=0x48D1CC,x=n3x,y=nxy+40,txt=now["fc_hour2_temp"].."°".." / "..now["fc_hour2_cond_short"]})
--Hour 3
n3x=200
image({w=30,h=30,x=n3x+15,y=nxy-5,file=now["fc_hour3_wicon"]})--good
out({c=0xFF8C00,x=n3x+18,y=nxy-13,txt=now["fc_hour3_time"].." "..now["fc_hour3_ampm_lc"]})
out({c=0x48D1CC,x=n3x,y=nxy+40,txt=now["fc_hour3_temp"].."°".." / "..now["fc_hour3_cond_short"]})

else
fcb=255
alsy=255
fcb1x=100.5
fcb1y=230
end--next3button

--forecast button
--forecastbutton button
local forecastbuttonx=fcb1x
local forecastbuttony=fcb1y
local forecastbuttonw=100
local forecastbuttonh=15
local forecastbuttononc={1,0,0,1}
local forecastbuttonoffc={1,1,1,1}
if localx>=forecastbuttonx and localx<=forecastbuttonx+forecastbuttonw and localy>=forecastbuttony and localy<=forecastbuttony+forecastbuttonh and forecastbutton~=1 then forecastbutton=1 elseif localx>=forecastbuttonx and localx<=forecastbuttonx+forecastbuttonw and localy>=forecastbuttony and localy<=forecastbuttony+forecastbuttonh and forecastbutton==1 then forecastbutton=0 end
if forecastbutton==1 then cairo_set_source_rgba (cr,forecastbuttononc[1],forecastbuttononc[2],forecastbuttononc[3],forecastbuttononc[4]) else cairo_set_source_rgba (cr,forecastbuttonoffc[1],forecastbuttonoffc[2],forecastbuttonoffc[3],forecastbuttonoffc[4]) end;cairo_set_line_width (cr,1);cairo_rectangle (cr,forecastbuttonx,forecastbuttony,forecastbuttonw,forecastbuttonh);cairo_stroke (cr)
out ({f="DroidSans",fs=10,x=forecastbuttonx+5,y=forecastbuttony+forecastbuttonh-4,txt="Extended Forecast"})font="DroidSans"

if forecastbutton==1 then
alsy=285
--fc2button button
local fc2buttonx=10.5
local fc2buttony=fcb
local fc2buttonw=30
local fc2buttonh=15
local fc2buttononc={1,0,0,1}
local fc2buttonoffc={1,1,1,1}
if localx>=fc2buttonx and localx<=fc2buttonx+fc2buttonw and localy>=fc2buttony and localy<=fc2buttony+fc2buttonh and fc2button~=1 then fc8button=0;fc6button=0;fc4button=0;fc2button=1 elseif localx>=fc2buttonx and localx<=fc2buttonx+fc2buttonw and localy>=fc2buttony and localy<=fc2buttony+fc2buttonh and fc2button==1 then fc2button=0 end
if fc2button==1 then cairo_set_source_rgba (cr,fc2buttononc[1],fc2buttononc[2],fc2buttononc[3],fc2buttononc[4]) else cairo_set_source_rgba (cr,fc2buttonoffc[1],fc2buttonoffc[2],fc2buttonoffc[3],fc2buttonoffc[4]) end;cairo_set_line_width (cr,1);cairo_rectangle (cr,fc2buttonx,fc2buttony,fc2buttonw,fc2buttonh);cairo_stroke (cr)
out ({f="DroidSans",fs=10,x=fc2buttonx+3,y=fc2buttony+fc2buttonh-5,txt="2 Day"})

--fc4button button
local fc4buttonx=10.5+35
local fc4buttony=fcb
local fc4buttonw=30
local fc4buttonh=15
local fc4buttononc={1,0,0,1}
local fc4buttonoffc={1,1,1,1}
if localx>=fc4buttonx and localx<=fc4buttonx+fc4buttonw and localy>=fc4buttony and localy<=fc4buttony+fc4buttonh and fc4button~=1 then fc8button=0;fc6button=0;fc4button=1;fc2button=0 elseif localx>=fc4buttonx and localx<=fc4buttonx+fc4buttonw and localy>=fc4buttony and localy<=fc4buttony+fc4buttonh and fc4button==1 then fc4button=0 end
if fc4button==1 then cairo_set_source_rgba (cr,fc4buttononc[1],fc4buttononc[2],fc4buttononc[3],fc4buttononc[4]) else cairo_set_source_rgba (cr,fc4buttonoffc[1],fc4buttonoffc[2],fc4buttonoffc[3],fc4buttonoffc[4]) end;cairo_set_line_width (cr,1);cairo_rectangle (cr,fc4buttonx,fc4buttony,fc4buttonw,fc4buttonh);cairo_stroke (cr)
out ({f="DroidSans",fs=10,x=fc4buttonx+3,y=fc4buttony+fc4buttonh-5,txt="4 Day"})font="DroidSans"

--fc6button button
local fc6buttonx=10.5+70
local fc6buttony=fcb
local fc6buttonw=30
local fc6buttonh=15
local fc6buttononc={1,0,0,1}
local fc6buttonoffc={1,1,1,1}
if localx>=fc6buttonx and localx<=fc6buttonx+fc6buttonw and localy>=fc6buttony and localy<=fc6buttony+fc6buttonh and fc6button~=1 then fc8button=0;fc6button=1;fc4button=0;fc2button=0 elseif localx>=fc6buttonx and localx<=fc6buttonx+fc6buttonw and localy>=fc6buttony and localy<=fc6buttony+fc6buttonh and fc6button==1 then fc6button=0 end
if fc6button==1 then cairo_set_source_rgba (cr,fc6buttononc[1],fc6buttononc[2],fc6buttononc[3],fc6buttononc[4]) else cairo_set_source_rgba (cr,fc6buttonoffc[1],fc6buttonoffc[2],fc6buttonoffc[3],fc6buttonoffc[4]) end;cairo_set_line_width (cr,1);cairo_rectangle (cr,fc6buttonx,fc6buttony,fc6buttonw,fc6buttonh);cairo_stroke (cr)
out ({f="DroidSans",fs=10,x=fc6buttonx+3,y=fc6buttony+fc6buttonh-5,txt="6 Day"})font="DroidSans"

--fc8button button
local fc8buttonx=10.5+105
local fc8buttony=fcb
local fc8buttonw=30
local fc8buttonh=15
local fc8buttononc={1,0,0,1}
local fc8buttonoffc={1,1,1,1}
if localx>=fc8buttonx and localx<=fc8buttonx+fc8buttonw and localy>=fc8buttony and localy<=fc8buttony+fc8buttonh and fc8button~=1 then fc8button=1;fc6button=0;fc4button=0;fc2button=0 elseif localx>=fc8buttonx and localx<=fc8buttonx+fc8buttonw and localy>=fc8buttony and localy<=fc8buttony+fc8buttonh and fc8button==1 then fc8button=0 end
if fc8button==1 then cairo_set_source_rgba (cr,fc8buttononc[1],fc8buttononc[2],fc8buttononc[3],fc8buttononc[4]) else cairo_set_source_rgba (cr,fc8buttonoffc[1],fc8buttonoffc[2],fc8buttonoffc[3],fc8buttonoffc[4]) end;cairo_set_line_width (cr,1);cairo_rectangle (cr,fc8buttonx,fc8buttony,fc8buttonw,fc8buttonh);cairo_stroke (cr)
out ({f="DroidSans",fs=10,x=fc8buttonx+3,y=fc8buttony+fc8buttonh-4,txt="8 Day"})font="DroidSans"


if fc8button==1 then 
number_of_days=8
alsy=760
elseif fc6button==1 then 
number_of_days=6
alsy=640
elseif fc4button==1 then 
number_of_days=4
alsy=515
elseif fc2button==1 then 
number_of_days=2
alsy=395
else
number_of_days=0
alsy=275
end

else
number_of_days=0
alsy=265
end--if forecast buttonelse


--###########################################################
--start or weather forecast repeat section
--set start forecast day
if number_of_days>0 then--so that section is only active if you want to see it!
start_day=1
--set total forecast days you want to display
topy=fcb+40
ygap=120
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=20,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=140,topy
ady=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=20,ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=140,ady
ady=topy+ygap+ygap
top_left_x_coordinate[5],top_left_y_coordinate[5]=20,ady
top_left_x_coordinate[6],top_left_y_coordinate[6]=140,ady
ady=topy+ygap+ygap+ygap
top_left_x_coordinate[7],top_left_y_coordinate[7]=20,ady
top_left_x_coordinate[8],top_left_y_coordinate[8]=140,ady
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do--start of day repeat, do not edit ########
local tlx=top_left_x_coordinate[i]--sets top left x position for each repeat ###################
local tly=top_left_y_coordinate[i]--sets top left y position for each repeat ###################
--########################################################################################
out({c=0xFAFAEC,x=tlx,y=tly,txt=forecast_day[i].." \- "..forecast_month_short[i].."\, "..forecast_date[i]})
image({x=tlx,y=tly+5,h=30,w=30,file=weather_icon[i]})
out({c=0xFF8C00,x=tlx+35,y=tly+33,txt=high_temp[i].."°"})
out({c=0xFAFAEC,x=tlx+52,y=tly+33,txt="/"})
out({c=0x00BFFF,x=tlx+60,y=tly+33,txt=low_temp[i].."°"})
out({c=0x48D1CC,x=tlx+35,y=tly+18,txt=conditions_short[i]})
out({c=0xFAFAEC,x=tlx-1,y=tly+50,txt="Chance Precip:"})
  out({c=0x48D1CC,x=tlx+78,y=tly+50,txt=precipitation[i].."%"})
out({c=0xFAFAEC,x=tlx,y=tly+62,txt="Wind:"})
  out({c=0x48D1CC,x=tlx+30,y=tly+62,txt=wind_nesw[i].." @ "..wind_mph[i].." mph"})
out({c=0xFAFAEC,x=tlx,y=tly+74,txt="Sunrise:"})
  out({c=0x48D1CC,x=tlx+55,y=tly+74,txt=sun_rise[i]})
out({c=0xFAFAEC,x=tlx,y=tly+86,txt="Sunset:"})
  out({c=0x48D1CC,x=tlx+55,y=tly+86,txt=sun_set[i]})
--out({c=0xFAFAEC,x=tlx,y=tly+98,txt="Moon:"})
  --out({c=0x48D1CC,x=tlx+30,y=tly+98,txt=moon_phase[i]})
--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
end--if number_of_days>0

end--OF WEATHER SECTION CONTROLLED BY MAIN WEATHER BUTTON

--ALERTS SECTION
--show alert icon
image({x=alsx,y=alsy,h=15,w=10,file=alert_icon})
--show number of alerts
out({x=alsx+15,y=alsy+15,fs=12,txt=alert_number})
--display alert information
display_alerts=2--set number of alerts to show,set 0 to show all
top_left_alert_x=28--set top left coordinates for entire alerts section
top_left_alert_y=15--^alerts will display in a single column
alert_gap=40--sets the gap between the TOP of one alert and the Top of the next alert
--#######################################################################################################################################
if alert_number==0 then noal=1 elseif alert_number~=0 and display_alerts>alert_number then noal=alert_number else noal=display_alerts end
for i=1,noal do--start of alerts display section. do not edit ###########################################################################
local tlx=alsx+top_left_alert_x--write output relative to tlx #################################
local tly=alsy+top_left_alert_y+((i-1)*alert_gap)--write output relative to tlx ###############
--########################################################################################
out({c=0xffffff,a=1,f="DroidSans",fs=8,x=tlx,y=tly,   txt=alert_type[i]})
out({c=0xffffff,a=1,f="DroidSans",fs=8,x=tlx,y=tly+15,txt=alert_issued[i]})
--########################################################################################
end--of alert display section ############################################################
--########################################################################################]]

--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################

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

Another question...

I want to launch the NOAA weather alerts site by clicking on the alert icon in order to read the alerts that are reported. How would this be accomplished?

Last edited by DrakarNoir (2012-12-23 14:26:46)


"The nine most terrifying words in the English language are, 'I'm from the government and I'm here to help.'.”  ~Ronald Reagan

Offline

#869 2012-12-27 10:30:24

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

i've added a new feature. now u can underline words.

i removed the feature to rotate text because i've never used it. and i really think that no one uses this feature.

--weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
-- update by mrpeachy
-- additional features (underline,shadow, big characters, low characters) by lionhead and arclance
require 'cairo'
require 'imlib2'
local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"

local username = "alexander"
package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

start=1
--INITIALIZE SETTINGS-- need only be run once
settings_table=weather_settings()
--##################################
--######## main function ########### 
function conky_weather()--##########
--##################################
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}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
--################################################
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]
--################################################
print ("gathering data with curl")
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section
--#########################################################################

--#########################################################################
--in case curl craps up it should retry until it works
if testall==nil or  alerttest==nil then
print ("curl attempt timed out, trying again")
local web=settings_table[2]
local alert_check=settings_table[13]
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert_check
processall=1
end--if testall==nil
--end or curl reruns ######################################################

--START PROCESSING ###########################################################################
if testall~=nil and alerttest~=nil and processall==1 then
local weathericons=settings_table[3]
local con_short=settings_table[4]
local visibility_unit=settings_table[6]
local wind_mph_unit=settings_table[7]
local wind_km_unit=settings_table[8]
local wind_kts_unit=settings_table[9]
local ceiling_unit=settings_table[10]
local wind_degrees_unit=settings_table[11]
local translate=settings_table[12]
local alert_check=settings_table[13]
--#########################################################################
--LOAD TRANSLATE TABLES IF TRANSLATE SETTING = 1
	if translate==1 then
	monthshort=settings_table[21]
	monthnames=settings_table[20]
	dayhort=settings_table[19]
	daynames=settings_table[18]
	neswtext=settings_table[14]
	tsuffix=settings_table[15]
	uvindextext=settings_table[16]
	moonphases=settings_table[17]
	additional=settings_table[22]
	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort

	dayshort={Monday="Mon",Tuesday="Tue",Wednesday="Wed",Thursday="Thu",Friday="Fri",Saturday="Sat",Sunday="Sun"}
	monthshort={January="Jan",February="Feb",March="Mar",April="Apr",May="May",June="Jun",July="Jul",August="Aug",September="Sep",October="Oct",November="Nov",December="Dec"}
	end--end if translate =1
--#########################################################################
--process data tables
--intellicast to conky weather icon conversion
wimage={
wx_65="32",  -- Clear
wx_66="30",  -- Partly Cloudy
wx_67="26",  -- Cloudy
wx_68="32",  -- Clear
wx_69="28",  -- Mostly Cloudy
wx_70="20",  -- Fog
wx_71="32",  -- Clear
wx_72="21",  -- Haze
wx_73="36",  -- Hot
wx_74="14",  -- Light Snow Showers
wx_75="28",  -- Mostly Cloudy
wx_76="18",  -- Sleet
wx_77="14",  -- Light Snow Showers
wx_78="23",  -- Blustery
wx_79="05",  -- Mixed Rain and Snow
wx_80="15",  -- Drifting Snow
wx_81="15",  -- Drifting Snow
wx_82="11",  -- Light Rain
wx_83="16",  -- Snow
wx_84="00",  -- Tornado
wx_85="32",  -- Clear
wx_86="25",  -- N/A
wx_87="09",  -- Drizzle
wx_88="05",  -- Mixed Rain and Snow
wx_89="18",  -- Sleet
wx_90="18",  -- Sleet
wx_91="39",  -- Scattered Showers
wx_92="39",  -- Scattered Showers
wx_93="39",  -- Scattered Showers
wx_94="39",  -- Scattered Showers
wx_95="37",  -- Isolated Thunderstorms
wx_96="37",  -- Isolated Thunderstorms
wx_97="31",  -- Clear
wx_98="29",  -- Partly Cloudy
wx_99="27",  -- Mostly Cloudy
wx_100="47",  -- Isolated Thunderstorms
wx_101="47",  -- Isolated Thunderstorms
wx_102="33",  -- Fair
wx_103="26",  -- Cloudy
wx_104="20",  -- Fog
wx_105="45",  -- Scattered Showers
wx_106="45",  -- Scattered Showers
wx_107="11",  -- Light Rain
wx_108="46",  -- Snow Showers
wx_109="46",  -- Snow Showers
wx_110="06",  -- Mixed Rain and Sleet
wx_111="18",  -- Sleet
wx_112="06",  -- Mixed Rain and Sleet
wx_113="46",  -- Snow Showers
wx_114="46",  -- Snow Showers
wx_115="31",  -- Clear
wx_116="47",  -- Isolated Thunderstorms
}--end w image table
--convert intellicast icons to weather font
wfont={
wx_65="a",
wx_66="c",
wx_67="f",
wx_68="a",
wx_69="d",
wx_70="0",
wx_71="a",
wx_72="9",
wx_73="5",
wx_74="p",
wx_75="d",
wx_76="w",
wx_77="p",
wx_78="6",
wx_79="x",
wx_80="8",
wx_81="8",
wx_82="h",
wx_83="q",
wx_84="m",
wx_85="a",
wx_86="-",
wx_87="h",
wx_88="x",
wx_89="w",
wx_90="w",
wx_91="g",
wx_92="g",
wx_93="g",
wx_94="g",
wx_95="k",
wx_96="k",
wx_97="A",
wx_98="C",
wx_99="D",
wx_100="K",
wx_101="K",
wx_102="B",
wx_103="f",
wx_104="0",
wx_105="G",
wx_106="G",
wx_107="h",
wx_108="O",
wx_109="O",
wx_110="x",
wx_111="w",
wx_112="x",
wx_113="O",
wx_114="O",
wx_115="A",
wx_116="K",
}--end w font table
--conversion day and month tables
moonfontt={
["New"]="@",
["Full"]="=",
["First Quarter"]="T",
["Last Quarter"]="G",
["Waning Gibbous"]="D",
["Waning Crescent"]="J",
["Waxing Crescent"]="Q",
["Waxing Gibbous"]="W",
}--end of moon font table
moonicont={
["New"]=weathericons.."moon_new.png",
["Full"]=weathericons.."moon_full.png",
["First Quarter"]=weathericons.."moon_first_quarter.png",
["Last Quarter"]=weathericons.."moon_last_quarter.png",
["Waning Gibbous"]=weathericons.."moon_waning_gibbous.png",
["Waning Crescent"]=weathericons.."moon_waning_crescent.png",
["Waxing Crescent"]=weathericons.."moon_waxing_crescent.png",
["Waxing Gibbous"]=weathericons.."moon_waxing_gibbous.png",
}--end of moon icon table
windfontt={
S="9",
SSW=":",
SW=";",
WSW="<",
W="=",
WNW=">",
NW="?",
NNW="@",
N="1",
NNE="2",
NE="3",
ENE="4",
E="5",
ESE="6",
SE="7",
SSE="8"
}--end of wind direction font table
--#########################################################################

--#########################################################################
--setup tables for forecast weather
forecast_day={}
forecast_day_caps={}
forecast_day_lc={}
forecast_day_short={}
forecast_day_short_caps={}
forecast_day_short_lc={}
forecast_month={}
forecast_month_caps={}
forecast_month_lc={}
forecast_month_short={}
forecast_month_short_caps={}
forecast_month_short_lc={}
forecast_date={}
weather_icon={}
weather_font={}
high_temp={}
low_temp={}
conditions={}
conditions_caps={}
conditions_lc={}
conditions_short={}
conditions_short_caps={}
conditions_short_lc={}
sun_rise={}
sun_rise_lc={}
sun_rise_time={}
sun_rise_24={}
moon_rise={}
moon_rise_lc={}
moon_rise_time={}
moon_rise_24={}
moon_rise_ampm={}
moon_rise_ampm_lc={}
sun_set={}
sun_set_lc={}
sun_set_time={}
sun_set_24={}
moon_set={}
moon_set_lc={}
moon_set_time={}
moon_set_24={}
moon_set_ampm={}
moon_set_ampm_lc={}
humidity={}
precipitation={}
snow={}
cloud_cover={}
moon_phase={}
moon_phase_caps={}
moon_phase_lc={}
moon_font={}
moon_icon={}
wind_mph={}
wind_km={}
wind_kts={}
wind_font={}
wind_icon={}
wind_deg={}
wind_nesw={}
uv_index_num={}
uv_index_txt={}
uv_index_txt_caps={}
uv_index_txt_lc={}
--#########################################################################

--#########################################################################
--get forecast chunk
local a,b,allweather=string.find(allweatherdata,">10 Day Forecast&nbsp(.*)>More from Intellicast</div>")
--extract information into tables
local start=0
local f=1
while f~=nil do
--match forecast day name and date
local s,f,t=string.find(allweather,"<td colspan=\"2\"><strong>([%a,%s%d]*)</strong></td>",start)
	if t~=nil then
	--split name from month and date
	local a,b,day=string.find(t,"(%a*),%s")
	local a,b,month=string.find(t,",%s(%a*)%s")
	local a,b,date=string.find(t,"(%d*)$")
	--ser day names, regular, caps, lowercase and short
	table.insert(forecast_day_short,dayshort[day])
	table.insert(forecast_day_short_caps,string.upper(dayshort[day]))
	table.insert(forecast_day_short_lc,string.lower(dayshort[day]))
		if translate==1 then
		day=daynames[day]
		else
		day=day
		end
	table.insert(forecast_day,day)
	table.insert(forecast_day_caps,string.upper(day))
	table.insert(forecast_day_lc,string.lower(day))
	--set month types
	table.insert(forecast_month_short,monthshort[month])
	table.insert(forecast_month_short_caps,string.upper(monthshort[month]))
	table.insert(forecast_month_short_lc,string.lower(monthshort[month]))
		if translate==1 then
		month=monthnames[month]
		else
		month=month
		end
	table.insert(forecast_month,month)
	table.insert(forecast_month_caps,string.upper(month))
	table.insert(forecast_month_lc,string.lower(month))
	--set date
	table.insert(forecast_date,date)
	end--if t~= nil
--intellicast weather icon match
local s,f,t=string.find(allweather,"40_white/(wx_[%d]*).png\"",start)
--convert to conkyweather icon
	if t~=nil then
	table.insert(weather_icon,weathericons..wimage[t]..".png")
	--convert to weather font
	table.insert(weather_font,wfont[t])
	end
--match conditions
local s,f,t=string.find(allweather," /><br />([%a%s%p]*)</td>",start)
	if t~=nil then
	table.insert(conditions,t)
	table.insert(conditions_caps,string.upper(t))
	table.insert(conditions_lc,string.lower(t))
	--set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	table.insert(conditions_short,cons)
	table.insert(conditions_short_caps,string.upper(cons))
	table.insert(conditions_short_lc,string.lower(cons))
	-----------------------------------------------------
	end
--match high temp
local s,f,t=string.find(allweather,"\"Hi\">([%p%d]*)&deg",start)
table.insert(high_temp,t)
--match low temp
local s,f,t=string.find(allweather,"\"Lo\">([%p%d]*)&deg",start)
table.insert(low_temp,t)
--match sun rise times
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",start)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(sun_rise_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_rise,tm.." "..suf)
	table.insert(sun_rise_lc,string.lower(tm.." "..suf))
	table.insert(sun_rise_time,tm)
	end
--match sun set times
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then	
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(sun_set_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_set,tm.." "..suf)
	table.insert(sun_set_lc,string.lower(tm.." "..suf))
	table.insert(sun_set_time,tm)
	end
--moon rise
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(moon_rise_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_rise,tm.." "..suf)
	table.insert(moon_rise_lc,string.lower(tm.." "..suf))
	table.insert(moon_rise_time,tm)
	table.insert(moon_rise_ampm,suf)
	table.insert(moon_rise_ampm_lc,string.lower(suf))
	end
--moon set
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
table.insert(moon_set_24,convert24(tm,suf))
--###############################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_set,tm.." "..suf)
	table.insert(moon_set_lc,string.lower(tm.." "..suf))
	table.insert(moon_set_time,tm)
	table.insert(moon_set_ampm,suf)
	table.insert(moon_set_ampm_lc,string.lower(suf))
	end
--match uv index
local s,f,tuv=string.find(allweather,"UV Index:</strong>%s*(%d*%s*%([%a%s]*%))%s*<br />",start)
if tuv~=nil then
	--get just number
	local a,b,unm=string.find(tuv,"(%d*)%s*%([%a%s]*%)")
	--get just text
	local a,b,utx=string.find(tuv,"%d*%s*%(([%a%s]*)%)")
	table.insert(uv_index_num,unm)
		if translate==1 then
		utx=uvindextext[utx]
		else
		utx=utx
		end
	table.insert(uv_index_txt,utx)
	table.insert(uv_index_txt_caps,string.upper(utx))
	table.insert(uv_index_txt_lc,string.lower(utx))
	end
--match humidity
local s,f,t=string.find(allweather,"Humidity:</strong> (%d*)<br />",start)
table.insert(humidity,t)
--match ppt
local s,f,t=string.find(allweather,"Precipitation:</strong> (%d*)<br />",start)
table.insert(precipitation,t)
--match snow %
local s,f,t=string.find(allweather,"Snow Probability:</strong>%s*(%d*)<br />",start)
table.insert(snow,t)
--match cloud coveage
local s,f,t=string.find(allweather,"Cloud Coverage:</strong> (%d*)<br />",start)
table.insert(cloud_cover,t)
--match moon phase
local s,f,t=string.find(allweather,"Moon Phase:</strong> ([%a%s]*) <br />",start)
--set moon phase text
	if t~= nil then
	--set moon phase font and icon
	table.insert(moon_font,moonfontt[t])
	table.insert(moon_icon,moonicont[t])
		if translate==1 then
		t=moonphases[t]
		else
		t=t
		end
	table.insert(moon_phase,t)
	table.insert(moon_phase_caps,string.upper(t))
	table.insert(moon_phase_lc,string.lower(t))
	end
--match wind speeds
local s,f,tmph=string.find(allweather,"Wind Speed:</strong> (%d*)Mph",start)
local tmph=tonumber(tmph)
table.insert(wind_mph,tmph)
local s,f,t=string.find(allweather,"Mph%s*%((%d*)Km,",start)
table.insert(wind_km,t)
local s,f,t=string.find(allweather,"Km,%s*(%d*)Kts%)",start)
table.insert(wind_kts,t)
--match wind direction
local s,f,twd=string.find(allweather,"Wind Direction:</strong> ([%d&;%s%(%a%)]*)%s*</div>",start)
	if twd~=nil then
	local a,b,tdeg=string.find(twd,"(%d*)&deg;")
	table.insert(wind_deg,tdeg)
	--match wind font and nesw   
	local a,b,tnesw=string.find(twd,"%((%a*)%)")
	table.insert(wind_font,windfontt[tnesw])
		if tmph>0 and tmph<19 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph>18 and tmph<38 then
		table.insert(wind_icon,weathericons.."yellow_"..string.lower(tnesw)..".png")
		elseif tmph>37 and tmph<64 then
		table.insert(wind_icon,weathericons.."orange_"..string.lower(tnesw)..".png")
		elseif tmph>63 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph==0 then
		table.insert(wind_icon,weathericons.."no_wind.png")
		end
		if translate==1 then
		tnesw=neswtext[tnesw]
		else
		tnesw=tnesw
		end
	table.insert(wind_nesw,tnesw)
	end
if f==nil then break end
start=f
end--while
--#########################################################################################################################################

--#########################################################################
--get location
local a,b,wl=string.find(allweatherdata,"<title>%s*Intellicast%s%p%s(.*)</title>")
weather_location=string.gsub(wl," Extended Forecast in",",")
--#########################################################################

--#########################################################################
--format now weather
--extract current data
--get now weather chunk
local a,b,nowweather=string.find(allweatherdata,">Current Conditions&nbsp(.*)>View Detailed Observations for the last<br />")
now={}
monthlong={Jan="January",Feb="February",Mar="March",Apr="April",May="May",Jun="June",Jul="July",Aug="August",Sep="September",Oct="October",Nov="November",Dec="December"}
local s,f,tnow=string.find(nowweather,"<div style=\"float:right;color:#666;\">  As of ([%d%p%a%s]*) %(Local Time%)")
local s,f,t=string.find(tnow,"(%d*%p%d*%s%a*) on")
--get time only
local a,b,ntm=string.find(t,"(%d*%p%d*)")
--get suffix only
local a,b,suf=string.find(t,"(%u%u)")
--###############################
--24 hour conversion
now["time_24"]=convert24(ntm,suf)
--###############################
if translate==1 then
suf=tsuffix[suf]
else
suf=suf
end
now["time"]=ntm.." "..suf
now["time_lc"]=string.lower(ntm.." "..suf)
now["time_num"]=ntm
now["time_ampm"]=suf
now["time_ampm_lc"]=string.lower(suf)
--get day
local s,f,t=string.find(tnow,"on (%a*)%s%d*")
if translate==1 then
day=daynames[t]
else
day=t
end
now["day"]=day
now["day_caps"]=string.upper(day)
now["day_lc"]=string.lower(day)
--short day names
local ds=dayshort[t]
now["day_short"]=ds
now["day_short_caps"]=string.upper(ds)
now["day_short_lc"]=string.lower(ds)
--get date
local s,f,t=string.find(tnow,"%s(%d%d)%s")
now["date"]=t
--get months
local s,f,t=string.find(tnow,"%d%d%s(%a*)%s%d")
if translate==1 then
mnth=monthlong[t]
now["month_short"]=monthshort[mnth]
now["month_short_caps"]=string.upper(monthshort[mnth])
now["month_short_lc"]=string.lower(monthshort[mnth])
mnth=monthnames[mnth]
else
now["month_short"]=t
now["month_short_caps"]=string.upper(t)
now["month_short_lc"]=string.lower(t)
mnth=monthlong[t]
end
now["month"]=mnth
now["month_caps"]=string.upper(mnth)
now["month_lc"]=string.lower(mnth)
local s,f,t=string.find(tnow,"%a%a%a%s(%d%d%d%d)")
now["year"]=t
local s,f,t=string.find(nowweather,"40_white/(wx_[%d]*)%ppng%p%stitle=%p")
now["weather_icon"]=weathericons..wimage[t]..".png"
now["weather_font"]=wfont[t]
local s,f,t=string.find(nowweather,"class=%pIcon%p /> ([%a%s%p]*)%s*%s*</td>%s*<td class=%pEmpty%p>&nbsp;")
local t=t:gsub("^%s*(.-)%s*$", "%1")
now["conditions"]=t
now["conditions_caps"]=string.upper(t)
now["conditions_lc"]=string.lower(t)
--set short versions------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["conditions_short"]=cons
	now["conditions_short_caps"]=string.upper(cons)
	now["conditions_short_lc"]=string.lower(cons)
--------------------------------------------
local s,f,t=string.find(nowweather,"Temperature\">([%p%d]*)&deg")
now["temp"]=t
local s,f,t=string.find(nowweather,">Feels Like: ([%p%d]*)&deg;</a>")
now["feels_like"]=t
local s,f,t=string.find(nowweather,">Wind Chill: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["wind_chill"]=t
local s,f,t=string.find(nowweather,">Ceiling: </a></td>%s*<td>([%a%d]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tc=t..ceiling_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tc=unlset
end
now["ceiling"]=tc
now["ceiling_caps"]=string.upper(tc)
now["ceiling_lc"]=string.lower(tc)
--get heat index
local s,f,t=string.find(nowweather,">Heat Index: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["heat_index"]=t
--get visibility
local s,f,t=string.find(nowweather,">Visibility: </a></td>%s*<td>([%a%d%p]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tv=t..visibility_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tv=unlset
end
now["visibility"]=tv
now["visibility_caps"]=string.upper(tv)
--get dew point
local s,f,t=string.find(nowweather,">Dew Point: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["dew_point"]=t
--get wind speed
local s,f,t=string.find(nowweather,">Wind: </a></td>%s*<td>(%d*)mph</td>")
local tmph=tonumber(t)
now["wind_mph"]=t..wind_mph_unit
now["wind_mph_caps"]=string.upper(t..wind_mph_unit)
--convert mph to km and knots #################################################
--[[1 mile per hour = 0.869 international nautical mile per hour (knot)
     1 mile per hour = 1.609 kilometers per hour
     1 mile per hour = 0.4470 meter per second
     1 knot = 1.852 kilometers per hour
     1 knot = 0.5144 meter per second
     1 meter per second = 3.6 kilometers per hour]]
now["wind_km"]=round(tonumber(t)*1.609)..wind_km_unit
now["wind_km_caps"]=string.upper(round(tonumber(t)*1.609)..wind_km_unit)
now["wind_kts"]=round(tonumber(t)*0.869)..wind_kts_unit
now["wind_kts_caps"]=string.upper(round(tonumber(t)*0.869)..wind_kts_unit)
--#############################################################################
local s,f,t=string.find(nowweather,">Humidity: </a></td>%s*<td>(%d*)</td>")
now["humidity"]=t
--get wind direction #######################################################
local s,f,twd=string.find(nowweather,">Direction: </a></td>%s*<td style=[%p%a]*>([%d&;%s%(%a%)]*)</td>%s*</tr>")
--check for NA
local a,b,t=string.find(twd,"(%a*)")
local tnesw=t
if tnesw~="NA" then
local a,b,t=string.find(twd,"(%d*)&deg;")
now["wind_deg"]=t..wind_degrees_unit
local a,b,tnesw=string.find(twd,"%((%a*)%)")
	if tmph>0 and tmph<19 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	elseif tmph>18 and tmph<38 then
	now["wind_icon"]=weathericons.."yellow_"..string.lower(tnesw)..".png"
	elseif tmph>37 and tmph<64 then
	now["wind_icon"]=weathericons.."orange_"..string.lower(tnesw)..".png"
	elseif tmph>63 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	end
now["wind_font"]=windfontt[tnesw]
--################################
	if translate==1 then
	tnesw=neswtext[tnesw]
	else
	tnesw=tnesw
	end
--################################
now["wind_nesw"]=tnesw		
else
	if translate==1 then naset=additional.NA else naset="NA" end
now["wind_deg"]=naset
now["wind_icon"]=weathericons.."no_wind.png"
now["wind_nesw"]=naset
now["wind_font"]=windfontt["N"]
end
--END WIND DIRECTION #######################################################
--get pressure
local s,f,t=string.find(nowweather,">Pressure: </a></td>%s*<td>([%d%p]*)\"</td>")
now["pressure"]=t
--convert pressures ########################################################
--[[ 1 inch of mercury = 25.4 mm of mercury = 33.86 millibars
     = 33.86 hectoPascals]]
now["pressure_mb"]=round(tonumber(t)*33.86)
--##########################################################################
local s,f,t=string.find(nowweather,">Gusts: </a></td>%s*<td>([%d%a]*)</td>")
if t~="NA" then
local s,f,t=string.find(t,"(%d*)")
tg=t..wind_mph_unit
tgkm=round(tonumber(t)*1.609)..wind_km_unit
tgkts=round(tonumber(t)*0.869)..wind_kts_unit
else
	if translate==1 then naset=additional.NA else naset="NA" end
tg=naset
tgkm=naset
tgkts=naset
end
now["wind_gusts"]=tg
now["wind_gusts_caps"]=string.upper(tg)
now["wind_gusts_km"]=tgkm
now["wind_gusts_km_caps"]=string.upper(tgkm)
now["wind_gusts_kts"]=tgkts
now["wind_gusts_kts_caps"]=string.upper(tgkts)
--##########################################################################
--get hourly forecast options hour1--------------------
--get day 1 bit
local s,f,hfc=string.find(nowweather,"<td class=%pHour%p%sstyle=%ppadding%pleft([%a%d%p%s]*)%pdeg%p</strong>",1)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",1)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",1)
--24 hour conversion ######################
now["fc_hour1_time_24"]=convert24(tm,suf)
--#########################################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour1_time"]=tm
now["fc_hour1_ampm"]=suf
now["fc_hour1_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%p%s%a]*)%s*</td>%s*<td class=%pHour%p",1)
now["fc_hour1_cond"]=t
now["fc_hour1_cond_lc"]=string.lower(t)
now["fc_hour1_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour1_cond_short"]=cons
	now["fc_hour1_cond_short_caps"]=string.upper(cons)
	now["fc_hour1_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",1)
now["fc_hour1_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour1_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",1)
now["fc_hour1_temp"]=t
--end of hour1 data gathering--repeat 2 more times
--get hourly forecast options hour2--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion ######################
now["fc_hour2_time_24"]=convert24(tm,suf)
--#########################################	
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour2_time"]=tm
now["fc_hour2_ampm"]=suf
now["fc_hour2_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour2_cond"]=t
now["fc_hour2_cond_lc"]=string.lower(t)
now["fc_hour2_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour2_cond_short"]=cons
	now["fc_hour2_cond_short_caps"]=string.upper(cons)
	now["fc_hour2_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour2_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour2_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",start)
now["fc_hour2_temp"]=t
--end of hour2 data gathering--repeat 1 more times
--get hourly forecast options hour3--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion ######################
now["fc_hour3_time_24"]=convert24(tm,suf)
--#########################################
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour3_time"]=tm
now["fc_hour3_ampm"]=suf
now["fc_hour3_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour3_cond"]=t
now["fc_hour3_cond_lc"]=string.lower(t)
now["fc_hour3_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour3_cond_short"]=cons
	now["fc_hour3_cond_short_caps"]=string.upper(cons)
	now["fc_hour3_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour3_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour3_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)",start)
now["fc_hour3_temp"]=t
--end of hour3 data gathering--finished for all hours
--ALERTS###############################################################
if alert_check==1 then
--set tables
alert_type={}
alert_issued={}
if alerttest~=0 then
alert_icon=weathericons.."icon_alert_1.gif"
--extract information into tables
local start=0
local f=1
while f~=nil do
local s,f,t=string.find(alertdata,"><strong class='Alert'>([%a%s]*)</strong><br/>",start)
	if t~=nil then
	table.insert(alert_type,string.upper(t))
	end--if t~=nil
local s,f,t=string.find(alertdata,"<br />([%d%a%s:]*)<br /><br />",start)
	if t~=nil then
	table.insert(alert_issued,t)
	end--if t~=nil
if f==nil then break end
start=f
alert_number=#alert_type
end--while
else
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"NO ALERTS")
table.insert(alert_issued,"")
alert_number=0
end--alerttest~=nil
else
alert_type={}
alert_issued={}
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"alerts turned off")
table.insert(alert_issued,"")
alert_number=0
end--if alert check ###########################################
--###############end of data processing########################

--#########################################################################
if testing==0 then
processall=0
print ("processing complete")
elseif testing==1 then
processall=1
end--if testing ==0
--###################################################################################
end--of data processing section #####################################################
--###################################################################################
if processall==0 or testing==1 then
_G.weather_script()
end
--#########################################################################################################
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--end--####### end of if updates>5 #############################
--#########################################################################################################

cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--######################################
end-- end main function ################
--######################################
function round(num)
	local idp=tonumber(settings_table[5])
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end--of round function #################################################################
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--string split #######################################################################


function xout(txj)--c,a,f,fs,x,y,txt,j ##################################################
c=nil
c=(txj.c or default_color)
a=nil
a=(txj.a or default_alpha)
f=nil
f=(txj.f or default_font)
fs=nil
fs=(txj.fs or default_font_size)
x=nil
x=(txj.x or 0)
y=nil
y=(txj.y or 0)
txt=nil
txt=(txj.txt or "set txt")
j=nil
j=(txj.j or "l")
-- ###############################################
local cs=txj.cs     or default_size         or "normal_c"
	local format=txj.format					or default_format			or "normal"
	local ul=txj.ul     or default_ul         or "no"
	local shaded=txj.shaded				or default_shaded		or "no"


	local function col(c,a)
	return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
	end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local text=string.gsub(txt," ","_")
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local wx=extents.width
if j=="l" then
cairo_move_to (cr,x,y)
adx=wx
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
adx=wx/2
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
adx=0
end

	--set face
	if format=="normal" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	elseif format=="bold" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
	elseif format=="italic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
	elseif format=="bolditalic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
	else
		print ('format not set correctly - "normal","bold","italic","bolditalic"')
	end

-- set size of letters
if cs=="big_c" then
txt=string.upper(txt)
elseif cs=="small_c" then
txt=string.lower(txt)
elseif cs=="normal_c" then
txt=txt
else
print ('size not set correctly - "normal_c","big_c","small_c"')
end
----------------------
	if ul=="yes" then
		lw=1
		lc=CAIRO_LINE_CAP_BUTT
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE)

		startx=x
		endx=startx+wx
		starty=y+5
		endy=y+5

		----------------------------
		cairo_set_line_width (cr,lw)
		cairo_set_line_cap  (cr, lc)
		cairo_set_source_rgba (cr,col(c,a))

		cairo_show_text (cr,txt)
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wx,endy)
		cairo_stroke (cr)
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) 
	elseif ul == "no" then
		txt=txt
	else
		print ("underline not set right")
	end --# if if ul=="yes" then

	if shaded == "yes" then
		sc=0x000000
		sa=1
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,col(sc,sa))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	elseif shaded=="no" then
	txt=txt
	end

-- ################################################################
cairo_move_to (cr,(x),(y))
cairo_set_source_rgba (cr,col(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
nextx=nil
nextx=adx+x
return nextx
end--function xout ###################################################################

-- ###### function out ########################################################################

function out(txj)--c,a,f,fs,face,x,y,txt,hj,vj,size,underline ##################################################
	local extents=cairo_text_extents_t:create()
	tolua.takeownership(extents)
	--#########################################################################################################
	local function color(col,alp)
		return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
	end
	--#########################################################################################################
	local c=txj.c						or default_color		or 0xffffff
	local a=txj.a						or default_alpha		or 1
	local f=txj.f						or default_font			or "mono"
	local fs=txj.fs						or default_font_size	or 12
	local x=txj.x						or 100
	local y=txj.y						or 100
	local txt=txj.txt					or "set txt"
	local hj=txj.hj						or default_hj			or "l"
	local vj=txj.vj						or default_vj			or "n"
	local face=txj.face					or default_face			or "normal"
	local size=txj.size     or default_size         or "normal_c"
	--################ ADD SHADES ###########################################
	local shaded=txj.shaded				or default_shaded		or "no" --## shades are drawn if shaded="yes"
	local shade_color=txj.shade_color	or default_shade_color	or 0x000000
	local shade_alpha=txj.shade_alpha	or default_shade_alpha	or 1
	--#######################################################################
	local underline=txj.underline     or default_underline         or "no"
	local line_color=txj.line_color    or   default_line_color   or   c
	local line_space=txj.line_space    or default_line_space   or  5
	local line_width=txj.line_width     or default_line_width   or  1
--############################################################
	--set face
	if face=="normal" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	elseif face=="bold" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
	elseif face=="italic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
	elseif face=="bolditalic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
	else
		print ('face not set correctly - "normal","bold","italic","bolditalic"')
	end
	-- set size of letters
	if size=="big_c" then
	txt=string.upper(txt)
	elseif size=="small_c" then
	txt=string.lower(txt)
	elseif size=="normal_c" then
	txt=txt
	else
	print ('size not set correctly - "normal_c","big_c","small_c"')
	end
	----------------------
	cairo_set_font_size (cr, fs)
	cairo_text_extents(cr,txt,extents)
	local wx=extents.x_advance
	local wd=extents.width
	local hy=extents.height
	local bx=extents.x_bearing
	local by=extents.y_bearing+hy
	local tx=x
	local ty=y
	--set horizontal alignment - l, c, r
	if hj=="l" then
		x=x-bx
	elseif hj=="c" then
		x=x-((wx-bx)/2)-bx
	elseif hj=="r" then
		x=x-wx
	else
		print ("hj not set correctly - l, c, r")
	end
	--vj. n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
	if vj=="n" then
		y=y
	elseif vj=="nb" then
		y=y-by
	elseif vj=="m" then
		y=y+((hy-by)/2)
	elseif vj=="mb" then
		y=y+(hy/2)-by
	elseif vj=="t" then
		y=y+hy-by
	else
		print ("vj not set correctly - n, nb, m, mb, t")
	end

	if shaded == "yes" then
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,color(shade_color,shade_alpha))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	end --# if shaded == "yes" then

	cairo_move_to (cr,x,y)
	cairo_set_source_rgba (cr,color(c,a))
	cairo_show_text (cr,txt)
	cairo_stroke (cr)

	if underline=="yes" then
		line_cap=CAIRO_LINE_CAP_BUTT
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE)

		startx=x
		endx=startx+wd
		starty=y+line_space
		endy=y+line_space

		cairo_set_line_width (cr,line_width)
		cairo_set_line_cap  (cr, line_cap)
		cairo_set_source_rgba (cr,color(line_color,a))
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wd,endy)
		cairo_stroke (cr)
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) --# reset antialiasing so we don't screw up other code
	elseif underline == "no" then
	txt=txt
	else	
	print ("underline not set right")
	end
-- ##############################################################
end--function out ###################################################################

-- ###################################################################

function image(im)--#################################################################
x=nil
x=(im.x or 0)
y=nil
y=(im.y or 0)
w=nil
w=(im.w or default_image_width)
h=nil
h=(im.h or default_image_height)
file=nil
file=tostring(im.file)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(w)
end
if tonumber(h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x, y)
imlib_free_image()
show=nil
end--function image ##################################################################
function convert24(tm,suf)
local tmlen=string.len(tm)
local colon=string.find(tm,":")
	if colon~=nil then
	tmhr=string.sub(tm,1,colon-1)
	tmmn=string.sub(tm,colon+1,tmlen)
	else
	tmhr=tm
	tmmn=""
	end
if suf=="PM" and tonumber(tmhr)~=12 then
tmhr=tmhr+12
elseif suf=="PM" and tonumber(tmhr)==12  then
tmhr=12
elseif suf=="AM" and tonumber(tmhr)<10 then
tmhr="0"..tmhr
elseif suf=="AM" and tonumber(tmhr)>=10 and tonumber(tmhr)~=12 then
tmhr=tmhr
elseif suf=="AM" and tonumber(tmhr)==12 then
tmhr="00"
end
if colon~=nil then
return tmhr..":"..tmmn
else
return tmhr
end--if colon~=nil
end--of function
--END OF SCRIPT

the default-color for the line is the same like the color of the text.

underline="yes"

but u also can define another color for this line, for example like this:

line_color=0xff0000

or u can define a bigger space between the word an the line:

line_space=20

the default value for this space is 5.

this is a screenshot to show the new features:

2012_12_27_112221_800x480_scrot.jpg

as u can see the shadow improves the contrast. if u use shaded text then u can even see yellow text on a yellow background smile

the new update doesn't have an effect to existing templates!!! i also updated the function xout. the onliner at the bottom of my screenshot only contains calls of this function!


v9000 is working but if u see something to improve it then feel free to post it smile



edit: i've updated the function xout a bit. this function uses the same functions .but xout only acts as a 'light-version' of the function out. in the upcoming weeks i will add some more features to this function.

the call of the different features are a bit different:

add this if u want to underline words:

ul="yes"

the function xout only supports the color black as the color for the line below the text smile

add this if u want to use shaded text:

shaded="yes" 

the function xout only supports the color black as the color for the shadow smile

add this if u want to change the size of the words (characters):

cs="small_c" 
cs="big_c"

this is the standard-setting. you do not have to use this if u ue the standard-size.

cs="normal_c"

if u want to use another format, add this:

italic characters

format="italic"

bold characters

format="bold"

bolditalic format

format="bolditalic"

this is the standard-setting. you do not have to use this if u use the standard-format.

format="normal"

big thank you to use arclance. he helped me to add the feature to draw the shadow.

remember: when u use the feature 'shadow' you even can display yellow colored text on top of a yellow background! the shadow increases the contrast.

this is an example of usage of xout (first two words):

xout({x=0,y=ypos,c=0xffff00,f="mono",fs=10,ul="yes",format="italic",shaded="yes",txt=now["conditions_short_lc"]})

abqoQx79.png

most of the features are useful if u want to format your conky-output!

u can use it like this:

local actual_time=conky_parse('${time %k:%M:%S}')
({x=posx_2,y=25,c=hell,f="mono",fs=10,shaded="yes",line_color=0xff0000,underline="no",face="italic",txt=actual_time,hj='r'})

as u can see in the screenshot i'm using a function to convert numbers into words:

function n2w(number)
number=tonumber(number)
local n_len=string.len(number)
if number<0 then
number=tonumber(string.sub(number,2,n_len))
minus="minus "
else
number=number
minus=""
end
if number>99 then
h=tonumber(string.sub(number,1,1))
tu=tonumber(string.sub(number,2,3))
t=tonumber(string.sub(number,2,2))
u=tonumber(string.sub(number,3,3))
elseif number<100 then
tu=number
t=tonumber(string.sub(number,1,1))
u=tonumber(string.sub(number,2,2))
end
n1_tab={"eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn",}
n2_tab={"zehn","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"}
if number>0 then n0="" else n0="null" end
if tu<20 and tu~=10 and tu~=0 then 
	ausgabe=n1_tab[tu]
elseif tu==10 then
	ausgabe="zehn"
elseif tu==0 then
	ausgabe="null"
elseif tu>19 then
	if u>0 then 
	joinu=" " 
	u=n1_tab[u]
	else 
	joinu=""
	u=""
	end
	g=string.sub(number,2,2)
--	out=joinu..'lang:'..tu..' geschn.: '..g..' '..n2_tab[t]..'('..string.sub(tu,1,1)..','..string.sub(tu,2,2)..')'
	ausgabe=international(tu,g,n2_tab[t])
--	out=n2_tab[t]..joinu..u -- original
end
if number>99 and number~=100 then
	h=n1_tab[h]
	return minus..h.." hundred and "..ausgabe
elseif number==100 then
	return "einhundert"
elseif number<100 then
	return minus..ausgabe
end
end--function

function international(lang,geschnitten,wort)

local anzahl=tonumber(lang) -- ganze zahl, z.b. 21
local kurzezahl=tonumber(geschnitten) -- letzte zahl, z.b. 1 von 21

if kurzezahl==1 or anzahl==1 then

 if string.len(anzahl)>1  then
 nummer='einund'..n2_tab[t]     -- gives me for example 21, 31 etc
 elseif string.len(anzahl)==1 then
 nummer='eins'			           -- gives me the number 1
 end

elseif kurzezahl~=1 or anzahl ~=1 then

   if anzahl==0 then
   nummer=wort                                     -- should give me the word 'null' (zero)
   elseif tonumber(string.sub(anzahl,1,1)) and tonumber(string.sub(anzahl,2,2))==0 then   --
   nummer=wort                                     -- gives me numbers like 10,20,30 etc.
--   elseif anzahl<0 then
--     nummer=minus..' '..wort
   else 
    nummer=n2w(kurzezahl)..'und'..wort         --  gives me such numbers like 22,23,24 etc.
    end

end

return nummer

end -- der fun ktion

and this way you can call this function:

xout({x=150,y=ypos,c=hell,f="mono",fs=10,format="italic",shaded="yes",txt=n2w(now["temp"])..' grad'})

this version of v9000 is already tested with my templates. but feel free to test with your existing template! i need some feedback (positive or negative) smile

Moderator Edit - Image Resize - VastOne

----------------------------------------------------------------------------------------------------------------------------
Please use thumbnails (please try to avoid the large thumbnail imgur.com code) linking to the larger image to help those of us with slow connections. An example of the code needed is below. Most image hosting sites will automatically generate this for you as well. Users have been using postimage.org lately which does a nice job.

[url=http://link.to.your.fullsized.image][img]http://link.to.your.thumbnail.image[/img][/url]

Last edited by lionhead (2013-01-06 10:40:11)

Offline

#870 2013-01-18 11:41:29

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 456

Re: weather in conky (LUA scripts) updated 12/26/13!

i included the possibility to display an external image within lua. you do not need an extra-file to grab the image. you fully can work within lua. now u can decorate the external image with the weather of each image :)

external image means that u can grab for example the image of a webcam or the current position of the iss :)

you can call the function like this:

extern({posx=800,posy=200,imgw=195,imgh=195,imgurl="http://antarctica.martingrund.de/ohig-pingi-z.jpg",imghdd="pinguin.jpg",imgiv=60})

you can define the horizontal position with this parameter:

posx=123

you do not have to use this parameter if the horizontal position is zero. this is because the default value!

you can define the vertical position with this parameter:

posy=123

you do not have to use this parameter if the vertical position is zero. because this is the default value!

surely you can define the width and the height of the image. you can set the value for the width like this:

imgw=300

you can define the height of the image like this:

imgh=300

the default value for the width and the height is 200. you do not have to define this when you use the value twohundred.

the next variable is the url of the webcam. this value is really important:

imgurl='http://www.eso.org/public/webcams/vlt.jpg'

the grabbed image will be stored in the home-directory of the user, for example /home/alexander/

you can define the name of the grabbed image. if u only want to use one webcam then u do not have to define a name. the name of the image is 'dei.jpg'. the whole path: /home/yourname/dei.jpg

the name 'dei' means display external image :)

here is an example how you can define the name:

imghdd='vlt.jpg'

some external images  actualize every second (for example). in this case u can define the intervall (when the script grabs a newer version of the image):

imgiv=20

the default value for the intervall is sixty. this means that a newer version of the image will be grabbed after a minute.

the order / sequence of the parameters is equal. the main point is that you define all parameters you need!

here is the code:

-- weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
-- official update by mrpeachy
-- additional features by lionhead, arclance and dk75
-- format text (underline, shadow, big characters, low characters)
-- parse conky variables, chg file extension, add decimal,
-- you can load external images, month2number, drop leading characters, 
-- hubble picture of the week, nasa image of the day
-- last update 21.03.2013
require 'cairo'
require 'imlib2'
local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"
local username = "alexander"
package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

start=1
--INITIALIZE SETTINGS-- need only be run once
settings_table=weather_settings()
--##################################
--######## main function ########### 
function conky_weather()--##########
-- function to convert color into hex-code
function col(c,a)
return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
end--local function

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}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]
print ("gathering data with curl")
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section
--in case curl craps up it should retry until it works
if testall==nil or  alerttest==nil then
print ("curl attempt timed out, trying again")
local web=settings_table[2]
local alert_check=settings_table[13]
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert_check
processall=1
end--if testall==nil
--end or curl reruns
--START PROCESSING ###########################################################################
if testall~=nil and alerttest~=nil and processall==1 then
local weathericons=settings_table[3]
local con_short=settings_table[4]
local visibility_unit=settings_table[6]
local wind_mph_unit=settings_table[7]
local wind_km_unit=settings_table[8]
local wind_kts_unit=settings_table[9]
local ceiling_unit=settings_table[10]
local wind_degrees_unit=settings_table[11]
local translate=settings_table[12]
local alert_check=settings_table[13]
--LOAD TRANSLATE TABLES IF TRANSLATE SETTING = 1
	if translate==1 then
	monthshort=settings_table[21]
	monthnames=settings_table[20]
	dayhort=settings_table[19]
	daynames=settings_table[18]
	neswtext=settings_table[14]
	tsuffix=settings_table[15]
	uvindextext=settings_table[16]
	moonphases=settings_table[17]
	additional=settings_table[22]
	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort

	dayshort={Monday="Mon",Tuesday="Tue",Wednesday="Wed",Thursday="Thu",Friday="Fri",Saturday="Sat",Sunday="Sun"}
	monthshort={January="Jan",February="Feb",March="Mar",April="Apr",May="May",June="Jun",July="Jul",August="Aug",September="Sep",October="Oct",November="Nov",December="Dec"}
	end--end if translate =1
--process data tables
--intellicast to conky weather icon conversion
wimage={
wx_65="32",  -- Clear
wx_66="30",  -- Partly Cloudy
wx_67="26",  -- Cloudy
wx_68="32",  -- Clear
wx_69="28",  -- Mostly Cloudy
wx_70="20",  -- Fog
wx_71="32",  -- Clear
wx_72="21",  -- Haze
wx_73="36",  -- Hot
wx_74="14",  -- Light Snow Showers
wx_75="28",  -- Mostly Cloudy
wx_76="18",  -- Sleet
wx_77="14",  -- Light Snow Showers
wx_78="23",  -- Blustery
wx_79="05",  -- Mixed Rain and Snow
wx_80="15",  -- Drifting Snow
wx_81="15",  -- Drifting Snow
wx_82="11",  -- Light Rain
wx_83="16",  -- Snow
wx_84="00",  -- Tornado
wx_85="32",  -- Clear
wx_86="25",  -- N/A
wx_87="09",  -- Drizzle
wx_88="05",  -- Mixed Rain and Snow
wx_89="18",  -- Sleet
wx_90="18",  -- Sleet
wx_91="39",  -- Scattered Showers
wx_92="39",  -- Scattered Showers
wx_93="39",  -- Scattered Showers
wx_94="39",  -- Scattered Showers
wx_95="37",  -- Isolated Thunderstorms
wx_96="37",  -- Isolated Thunderstorms
wx_97="31",  -- Clear
wx_98="29",  -- Partly Cloudy
wx_99="27",  -- Mostly Cloudy
wx_100="47",  -- Isolated Thunderstorms
wx_101="47",  -- Isolated Thunderstorms
wx_102="33",  -- Fair
wx_103="26",  -- Cloudy
wx_104="20",  -- Fog
wx_105="45",  -- Scattered Showers
wx_106="45",  -- Scattered Showers
wx_107="11",  -- Light Rain
wx_108="46",  -- Snow Showers
wx_109="46",  -- Snow Showers
wx_110="06",  -- Mixed Rain and Sleet
wx_111="18",  -- Sleet
wx_112="06",  -- Mixed Rain and Sleet
wx_113="46",  -- Snow Showers
wx_114="46",  -- Snow Showers
wx_115="31",  -- Clear
wx_116="47",  -- Isolated Thunderstorms
}--end w image table
--convert intellicast icons to weather font
wfont={
wx_65="a",
wx_66="c",
wx_67="f",
wx_68="a",
wx_69="d",
wx_70="0",
wx_71="a",
wx_72="9",
wx_73="5",
wx_74="p",
wx_75="d",
wx_76="w",
wx_77="p",
wx_78="6",
wx_79="x",
wx_80="8",
wx_81="8",
wx_82="h",
wx_83="q",
wx_84="m",
wx_85="a",
wx_86="-",
wx_87="h",
wx_88="x",
wx_89="w",
wx_90="w",
wx_91="g",
wx_92="g",
wx_93="g",
wx_94="g",
wx_95="k",
wx_96="k",
wx_97="A",
wx_98="C",
wx_99="D",
wx_100="K",
wx_101="K",
wx_102="B",
wx_103="f",
wx_104="0",
wx_105="G",
wx_106="G",
wx_107="h",
wx_108="O",
wx_109="O",
wx_110="x",
wx_111="w",
wx_112="x",
wx_113="O",
wx_114="O",
wx_115="A",
wx_116="K",
}--end w font table
--conversion day and month tables
moonfontt={
["New"]="@",
["Full"]="=",
["First Quarter"]="T",
["Last Quarter"]="G",
["Waning Gibbous"]="D",
["Waning Crescent"]="J",
["Waxing Crescent"]="Q",
["Waxing Gibbous"]="W",
}--end of moon font table
moonicont={
["New"]=weathericons.."moon_new.png",
["Full"]=weathericons.."moon_full.png",
["First Quarter"]=weathericons.."moon_first_quarter.png",
["Last Quarter"]=weathericons.."moon_last_quarter.png",
["Waning Gibbous"]=weathericons.."moon_waning_gibbous.png",
["Waning Crescent"]=weathericons.."moon_waning_crescent.png",
["Waxing Crescent"]=weathericons.."moon_waxing_crescent.png",
["Waxing Gibbous"]=weathericons.."moon_waxing_gibbous.png",
}--end of moon icon table
windfontt={
S="9",
SSW=":",
SW=";",
WSW="<",
W="=",
WNW=">",
NW="?",
NNW="@",
N="1",
NNE="2",
NE="3",
ENE="4",
E="5",
ESE="6",
SE="7",
SSE="8"
}--end of wind direction font table
--setup tables for forecast weather
forecast_day={}
forecast_day_caps={}
forecast_day_lc={}
forecast_day_short={}
forecast_day_short_caps={}
forecast_day_short_lc={}
forecast_month={}
forecast_month_caps={}
forecast_month_lc={}
forecast_month_short={}
forecast_month_short_caps={}
forecast_month_short_lc={}
forecast_date={}
weather_icon={}
weather_font={}
high_temp={}
low_temp={}
conditions={}
conditions_caps={}
conditions_lc={}
conditions_short={}
conditions_short_caps={}
conditions_short_lc={}
sun_rise={}
sun_rise_lc={}
sun_rise_time={}
sun_rise_24={}
moon_rise={}
moon_rise_lc={}
moon_rise_time={}
moon_rise_24={}
moon_rise_ampm={}
moon_rise_ampm_lc={}
sun_set={}
sun_set_lc={}
sun_set_time={}
sun_set_24={}
moon_set={}
moon_set_lc={}
moon_set_time={}
moon_set_24={}
moon_set_ampm={}
moon_set_ampm_lc={}
humidity={}
precipitation={}
snow={}
cloud_cover={}
moon_phase={}
moon_phase_caps={}
moon_phase_lc={}
moon_font={}
moon_icon={}
wind_mph={}
wind_km={}
wind_kts={}
wind_font={}
wind_icon={}
wind_deg={}
wind_nesw={}
uv_index_num={}
uv_index_txt={}
uv_index_txt_caps={}
uv_index_txt_lc={}
--get forecast chunk --------------------------------------------------------
local a,b,allweather=string.find(allweatherdata,">10 Day Forecast&nbsp(.*)>More from Intellicast</div>")
--extract information into tables
local start=0
local f=1
while f~=nil do
--match forecast day name and date
local s,f,t=string.find(allweather,"<td colspan=\"2\"><strong>([%a,%s%d]*)</strong></td>",start)
	if t~=nil then
	--split name from month and date
	local a,b,day=string.find(t,"(%a*),%s")
	local a,b,month=string.find(t,",%s(%a*)%s")
	local a,b,date=string.find(t,"(%d*)$")
	--set day names, regular, caps, lowercase and short
	table.insert(forecast_day_short,dayshort[day])
	table.insert(forecast_day_short_caps,string.upper(dayshort[day]))
	table.insert(forecast_day_short_lc,string.lower(dayshort[day]))
		if translate==1 then
		day=daynames[day]
		else
		day=day
		end
	table.insert(forecast_day,day)
	table.insert(forecast_day_caps,string.upper(day))
	table.insert(forecast_day_lc,string.lower(day))
	--set month types
	table.insert(forecast_month_short,monthshort[month])
	table.insert(forecast_month_short_caps,string.upper(monthshort[month]))
	table.insert(forecast_month_short_lc,string.lower(monthshort[month]))
		if translate==1 then
		month=monthnames[month]
		else
		month=month
		end
	table.insert(forecast_month,month)
	table.insert(forecast_month_caps,string.upper(month))
	table.insert(forecast_month_lc,string.lower(month))
	--set date
	table.insert(forecast_date,date)
	end--if t~= nil
--intellicast weather icon match
local s,f,t=string.find(allweather,"40_white/(wx_[%d]*).png\"",start)
--convert to conkyweather icon
	if t~=nil then
	table.insert(weather_icon,weathericons..wimage[t]..".png")
	--convert to weather font
	table.insert(weather_font,wfont[t])
	end
--match conditions
local s,f,t=string.find(allweather," /><br />([%a%s%p]*)</td>",start)
	if t~=nil then
	table.insert(conditions,t)
	table.insert(conditions_caps,string.upper(t))
	table.insert(conditions_lc,string.lower(t))
	--set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	----------------------------------------------------
	table.insert(conditions_short,cons)
	table.insert(conditions_short_caps,string.upper(cons))
	table.insert(conditions_short_lc,string.lower(cons))
	end
--match high temp
local s,f,t=string.find(allweather,"\"Hi\">([%p%d]*)&deg",start)
table.insert(high_temp,t)
--match low temp
local s,f,t=string.find(allweather,"\"Lo\">([%p%d]*)&deg",start)
table.insert(low_temp,t)
--match sun rise times
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",start)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--24 hour conversion
table.insert(sun_rise_24,convert24(tm,suf))
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_rise,tm.." "..suf)
	table.insert(sun_rise_lc,string.lower(tm.." "..suf))
	table.insert(sun_rise_time,tm)
	end
--match sun set times
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then	
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--24 hour conversion
table.insert(sun_set_24,convert24(tm,suf))
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_set,tm.." "..suf)
	table.insert(sun_set_lc,string.lower(tm.." "..suf))
	table.insert(sun_set_time,tm)
	end
--moon rise
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--24 hour conversion
table.insert(moon_rise_24,convert24(tm,suf))
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_rise,tm.." "..suf)
	table.insert(moon_rise_lc,string.lower(tm.." "..suf))
	table.insert(moon_rise_time,tm)
	table.insert(moon_rise_ampm,suf)
	table.insert(moon_rise_ampm_lc,string.lower(suf))
	end
--moon set
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
--24 hour conversion
table.insert(moon_set_24,convert24(tm,suf))
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_set,tm.." "..suf)
	table.insert(moon_set_lc,string.lower(tm.." "..suf))
	table.insert(moon_set_time,tm)
	table.insert(moon_set_ampm,suf)
	table.insert(moon_set_ampm_lc,string.lower(suf))
	end
--match uv index
local s,f,tuv=string.find(allweather,"UV Index:</strong>%s*(%d*%s*%([%a%s]*%))%s*<br />",start)
if tuv~=nil then
	--get just number
	local a,b,unm=string.find(tuv,"(%d*)%s*%([%a%s]*%)")
	--get just text
	local a,b,utx=string.find(tuv,"%d*%s*%(([%a%s]*)%)")
	table.insert(uv_index_num,unm)
		if translate==1 then
		utx=uvindextext[utx]
		else
		utx=utx
		end
	table.insert(uv_index_txt,utx)
	table.insert(uv_index_txt_caps,string.upper(utx))
	table.insert(uv_index_txt_lc,string.lower(utx))
	end
--match humidity
local s,f,t=string.find(allweather,"Humidity:</strong> (%d*)<br />",start)
table.insert(humidity,t)
--match ppt
local s,f,t=string.find(allweather,"Precipitation:</strong> (%d*)<br />",start)
table.insert(precipitation,t)
--match snow %
local s,f,t=string.find(allweather,"Snow Probability:</strong>%s*(%d*)<br />",start)
table.insert(snow,t)
--match cloud coverage
local s,f,t=string.find(allweather,"Cloud Coverage:</strong> (%d*)<br />",start)
table.insert(cloud_cover,t)
--match moon phase
local s,f,t=string.find(allweather,"Moon Phase:</strong> ([%a%s]*) <br />",start)
--set moon phase text
	if t~= nil then
	--set moon phase font and icon
	table.insert(moon_font,moonfontt[t])
	table.insert(moon_icon,moonicont[t])
		if translate==1 then
		t=moonphases[t]
		else
		t=t
		end
	table.insert(moon_phase,t)
	table.insert(moon_phase_caps,string.upper(t))
	table.insert(moon_phase_lc,string.lower(t))
	end
--match wind speeds
local s,f,tmph=string.find(allweather,"Wind Speed:</strong> (%d*)Mph",start)
local tmph=tonumber(tmph)
table.insert(wind_mph,tmph)
local s,f,t=string.find(allweather,"Mph%s*%((%d*)Km,",start)
table.insert(wind_km,t)
local s,f,t=string.find(allweather,"Km,%s*(%d*)Kts%)",start)
table.insert(wind_kts,t)
--match wind direction
local s,f,twd=string.find(allweather,"Wind Direction:</strong> ([%d&;%s%(%a%)]*)%s*</div>",start)
	if twd~=nil then
	local a,b,tdeg=string.find(twd,"(%d*)&deg;")
	table.insert(wind_deg,tdeg)
	--match wind font and nesw   
	local a,b,tnesw=string.find(twd,"%((%a*)%)")
	table.insert(wind_font,windfontt[tnesw])
		if tmph>0 and tmph<19 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph>18 and tmph<38 then
		table.insert(wind_icon,weathericons.."yellow_"..string.lower(tnesw)..".png")
		elseif tmph>37 and tmph<64 then
		table.insert(wind_icon,weathericons.."orange_"..string.lower(tnesw)..".png")
		elseif tmph>63 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph==0 then
		table.insert(wind_icon,weathericons.."no_wind.png")
		end
		if translate==1 then
		tnesw=neswtext[tnesw]
		else
		tnesw=tnesw
		end
	table.insert(wind_nesw,tnesw)
	end
if f==nil then break end
start=f
end--while
--get location
local a,b,wl=string.find(allweatherdata,"<title>%s*Intellicast%s%p%s(.*)</title>")
weather_location=string.gsub(wl," Extended Forecast in",",")
--format now weather
--extract current data
--get now weather chunk
local a,b,nowweather=string.find(allweatherdata,">Current Conditions&nbsp(.*)>View Detailed Observations for the last<br />")
now={}
monthlong={Jan="January",Feb="February",Mar="March",Apr="April",May="May",Jun="June",Jul="July",Aug="August",Sep="September",Oct="October",Nov="November",Dec="December"}
local s,f,tnow=string.find(nowweather,"<div style=\"float:right;color:#666;\">  As of ([%d%p%a%s]*) %(Local Time%)")
local s,f,t=string.find(tnow,"(%d*%p%d*%s%a*) on")
--get time only
local a,b,ntm=string.find(t,"(%d*%p%d*)")
--get suffix only
local a,b,suf=string.find(t,"(%u%u)")
--24 hour conversion
now["time_24"]=convert24(ntm,suf)
if translate==1 then
suf=tsuffix[suf]
else
suf=suf
end
now["time"]=ntm.." "..suf
now["time_lc"]=string.lower(ntm.." "..suf)
now["time_num"]=ntm
now["time_ampm"]=suf
now["time_ampm_lc"]=string.lower(suf)
--get day
local s,f,t=string.find(tnow,"on (%a*)%s%d*")
if translate==1 then
day=daynames[t]
else
day=t
end
now["day"]=day
now["day_caps"]=string.upper(day)
now["day_lc"]=string.lower(day)
--short day names
local ds=dayshort[t]
now["day_short"]=ds
now["day_short_caps"]=string.upper(ds)
now["day_short_lc"]=string.lower(ds)
--get date
local s,f,t=string.find(tnow,"%s(%d%d)%s")
now["date"]=t
--get months
local s,f,t=string.find(tnow,"%d%d%s(%a*)%s%d")
if translate==1 then
mnth=monthlong[t]
now["month_short"]=monthshort[mnth]
now["month_short_caps"]=string.upper(monthshort[mnth])
now["month_short_lc"]=string.lower(monthshort[mnth])
mnth=monthnames[mnth]
else
now["month_short"]=t
now["month_short_caps"]=string.upper(t)
now["month_short_lc"]=string.lower(t)
mnth=monthlong[t]
end
now["month"]=mnth
now["month_caps"]=string.upper(mnth)
now["month_lc"]=string.lower(mnth)
local s,f,t=string.find(tnow,"%a%a%a%s(%d%d%d%d)")
now["year"]=t
local s,f,t=string.find(nowweather,"40_white/(wx_[%d]*)%ppng%p%stitle=%p")
now["weather_icon"]=weathericons..wimage[t]..".png"
now["weather_font"]=wfont[t]
local s,f,t=string.find(nowweather,"class=%pIcon%p /> ([%a%s%p]*)%s*%s*</td>%s*<td class=%pEmpty%p>&nbsp;")
local t=t:gsub("^%s*(.-)%s*$", "%1")
now["conditions"]=t
now["conditions_caps"]=string.upper(t)
now["conditions_lc"]=string.lower(t)
--set short versions------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["conditions_short"]=cons
	now["conditions_short_caps"]=string.upper(cons)
	now["conditions_short_lc"]=string.lower(cons)
--------------------------------------------
local s,f,t=string.find(nowweather,"Temperature\">([%p%d]*)&deg")
now["temp"]=t
local s,f,t=string.find(nowweather,">Feels Like: ([%p%d]*)&deg;</a>")
now["feels_like"]=t
local s,f,t=string.find(nowweather,">Wind Chill: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["wind_chill"]=t
local s,f,t=string.find(nowweather,">Ceiling: </a></td>%s*<td>([%a%d]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tc=t..ceiling_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tc=unlset
end
now["ceiling"]=tc
now["ceiling_caps"]=string.upper(tc)
now["ceiling_lc"]=string.lower(tc)
--get heat index
local s,f,t=string.find(nowweather,">Heat Index: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["heat_index"]=t
--get visibility
local s,f,t=string.find(nowweather,">Visibility: </a></td>%s*<td>([%a%d%p]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tv=t..visibility_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tv=unlset
end
now["visibility"]=tv
now["visibility_caps"]=string.upper(tv)
--get dew point
local s,f,t=string.find(nowweather,">Dew Point: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["dew_point"]=t
--get wind speed
local s,f,t=string.find(nowweather,">Wind: </a></td>%s*<td>(%d*)mph</td>")
local tmph=tonumber(t)
now["wind_mph"]=t..wind_mph_unit
now["wind_mph_caps"]=string.upper(t..wind_mph_unit)
--convert mph to km and knots
now["wind_km"]=round(tonumber(t)*1.609)..wind_km_unit
now["wind_km_caps"]=string.upper(round(tonumber(t)*1.609)..wind_km_unit)
now["wind_kts"]=round(tonumber(t)*0.869)..wind_kts_unit
now["wind_kts_caps"]=string.upper(round(tonumber(t)*0.869)..wind_kts_unit)
local s,f,t=string.find(nowweather,">Humidity: </a></td>%s*<td>(%d*)</td>")
now["humidity"]=t
--get wind direction ------------------------
local s,f,twd=string.find(nowweather,">Direction: </a></td>%s*<td style=[%p%a]*>([%d&;%s%(%a%)]*)</td>%s*</tr>")
--check for NA
local a,b,t=string.find(twd,"(%a*)")
local tnesw=t
if tnesw~="NA" then
local a,b,t=string.find(twd,"(%d*)&deg;")
now["wind_deg"]=t..wind_degrees_unit
local a,b,tnesw=string.find(twd,"%((%a*)%)")
	if tmph>0 and tmph<19 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	elseif tmph>18 and tmph<38 then
	now["wind_icon"]=weathericons.."yellow_"..string.lower(tnesw)..".png"
	elseif tmph>37 and tmph<64 then
	now["wind_icon"]=weathericons.."orange_"..string.lower(tnesw)..".png"
	elseif tmph>63 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	end
now["wind_font"]=windfontt[tnesw]
	if translate==1 then
	tnesw=neswtext[tnesw]
	else
	tnesw=tnesw
	end
now["wind_nesw"]=tnesw		
else
	if translate==1 then naset=additional.NA else naset="NA" end
now["wind_deg"]=naset
now["wind_icon"]=weathericons.."no_wind.png"
now["wind_nesw"]=naset
now["wind_font"]=windfontt["N"]
end
--END WIND DIRECTION #######################################################
--get pressure
local s,f,t=string.find(nowweather,">Pressure: </a></td>%s*<td>([%d%p]*)\"</td>")
now["pressure"]=t
--convert pressures ----------------
now["pressure_mb"]=round(tonumber(t)*33.86)
local s,f,t=string.find(nowweather,">Gusts: </a></td>%s*<td>([%d%a]*)</td>")
if t~="NA" then
local s,f,t=string.find(t,"(%d*)")
tg=t..wind_mph_unit
tgkm=round(tonumber(t)*1.609)..wind_km_unit
tgkts=round(tonumber(t)*0.869)..wind_kts_unit
else
	if translate==1 then naset=additional.NA else naset="NA" end
tg=naset
tgkm=naset
tgkts=naset
end
now["wind_gusts"]=tg
now["wind_gusts_caps"]=string.upper(tg)
now["wind_gusts_km"]=tgkm
now["wind_gusts_km_caps"]=string.upper(tgkm)
now["wind_gusts_kts"]=tgkts
now["wind_gusts_kts_caps"]=string.upper(tgkts)
--get hourly forecast options hour1
--get day 1 bit
local s,f,hfc=string.find(nowweather,"<td class=%pHour%p%sstyle=%ppadding%pleft([%a%d%p%s]*)%pdeg%p</strong>",1)
--get time and conditions
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",1)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",1)
--24 hour conversion
now["fc_hour1_time_24"]=convert24(tm,suf)
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour1_time"]=tm
now["fc_hour1_ampm"]=suf
now["fc_hour1_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%p%s%a]*)%s*</td>%s*<td class=%pHour%p",1)
now["fc_hour1_cond"]=t
now["fc_hour1_cond_lc"]=string.lower(t)
now["fc_hour1_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour1_cond_short"]=cons
	now["fc_hour1_cond_short_caps"]=string.upper(cons)
	now["fc_hour1_cond_short_lc"]=string.lower(cons)
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",1)
now["fc_hour1_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour1_wfont"]=wfont[t]
--get temperature
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",1)
now["fc_hour1_temp"]=t
--end of hour1 data gathering--repeat 2 more times
--get hourly forecast options hour2--------------------
local start=tonumber(b)
--get time and conditions
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion
now["fc_hour2_time_24"]=convert24(tm,suf)
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour2_time"]=tm
now["fc_hour2_ampm"]=suf
now["fc_hour2_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour2_cond"]=t
now["fc_hour2_cond_lc"]=string.lower(t)
now["fc_hour2_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour2_cond_short"]=cons
	now["fc_hour2_cond_short_caps"]=string.upper(cons)
	now["fc_hour2_cond_short_lc"]=string.lower(cons)
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour2_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour2_wfont"]=wfont[t]
--get temperature
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",start)
now["fc_hour2_temp"]=t
--end of hour2 data gathering--repeat 1 more times
local start=tonumber(b)
--get time and conditions
local a,b,tm=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
local a,b,suf=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
--24 hour conversion
now["fc_hour3_time_24"]=convert24(tm,suf)
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
now["fc_hour3_time"]=tm
now["fc_hour3_ampm"]=suf
now["fc_hour3_ampm_lc"]=string.lower(suf)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour3_cond"]=t
now["fc_hour3_cond_lc"]=string.lower(t)
now["fc_hour3_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
        for k,v in pairs(con_short) do
            local cons_length=string.len(cons)
            local match_length=string.len(k)
            if cons_length==match_length then
            cons=string.gsub(cons,k,v)
            end
        end
	now["fc_hour3_cond_short"]=cons
	now["fc_hour3_cond_short_caps"]=string.upper(cons)
	now["fc_hour3_cond_short_lc"]=string.lower(cons)
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour3_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour3_wfont"]=wfont[t]
--get temperature
local a,b,t=string.find(hfc,"><strong>([%p%d]*)",start)
now["fc_hour3_temp"]=t
--end of hour3 data gathering--finished for all hours
--ALERTS###############################################################
if alert_check==1 then
--set tables
alert_type={}
alert_issued={}
if alerttest~=0 then
alert_icon=weathericons.."icon_alert_1.gif"
--extract information into tables
local start=0
local f=1
while f~=nil do
local s,f,t=string.find(alertdata,"><strong class='Alert'>([%a%s]*)</strong><br/>",start)
	if t~=nil then
	table.insert(alert_type,string.upper(t))
	end--if t~=nil
local s,f,t=string.find(alertdata,"<br />([%d%a%s:]*)<br /><br />",start)
	if t~=nil then
	table.insert(alert_issued,t)
	end--if t~=nil
if f==nil then break end
start=f
alert_number=#alert_type
end--while
else
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"NO ALERTS")
table.insert(alert_issued,"")
alert_number=0
end--alerttest~=nil
else
alert_type={}
alert_issued={}
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"alerts turned off")
table.insert(alert_issued,"")
alert_number=0
end--if alert check
-- end of data processing
if testing==0 then
processall=0
print ("processing complete")
elseif testing==1 then
processall=1
end--if testing ==0
end--of data processing section
if processall==0 or testing==1 then
_G.weather_script()
end
--#########################################################################################################
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--end--####### end of if updates>5 #############################
--#########################################################################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function

function round(num)
	local idp=tonumber(settings_table[5])
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end--of round function

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--string split

function xout(txj)
c=nil
c=(txj.c or default_color)
a=nil
a=(txj.a or default_alpha)
f=nil
f=(txj.f or default_font)
fs=nil
fs=(txj.fs or default_font_size)
x=nil
x=(txj.x or 0)
y=nil
y=(txj.y or 0)
txt=nil
txt=(txj.txt or "set txt")
j=nil
j=(txj.j or "l")
local cs=txj.cs     or default_size         or "normal_c"
local format=txj.format					or default_format			or "normal"
local ul=txj.ul     or default_ul         or "no"
local shaded=txj.shaded				or default_shaded		or "no"
------------------
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local text=string.gsub(txt," ","_")
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local wx=extents.width
if j=="l" then
cairo_move_to (cr,x,y)
adx=wx
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
adx=wx/2
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
adx=0
end
	if format=="normal" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	elseif format=="bold" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
	elseif format=="italic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
	elseif format=="bolditalic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
	end
----------------------
if cs=="big_c" then
txt=string.upper(txt)
elseif cs=="small_c" then
txt=string.lower(txt)
elseif cs=="normal_c" then
txt=txt
end
----------------------
	if ul=="yes" then
		lw=1
		lc=CAIRO_LINE_CAP_BUTT
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE)
		----------------------------
		startx=x
		endx=startx+wx
		starty=y+5
		endy=y+5
		----------------------------
		cairo_set_line_width (cr,lw)
		cairo_set_line_cap  (cr, lc)
		cairo_set_source_rgba (cr,col(c,a))
		cairo_show_text (cr,txt)
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wx,endy)
		cairo_stroke (cr)
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) 
	elseif ul == "no" then
		txt=txt
	end -- if
	-----------------------------------------------------
	if shaded == "yes" then
		sc=0x000000
		sa=1
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,col(sc,sa))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	elseif shaded=="no" then
	txt=txt
	end
	----------------------------------------------------
cairo_move_to (cr,(x),(y))
cairo_set_source_rgba (cr,col(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
nextx=nil
nextx=adx+x
return nextx
end--function xout

function out(txj)
	local extents=cairo_text_extents_t:create()
	tolua.takeownership(extents)
	local c=txj.c						or default_color		or 0xffffff
	local a=txj.a						or default_alpha		or 1
	local f=txj.f						or default_font			or "mono"
	local fs=txj.fs						or default_font_size	or 12
	local x=txj.x						or 100
	local y=txj.y						or 100
	local txt=txj.txt					or "set txt"
	local hj=txj.hj						or default_hj			or "l"
	local vj=txj.vj						or default_vj			or "n"
	local face=txj.face					or default_face			or "normal"
	local size=txj.size     or default_size         or "normal_c"
	local shaded=txj.shaded				or default_shaded		or "no"
	local shade_color=txj.shade_color	or default_shade_color	or 0x000000
	local shade_alpha=txj.shade_alpha	or default_shade_alpha	or 1
	local underline=txj.underline     or default_underline         or "no"
	local line_color=txj.line_color    or   default_line_color   or   c
	local line_space=txj.line_space    or default_line_space   or  5
	local line_width=txj.line_width     or default_line_width   or  1
	local number=txj.number  or 8
	local radius=txj.radius or 1.75
	local blurred=txj.blurred or no
	
	local bc=txj.bc or 0x000000
	local ba=txj.ba or 1
	local lw=txj.lw or 1
	
-- ##########################################################
-- ## Italic = Bezeichnung für kursive Antiqua-Schriften  ###
-- ## Oblique = Bezeichnung für kursive Grotesk-Schriften ###
-- ##########################################################
    
	if face=="normal" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	elseif face=="bold" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
	elseif face=="italic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
	elseif face=="bolditalic" then
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
	elseif face=="oblique" then 
		cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_OBLIQUE, CAIRO_FONT_WEIGHT_NORMAL);
	end
	
	----------------------
	if size=="big_c" then
	txt=string.upper(txt)
	elseif size=="small_c" then
	txt=string.lower(txt)
	elseif size=="normal_c" then
	txt=txt
	end
	----------------------
	cairo_set_font_size (cr, fs)
	cairo_text_extents(cr,txt,extents)
	local wx=extents.x_advance -- measure spaces too
	local wd=extents.width
	local hy=extents.height
	local bx=extents.x_bearing
	local by=extents.y_bearing+hy
	local tx=x
	local ty=y
	--set horizontal alignment
	if hj=="l" then
		x=x-bx
	elseif hj=="c" then
		x=x-((wx-bx)/2)-bx
	elseif hj=="r" then
		x=x-wx
	end
	-- set shade
	if shaded == "yes" then
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,col(shade_color,shade_alpha))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	end -- if
	-------------------------------------------------
	cairo_move_to (cr,x,y)
	cairo_set_source_rgba (cr,col(c,a))
	cairo_show_text (cr,txt)
	cairo_stroke (cr)
	--------------------------------------------------
	if blurred=="yes" then
	 radi=radius
	 inum=number
	 horiz=x
	 verti=y

	 for i=1,inum do
	 deg=360/inum
	 text_arc=((2*math.pi/inum)*i)
	 txs=0+radi*(math.sin(text_arc))
	 tys=0-radi*(math.cos(text_arc))
	    ----------------------------
		cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
		----------------------------
	 cairo_set_font_size (cr, fs);
	 cairo_set_source_rgba (cr, col(c,ba));
	 cairo_move_to (cr, txs+horiz, tys+verti);
	 cairo_show_text (cr, txt)
     end
	 
	elseif blurred=="no" then
	 txt=txt
	end
	--------------------------------------------------
	if underline=="yes" then
		line_cap=CAIRO_LINE_CAP_BUTT
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE)
		----------------------------------------------
		startx=x
		endx=startx+wd
		starty=y+line_space
		endy=y+line_space
		----------------------------------------------
		cairo_set_line_width (cr,line_width)
		cairo_set_line_cap  (cr, line_cap)
		cairo_set_source_rgba (cr,col(line_color,a))
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wd,endy)
		cairo_stroke (cr)
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) --# reset antialiasing so we don't screw up other code
	elseif underline == "no" then
	txt=txt
	end
end--of function out 

-- ###############################################################################
-- ## display local images #######################################################
-- ###############################################################################

function image(im)
	local x = nil
	x = (im.x or 0)
	local y = nil
	y = (im.y or 0)
	local w = nil
	w = (im.w or default_image_width)
	local h = nil
	h = (im.h or default_image_height)
	local file = nil
	file = tostring(im.file)
	if file == nil then print("set image file") end --# if file == nil then 
	local show = imlib_load_image(file)
	if show == nil then return end --# if show == nil then 
	imlib_context_set_image(show)
	local WIDTH = nil
	if tonumber(w) == 0 then 
		WIDTH = imlib_image_get_width() 
	else
		WIDTH = tonumber(w)
	end --# if tonumber(w) == 0 then
	local HEIGHT = nil
	if tonumber(h) == 0 then HEIGHT = imlib_image_get_height() else HEIGHT = tonumber(h) end --# if tonumber(h) == 0 then 
	local scaled = imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), WIDTH, HEIGHT)
	imlib_free_image_and_decache()
	imlib_context_set_image(scaled)
	imlib_render_image_on_drawable(x, y)
	imlib_free_image_and_decache()
	show = nil
	WIDTH = nil
	HEIGHT = nil
	x = nil
	y = nil
	w = nil
	h = nil
	file = nil
	scaled = nil
end --# function image(im)
-- ##############################################################################

-- ###########################################################################
-- ## convert 12h-format into 24h-format #####################################
-- ###########################################################################

function convert24(tm,suf)
local tmlen=string.len(tm)
local colon=string.find(tm,":")
	if colon~=nil then
	tmhr=string.sub(tm,1,colon-1)
	tmmn=string.sub(tm,colon+1,tmlen)
	else
	tmhr=tm
	tmmn=""
	end
if suf=="PM" and tonumber(tmhr)~=12 then
tmhr=tmhr+12
elseif suf=="PM" and tonumber(tmhr)==12  then
tmhr=12
elseif suf=="AM" and tonumber(tmhr)<10 then
tmhr="0"..tmhr
elseif suf=="AM" and tonumber(tmhr)>=10 and tonumber(tmhr)~=12 then
tmhr=tmhr
elseif suf=="AM" and tonumber(tmhr)==12 then
tmhr="00"
end
if colon~=nil then
return tmhr..":"..tmmn
else
return tmhr
end--if colon~=nil
end--of function

-- ##############################################################################
-- ## END OF ORIGINAL SCRIPT ####################################################
-- ##############################################################################

-- ##############################################################################
-- ## display external images ###################################################
-- ##############################################################################

function extern(wb)
	----------------------------------------------
	local img_nw=nil
	local img_x=nil
	local img_y=nil
	local s=nil
	local j=nil
	local img_w=nil
	local img_h=nil
	local imgwidth=nil
	local imgheight=nil
	local imgt=nil
	local imgw=nil
	local imgh=nil
	----------------------------------------------
	img_x=(wb.posx or 0)
	img_y=(wb.posy or 0)
	img_w=wb.imgw
	img_h=wb.imgh
	j=(wb.j or "l")
	scaled=(wb.scaled or 200)
	scale_size=(wb.scale_size or 200)
	----------------------------------------------
	img_nw=(wb.imghdd or "external_img.jpg")
	s=wb.imgurl -- url of the webcam
	img_file='/home/'..username.."/"..img_nw
	img_intervall=(wb.imgiv or 60)
	-- grab external image from url and save it to hdd
	local updates = tonumber(conky_parse('${updates}'))
	if (math.mod(updates, img_intervall) == 0) then
		os.execute("wget  -q -O "..img_file..' "'..s..'"')
	end
	if img_file==nil then print("set image file") end
	---------------------------------------------------
	if scaled=="yes" then
	---------------------------------------------------
		local show = imlib_load_image(img_file)
		if show == nil then return 	end
		imlib_context_set_image(show)
		imgwidth= imlib_image_get_width()
		imgheight=imlib_image_get_height()
		imgw=scale_size
		imgh=(imgw*imgheight)/imgwidth
		imlib_free_image_and_decache()
	else
		imgw=img_w
		imgh=img_h
	end
	----------------------------------------------------
	if j=="l" then
	 img_x=img_x
	elseif j=="r" then
	 img_x=img_x-imgw
	else
	 print("alignment not made")
	end
	----------------------------------------------------
	image({x=img_x,y=img_y,w=imgw,h=imgh,file=img_file})
end--of function

-- ##############################################################################
-- ## grab url of the 'image of the day' by the nasa ############################
-- ##############################################################################

function get_image()
	local uri='http://www.nasa.gov/rss/image_of_the_day.rss'
	local f = assert(io.popen('curl -s '..uri, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	s, f = string.gsub(s, ".*image\/jpeg.*(http://.*\.jpg).*", "%1")
	return s
end

-- ##############################################################################
-- ## grab url of the 'picture of the week' by hubble ###########################
-- ##############################################################################

function potw_uri()
	local uri = 'http://feeds.feedburner.com/hubble_potw?format=xml'
	local f = assert(io.popen('curl -s '..uri, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	local b = nil
	local e = nil
	b,e,s = string.find(s,'(http://www%.spacetelescope%.org/static/archives/images/news/potw%d-.%.jpg)')
	return(s)
end

-- ###############################################################################
-- ## convert the name of the month into numbers #################################
-- ###############################################################################

function m2n(mn)
---------------------------------
local m2n_input=nil
local m2n_input=(mn.input or 0)
local m2n_input=string.lower(m2n_input)
local m2n_lang=nil
local m2n_lang=(mn.l or "en")
local month_to_num={}
local output=nil
---------------------------------
if m2n_lang=="de" then
 month_to_num={"januar","februar","märz","april","mai","juni","juli","august","september","oktober","november","dezember"}
elseif m2n_lang=="it" then
 month_to_num={"gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"}
elseif m2n_lang=="en" then
 month_to_num={"january","february","march","april","may","june","juli","august","september","octobre","november","december"}
end
-----------------------------------
for i,v in ipairs(month_to_num) do
    if tostring(m2n_input)==tostring(v) then
       if tonumber(i)<=9 then
	   output="0"..tonumber(i)
	   elseif tonumber(i)>=10 then
	   output=tonumber(i)
	   end
	end
end--of loop
return output
end--of function


-- ###########################################################################


function display_system(cd)
-----------------------------
local conky_order=nil
local variable=nil
local device=nil
local del=nil
local cs = nil
local ms = nil
-----------------------------
variable=cd.variable
device=(cd.device or '')
del=(cd.del or '.')
-----------------------------
conky_order=conky_parse("${"..variable..' '..device.."}")

local value = conky_order:gsub(" ","") -- remove spaces

	---- short_units no ------------------------
	if ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=(value:gsub("B",""))..' byte'	
	elseif string.find(value, 'KiB') ~= nil then
		ms=chgDel(conky_order,del)..' kb'
	elseif string.find(value, 'MiB') ~= nil then
		ms=chgDel(conky_order,del)..' mb'
	elseif string.find(value, 'GiB') ~= nil then
		ms=chgDel(conky_order,del)..' gb'
	elseif string.find(value, "TiB") ~= nil then
		ms=chgDel(conky_order,del).." tb"	
	elseif ((string.find(variable, "perc") ~= nil) or (string.find(variable, "percent") ~= nil)) then
		ms=chgDel(conky_order,del).." %"
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") == nil)) then
		ms=chgDel(conky_order,del).." Mhz"
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") ~= nil)) then
		ms=conky_order.." Ghz"
	elseif ((string.find(variable,"downspeedf") ~= nil) or (string.find(variable,"upspeedf") ~= nil)) then
		ms=chgDel(conky_order,del).." kb/s"
	elseif string.find(variable,"time") ~= nil then
		ms=conky_order:gsub(" ","")
	elseif string.find(variable,"cpu") ~= nil then
		ms=chgDel(conky_order,del).." %"
	---- short_units yes -----------------------
	elseif ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=chgDel(conky_order,del)..' byte'
	elseif string.find(value, "K") ~= nil then
		ms=chgDel(conky_order,del)..' kb'
	elseif string.find(value, "M") ~= nil then
		ms=chgDel(conky_order,del)..' mb'
	elseif string.find(value, "G") ~= nil then
		ms=chgDel(conky_order,del)..' gb'
	elseif string.find(value, "T") ~= nil then
		ms=(value:gsub("T",""))..' tb'
	------------------------------------------------------
	else ms=value:gsub(" ","") end
	------------------------------------------------------
	cs=string.gsub(tostring(ms),"%.",del) -- replace delimiter
	return cs
end -- of function

-- ######################################################################
-- ## chg format of number ##############################################
-- ######################################################################

function chgDel(value,del)
local ausgang=nil
local ersteZahl=nil
local rest=nil
local outputNumber=nil
-------------------------------------------------
ausgang=string.gsub(value, "(%d*\.*%d+).*", "%1") -- remove ending
ausgang=tonumber(ausgang) -- chg format to number

 if ((ausgang >= 10000) and (ausgang <= 99999.99)) then
       -----------------------------------------------------------------
       ersteZahl=string.sub(ausgang,1,2)
       rest=string.sub(ausgang,3,string.len(ausgang))
       -----------------------------------------------------------------
       if del=="," then
       outputNumber=ersteZahl..'.'..string.gsub(tostring(rest),"%.",",")
	   else
	   outputNumber=ersteZahl..','..string.gsub(tostring(rest),"%,",".")
       end
       -----------------------------------------------------------------
 elseif ((ausgang>=1000) and (ausgang <9999.99)) then
       -----------------------------------------------------------------
       ersteZahl=string.sub(ausgang,1,1)
       rest=string.sub(ausgang,2,string.len(ausgang))
       -----------------------------------------------------------------
	   if del=="," then
       outputNumber=ersteZahl..'.'..string.gsub(tostring(rest),"%.",del)
	   elseif del=="." then
	   outputNumber=ersteZahl..','..rest
       end
       -----------------------------------------------------------------
 elseif ausgang<999 then
       -----------------------------------------------------------------
	   if del=="," then
       outputNumber=string.gsub(tostring(ausgang),"%.",',')
	   elseif del=="." then
	   outputNumber=ausgang
       end
       -----------------------------------------------------------------
 elseif ausgang >=100000 then
	   -----------------------------------------------------------------
       ersteZahl=string.sub(ausgang,1,3)
       rest=string.sub(ausgang,4,string.len(ausgang))
       -----------------------------------------------------------------
	   if del=="," then
       outputNumber=ersteZahl..'.'..string.gsub(tostring(rest),"%.",del)
	   elseif del=="." then
	   outputNumber=ersteZahl..','..rest
       end
       -----------------------------------------------------------------
 end

return outputNumber

end -- of function



-- ##########################################################################
-- ## add zero ##############################################################
-- ##########################################################################

function addzero100(num)

if tonumber(num) < 10 then
return "00" .. num
elseif tonumber(num) <100 then
return "0" .. num
else
return num
end

end

-- ###########################################################################
-- ## add decimal place ######################################################
-- ###########################################################################

function add_decimal(input)
------------------------------------------------------------------------------
if string.find(input,"%a")==nil then
        if string.find(input,"%p")==nil then        
        input=input..',0'
        end
end
------------------------------------------------------------------------------
return input
end

-- ##########################################################################
-- ### drop leading zero ####################################################
-- ##########################################################################

function dropZero(wert)
-----------------------------------------------------------------------------
local erstezahl=nil
local ausgabe=nil

local erstezahl=tonumber(string.sub(wert,1,1))

 if erstezahl == 0 then
 ausgabe=string.sub(wert,2,string.len(wert))
 else
 ausgabe=string.sub(wert,1,string.len(wert))
 end -- of if

return ausgabe

end -- of function


-- #########################################################################
-- ## draw simple vertical bar #############################################
-- #########################################################################

function drawSimpleBar(sb)
--------------------------------
posx=sb.posx or 0
posy=sb.posy or 0
width=sb.width or 20
height=sb.height or 100
value=sb.value
device=sb.device
bar_bgcolor=sb.bar_bg_color or 0xff0000
bar_bgalpha=sb.bar_bg_alpha or 1
bar_ind_color=sb.bar_ind_color or 0xffffff
bar_ind_alpha=sb.bar_ind_alpha or 1

--------------------------------
--SETTINGS FOR CPU INDICATOR BAR
posx=posx
posy=posy
width=width
height=height

--set bar background
bar_bgcolor=bar_bgcolor
bar_bgalpha=bar_bgalpha
--set indicator color
bar_in_color=bar_ind_color
bar_in_alpha=bar_ind_alpha

--draw background
cairo_set_source_rgba (cr,col(bar_bgcolor,bar_bgalpha))
cairo_rectangle (cr,posx,posy,width,-height)
cairo_fill (cr)

--draw indicator
cairo_set_source_rgba (cr,col(bar_in_color,bar_in_alpha))--set indicator color
value=tonumber(conky_parse("${"..value..' '..device.."}"))
max_value=100
scale=height/max_value
indicator_height=scale*value
cairo_rectangle (cr,posx,posy,width,-indicator_height)
cairo_fill (cr)

end

-- ###################################################################################

function font_slant(value)
	local face=nil
	face=value
 	if face=="normal" then
	fs=CAIRO_FONT_SLANT_NORMAL
    elseif face=="bold" then
	fs=CAIRO_FONT_SLANT_NORMAL
	elseif face=="italic" then
	fs=CAIRO_FONT_SLANT_ITALIC
    elseif face=="bolditalic" then
    fs=CAIRO_FONT_SLANT_ITALIC
	elseif face=="oblique" then 
    fs=CAIRO_FONT_SLANT_OBLIQUE
	end
	    
	return fs
end

function font_weight(value)
	local face=nil
	face=value
 	if face=="normal" then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif face=="bold" then
	fw=CAIRO_FONT_WEIGHT_BOLD
	elseif face=="italic" then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif face=="bolditalic" then
    fw=CAIRO_FONT_WEIGHT_BOLD
	elseif face=="oblique" then 
    fw=CAIRO_FONT_WEIGHT_NORMAL
	end
	    
	return fw
end

-- ############################################################
-- ## change delimiter ########################################
-- ############################################################

function formatNumber(value,lang)

number=value

if lang=="de" then
firstPart=string.sub(number,1,1)
secondPart=string.sub(number,2,string.len(number))
numberGsub=string.gsub(tostring(secondPart),"%.",',')
newNumber=firstPart.."."..numberGsub
elseif lang=="en" then
firstPart=string.sub(number,1,1)
secondPart=string.sub(number,2,string.len(number))
numberGsub=string.gsub(tostring(secondPart),"%.",'.')
newNumber=firstPart..","..numberGsub
end


return newNumber
end

--END OF SCRIPT

within this brackets you can decline delimiter you can use.

the new version of the script doesn't have an effect to already existing templates!!! parallel i display the weather and it works like before :) there is no reason why you shouldn't use this version.

i tested the script with at least twenty different webcams and other external images (radar etc.)! surely you can use the script to display the current version of an image, for example like this:

extern({posx=800,posy=200,imgw=195,imgh=195,imgurl="http://antarctica.martingrund.de/ohig-pingi-z.jpg",imghdd="pinguin.jpg",imgiv=60})

this is my screenshot:

http://ompldr.org/vaDRlZw

as you can see in the screenshot you even can display rss-feeds on your desktop:

local feed_1=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 0}") 
local feed_2=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 1}") 
local feed_3=conky_parse("${rss http://www.astronews.com/_rss/aktuell.xml 300 item_title 2}")

out({x=0,y=10,c=0xffff00,txt=feed_1})
out({x=0,y=25,c=0xffff00,txt=feed_2})
out({x=0,y=40,c=0xffff00,txt=feed_3})

i've included two new functions to v9000. you can convert the name of the month into a number, for example 1st of december into 1.12.

you can call the function like this:

m2n({input=now["month"],l="de"})

the function works for different languages: german, english and italian.

u can use the variable 'input' to convert a name.

input=now["month"]

you can define the language like this:

l="de"

if u use english words then u do not have to use the parameter L

to convert english words is the standard-setting

m2n({input=now["month"]})

do not use (but it also works *g*)

m2n({input=now["month"],l="en"})

it's also possible to parse 'conky-orders, for example 'downspeedf'

this converts the values:

out({x=20,y=550,f="mono",c=dunkel,face="italic",shaded="yes",txt=display_system({variable="downspeedf",device="wlan0",del=','}),hj="r"})

add this if u want to use a variable from this webpage

it's important that u use this variable because it's neccesary to execute the script.

variable="downspeedf"

add this if u use a special device:

device="wlan0"

it looks like this:

vaHF1cg
if the conky-variable doesn't need a special device to work then use this, for example 'memperc'

out({x=20,y=550,f="mono",c=dunkel,face="italic",shaded="yes",txt=display_system({variable="memfree",del=','}),hj="r"})

if u want to change the delimiter then add this:

del=','

the default-value is the sign '.'

i did not change essential things (everything still works). all of the functions are well tested and do NOT have an effect to your existing templates.

edit: i removed some comments.

if u want to display a preview-image of the photo of the week (spacetelescope hubble) add this code within your template:

extern({posx=410,posy=0,scaled="yes",imgurl=potw_uri(),imghdd="potw.jpg",imgiv=60})

sometimes it is very useful if u can align your external image, for example 'right':

j="r"

the standard-setting is

j="l"

here an example:

extern({posx=conky_window.width,posy=0,scaled="yes",imgurl=potw_uri(),imghdd="potw.jpg",imgiv=60,j="r"})

thanks for mrpeachy for this great weather-script. if u find something to optimize the code then feel free to contact me :) or if u have a proposal what to add something then contact me.

Last edited by lionhead (2013-03-21 10:39:34)

Offline

#871 2013-02-13 18:23:35

impantsless
New Member
Registered: 2013-02-13
Posts: 6

Re: weather in conky (LUA scripts) updated 12/26/13!

I tried this out and when it comes up on my screen, it looks like it's missing a lot of data. I don't get any errors though. Could anyone help me out by pointing me in the right direction?

I'nm using Mint 14, 3.5.0-17-generic x86_64. Conky version is 1.9.0.

Thanks

v9000_screenshot.jpg

Moderator Edit - Image Resize - VastOne

----------------------------------------------------------------------------------------------------------------------------
Please use thumbnails (please try to avoid the large thumbnail imgur.com code) linking to the larger image to help those of us with slow connections. An example of the code needed is below. Most image hosting sites will automatically generate this for you as well. Users have been using postimage.org lately which does a nice job.

[url=http://link.to.your.fullsized.image][img]http://link.to.your.thumbnail.image[/img][/url]

Last edited by impantsless (2013-02-13 20:35:41)

Offline

#872 2013-02-15 19:41:13

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,691
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

impantsless wrote:

I tried this out and when it comes up on my screen, it looks like it's missing a lot of data. I don't get any errors though. Could anyone help me out by pointing me in the right direction?

I'nm using Mint 14, 3.5.0-17-generic x86_64. Conky version is 1.9.0.

Thanks

http://ompldr.org/vaGdhNw/v9000-screenshot.jpg

Can you post the conky and the template you are using.


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Online

#873 2013-02-16 01:43:46

impantsless
New Member
Registered: 2013-02-13
Posts: 6

Re: weather in conky (LUA scripts) updated 12/26/13!

impantsless wrote:

I tried this out and when it comes up on my screen, it looks like it's missing a lot of data. I don't get any errors though. Could anyone help me out by pointing me in the right direction?

I'nm using Mint 14, 3.5.0-17-generic x86_64. Conky version is 1.9.0.

Thanks

http://s3.postimage.org/mtnup2ybz/v9000_screenshot.jpg

Moderator Edit - Image Resize - VastOne

----------------------------------------------------------------------------------------------------------------------------
Please use thumbnails (please try to avoid the large thumbnail imgur.com code) linking to the larger image to help those of us with slow connections. An example of the code needed is below. Most image hosting sites will automatically generate this for you as well. Users have been using postimage.org lately which does a nice job.

[url=http://link.to.your.fullsized.image][img]http://link.to.your.thumbnail.image[/img][/url]

Sorry!

Offline

#874 2013-02-16 02:09:15

impantsless
New Member
Registered: 2013-02-13
Posts: 6

Re: weather in conky (LUA scripts) updated 12/26/13!

Sector11 wrote:
impantsless wrote:

I tried this out and when it comes up on my screen, it looks like it's missing a lot of data. I don't get any errors though. Could anyone help me out by pointing me in the right direction?

I'nm using Mint 14, 3.5.0-17-generic x86_64. Conky version is 1.9.0.

Thanks

http://ompldr.org/vaGdhNw/v9000-screenshot.jpg

Can you post the conky and the template you are using.

conky-weather

##############################################
#  Settings
##############################################
max_specials 10000
max_user_text 1500000
background no
use_xft yes
#xftfont Sans:size=12
#xftalpha 1
font Mono:size=8
total_run_times 0
own_window yes
own_window_argb_visual yes
own_window_transparent yes
own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 600 600
maximum_width 600
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
default_color white
default_shade_color black
default_outline_color white
alignment top_right
gap_x 10
gap_y 10
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
color1 86acad #darker blue
color2 b1c9c9 #lighter blue
text_buffer_size 100000
top_name_width 10
update_interval 1

lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
lua_load ~/v9000/weather_testing.lua

TEXT
${goto 230}${cpu}

v9000.lua

--weather v9000 by mrpeachy 01/10/12; released: Feb 23, 2012
require 'cairo'
require 'imlib2'
local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"
local username = username  
package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'
start=1
--INITIALIZE SETTINGS-- need only be run once
settings_table=weather_settings()
--##################################
--######## main function ########### 
function conky_weather()--##########
--##################################
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}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
--################################################
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]
--################################################
print ("gathering data with curl")
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section
--#########################################################################

--#########################################################################
--in case curl craps up it should retry until it works
if testall==nil or  alerttest==nil then
print ("curl attempt timed out, trying again")
local web=settings_table[2]
local alert_check=settings_table[13]
local f=io.popen("curl --max-time 60 '"..web.."' | sed 's/%//g'")
allweatherdata=f:read("*a")
f:close()
allweatherdata=string.gsub(allweatherdata,"[\n\r]","")
testall=string.find(allweatherdata,">10 Day Forecast&nbsp")
--CHECK FOR WEATHER ALERTS
if testall~=nil and alert_check==1 then
local alert=string.find(allweatherdata,"Severe Weather Alert!")
	if alert~=nil then
	print ("getting weather alerts")
	--get alert web
	local a,b,alertchunk=string.find(allweatherdata,">Local Information</div>(.*)>Severe Weather Alert!<")
	local a,b,alertsite=string.find(alertchunk,"><a href=%p(.*)%p><img src=")
	local f=io.popen("curl --max-time 60 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")
	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert_check
processall=1
end--if testall==nil
--end or curl reruns ######################################################

--START PROCESSING ###########################################################################
if testall~=nil and alerttest~=nil and processall==1 then
local weathericons=settings_table[3]
local con_short=settings_table[4]
local visibility_unit=settings_table[6]
local wind_mph_unit=settings_table[7]
local wind_km_unit=settings_table[8]
local wind_kts_unit=settings_table[9]
local ceiling_unit=settings_table[10]
local wind_degrees_unit=settings_table[11]
local translate=settings_table[12]
local alert_check=settings_table[13]
--#########################################################################
--LOAD TRANSLATE TABLES IF TRANSLATE SETTING = 1
	if translate==1 then
	monthshort=settings_table[21]
	monthnames=settings_table[20]
	dayhort=settings_table[19]
	daynames=settings_table[18]
	neswtext=settings_table[14]
	tsuffix=settings_table[15]
	uvindextext=settings_table[16]
	moonphases=settings_table[17]
	additional=settings_table[22]
	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort
	dayshort={Monday="Mon",Tuesday="Tue",Wednesday="Wed",Thursday="Thu",Friday="Fri",Saturday="Sat",Sunday="Sun"}
	monthshort={January="Jan",February="Feb",March="Mar",April="Apr",May="May",June="Jun",July="Jul",August="Aug",September="Sep",October="Oct",November="Nov",December="Dec"}
	end--end if translate =1
--#########################################################################
--process data tables
--intellicast to conky weather icon conversion
wimage={
wx_65="32",  -- Clear
wx_66="30",  -- Partly Cloudy
wx_67="26",  -- Cloudy
wx_68="32",  -- Clear
wx_69="28",  -- Mostly Cloudy
wx_70="20",  -- Fog
wx_71="32",  -- Clear
wx_72="21",  -- Haze
wx_73="36",  -- Hot
wx_74="14",  -- Light Snow Showers
wx_75="28",  -- Mostly Cloudy
wx_76="18",  -- Sleet
wx_77="14",  -- Light Snow Showers
wx_78="23",  -- Blustery
wx_79="05",  -- Mixed Rain and Snow
wx_80="15",  -- Drifting Snow
wx_81="15",  -- Drifting Snow
wx_82="11",  -- Light Rain
wx_83="16",  -- Snow
wx_84="00",  -- Tornado
wx_85="32",  -- Clear
wx_86="25",  -- N/A
wx_87="09",  -- Drizzle
wx_88="05",  -- Mixed Rain and Snow
wx_89="18",  -- Sleet
wx_90="18",  -- Sleet
wx_91="39",  -- Scattered Showers
wx_92="39",  -- Scattered Showers
wx_93="39",  -- Scattered Showers
wx_94="39",  -- Scattered Showers
wx_95="37",  -- Isolated Thunderstorms
wx_96="37",  -- Isolated Thunderstorms
wx_97="31",  -- Clear
wx_98="29",  -- Partly Cloudy
wx_99="27",  -- Mostly Cloudy
wx_100="47",  -- Isolated Thunderstorms
wx_101="47",  -- Isolated Thunderstorms
wx_102="33",  -- Fair
wx_103="26",  -- Cloudy
wx_104="20",  -- Fog
wx_105="45",  -- Scattered Showers
wx_106="45",  -- Scattered Showers
wx_107="11",  -- Light Rain
wx_108="46",  -- Snow Showers
wx_109="46",  -- Snow Showers
wx_110="06",  -- Mixed Rain and Sleet
wx_111="18",  -- Sleet
wx_112="06",  -- Mixed Rain and Sleet
wx_113="46",  -- Snow Showers
wx_114="46",  -- Snow Showers
wx_115="31",  -- Clear
wx_116="47",  -- Isolated Thunderstorms
}--end w image table
--convert intellicast icons to weather font
wfont={
wx_65="a",
wx_66="c",
wx_67="f",
wx_68="a",
wx_69="d",
wx_70="0",
wx_71="a",
wx_72="9",
wx_73="5",
wx_74="p",
wx_75="d",
wx_76="w",
wx_77="p",
wx_78="6",
wx_79="x",
wx_80="8",
wx_81="8",
wx_82="h",
wx_83="q",
wx_84="m",
wx_85="a",
wx_86="-",
wx_87="h",
wx_88="x",
wx_89="w",
wx_90="w",
wx_91="g",
wx_92="g",
wx_93="g",
wx_94="g",
wx_95="k",
wx_96="k",
wx_97="A",
wx_98="C",
wx_99="D",
wx_100="K",
wx_101="K",
wx_102="B",
wx_103="f",
wx_104="0",
wx_105="G",
wx_106="G",
wx_107="h",
wx_108="O",
wx_109="O",
wx_110="x",
wx_111="w",
wx_112="x",
wx_113="O",
wx_114="O",
wx_115="A",
wx_116="K",
}--end w font table
--conversion day and month tables
moonfontt={
["New"]="@",
["Full"]="=",
["First Quarter"]="T",
["Last Quarter"]="G",
["Waning Gibbous"]="D",
["Waning Crescent"]="J",
["Waxing Crescent"]="Q",
["Waxing Gibbous"]="W",
}--end of moon font table
moonicont={
["New"]=weathericons.."moon_new.png",
["Full"]=weathericons.."moon_full.png",
["First Quarter"]=weathericons.."moon_first_quarter.png",
["Last Quarter"]=weathericons.."moon_last_quarter.png",
["Waning Gibbous"]=weathericons.."moon_waning_gibbous.png",
["Waning Crescent"]=weathericons.."moon_waning_crescent.png",
["Waxing Crescent"]=weathericons.."moon_waxing_crescent.png",
["Waxing Gibbous"]=weathericons.."moon_waxing_gibbous.png",
}--end of moon icon table
windfontt={
S="9",
SSW=":",
SW=";",
WSW="<",
W="=",
WNW=">",
NW="?",
NNW="@",
N="1",
NNE="2",
NE="3",
ENE="4",
E="5",
ESE="6",
SE="7",
SSE="8"
}--end of wind direction font table
--#########################################################################

--#########################################################################
--setup tables for forecast weather
forecast_day={}
forecast_day_caps={}
forecast_day_lc={}
forecast_day_short={}
forecast_day_short_caps={}
forecast_day_short_lc={}
forecast_month={}
forecast_month_caps={}
forecast_month_lc={}
forecast_month_short={}
forecast_month_short_caps={}
forecast_month_short_lc={}
forecast_date={}
weather_icon={}
weather_font={}
high_temp={}
low_temp={}
conditions={}
conditions_caps={}
conditions_lc={}
conditions_short={}
conditions_short_caps={}
conditions_short_lc={}
sun_rise={}
sun_rise_lc={}
sun_rise_time={}
moon_rise={}
moon_rise_lc={}
moon_rise_time={}
moon_rise_ampm={}
moon_rise_ampm_lc={}
sun_set={}
sun_set_lc={}
sun_set_time={}
moon_set={}
moon_set_lc={}
moon_set_time={}
moon_set_ampm={}
moon_set_ampm_lc={}
humidity={}
precipitation={}
snow={}
cloud_cover={}
moon_phase={}
moon_phase_caps={}
moon_phase_lc={}
moon_font={}
moon_icon={}
wind_mph={}
wind_km={}
wind_kts={}
wind_font={}
wind_icon={}
wind_deg={}
wind_nesw={}
uv_index_num={}
uv_index_txt={}
uv_index_txt_caps={}
uv_index_txt_lc={}
--#########################################################################

--#########################################################################
--get forecast chunk
local a,b,allweather=string.find(allweatherdata,">10 Day Forecast&nbsp(.*)>More from Intellicast</div>")
--extract information into tables
local start=0
local f=1
while f~=nil do
--match forecast day name and date
local s,f,t=string.find(allweather,"<td colspan=\"2\"><strong>([%a,%s%d]*)</strong></td>",start)
	if t~=nil then
	--split name from month and date
	local a,b,day=string.find(t,"(%a*),%s")
	local a,b,month=string.find(t,",%s(%a*)%s")
	local a,b,date=string.find(t,"(%d*)$")
	--ser day names, regular, caps, lowercase and short
	table.insert(forecast_day_short,dayshort[day])
	table.insert(forecast_day_short_caps,string.upper(dayshort[day]))
	table.insert(forecast_day_short_lc,string.lower(dayshort[day]))
		if translate==1 then
		day=daynames[day]
		else
		day=day
		end
	table.insert(forecast_day,day)
	table.insert(forecast_day_caps,string.upper(day))
	table.insert(forecast_day_lc,string.lower(day))
	--set month types
	table.insert(forecast_month_short,monthshort[month])
	table.insert(forecast_month_short_caps,string.upper(monthshort[month]))
	table.insert(forecast_month_short_lc,string.lower(monthshort[month]))
		if translate==1 then
		month=monthnames[month]
		else
		month=month
		end
	table.insert(forecast_month,month)
	table.insert(forecast_month_caps,string.upper(month))
	table.insert(forecast_month_lc,string.lower(month))
	--set date
	table.insert(forecast_date,date)
	end--if t~= nil
--intellicast weather icon match
local s,f,t=string.find(allweather,"40_white/(wx_[%d]*).png\"",start)
--convert to conkyweather icon
	if t~=nil then
	table.insert(weather_icon,weathericons..wimage[t]..".png")
	--convert to weather font
	table.insert(weather_font,wfont[t])
	end
--match conditions
local s,f,t=string.find(allweather," /><br />([%a%s%p]*)</td>",start)
	if t~=nil then
	table.insert(conditions,t)
	table.insert(conditions_caps,string.upper(t))
	table.insert(conditions_lc,string.lower(t))
	--set short versions--------------------------------
	local cons=t
		for k,v in pairs(con_short) do
		cons=string.gsub(cons,k,v)
		end
	table.insert(conditions_short,cons)
	table.insert(conditions_short_caps,string.upper(cons))
	table.insert(conditions_short_lc,string.lower(cons))
	-----------------------------------------------------
	end
--match high temp
local s,f,t=string.find(allweather,"\"Hi\">([%p%d]*)&deg",start)
table.insert(high_temp,t)
--match low temp
local s,f,t=string.find(allweather,"\"Lo\">([%p%d]*)&deg",start)
table.insert(low_temp,t)
--match sun rise times
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",start)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_rise,tm.." "..suf)
	table.insert(sun_rise_lc,string.lower(tm.." "..suf))
	table.insert(sun_rise_time,tm)
	end
--match sun set times
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then	
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(sun_set,tm.." "..suf)
	table.insert(sun_set_lc,string.lower(tm.." "..suf))
	table.insert(sun_set_time,tm)
	end
--moon rise
local s,f,t=string.find(allweather,"Rise:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_rise,tm.." "..suf)
	table.insert(moon_rise_lc,string.lower(tm.." "..suf))
	table.insert(moon_rise_time,tm)
	table.insert(moon_rise_ampm,suf)
	table.insert(moon_rise_ampm_lc,string.lower(suf))
	end
--moon set
local s,f,t=string.find(allweather,"Set:</strong> (%d*:%d*%s%u%u)</td>",f)
	if t~=nil then
	--get time only
	local a,b,tm=string.find(t,"([%d%p]*)")
	--get suffix only
	local a,b,suf=string.find(t,"(%u%u)")
		if translate==1 then
		suf=tsuffix[suf]
		else
		suf=suf
		end
	table.insert(moon_set,tm.." "..suf)
	table.insert(moon_set_lc,string.lower(tm.." "..suf))
	table.insert(moon_set_time,tm)
	table.insert(moon_set_ampm,suf)
	table.insert(moon_set_ampm_lc,string.lower(suf))
	end
--match uv index
local s,f,tuv=string.find(allweather,"UV Index:</strong>%s*(%d*%s*%([%a%s]*%))%s*<br />",start)
if tuv~=nil then
	--get just number
	local a,b,unm=string.find(tuv,"(%d*)%s*%([%a%s]*%)")
	--get just text
	local a,b,utx=string.find(tuv,"%d*%s*%(([%a%s]*)%)")
	table.insert(uv_index_num,unm)
		if translate==1 then
		utx=uvindextext[utx]
		else
		utx=utx
		end
	table.insert(uv_index_txt,utx)
	table.insert(uv_index_txt_caps,string.upper(utx))
	table.insert(uv_index_txt_lc,string.lower(utx))
	end
--match humidity
local s,f,t=string.find(allweather,"Humidity:</strong> (%d*)<br />",start)
table.insert(humidity,t)
--match ppt
local s,f,t=string.find(allweather,"Precipitation:</strong> (%d*)<br />",start)
table.insert(precipitation,t)
--match snow %
local s,f,t=string.find(allweather,"Snow Probability:</strong>%s*(%d*)<br />",start)
table.insert(snow,t)
--match cloud coveage
local s,f,t=string.find(allweather,"Cloud Coverage:</strong> (%d*)<br />",start)
table.insert(cloud_cover,t)
--match moon phase
local s,f,t=string.find(allweather,"Moon Phase:</strong> ([%a%s]*) <br />",start)
--set moon phase text
	if t~= nil then
	--set moon phase font and icon
	table.insert(moon_font,moonfontt[t])
	table.insert(moon_icon,moonicont[t])
		if translate==1 then
		t=moonphases[t]
		else
		t=t
		end
	table.insert(moon_phase,t)
	table.insert(moon_phase_caps,string.upper(t))
	table.insert(moon_phase_lc,string.lower(t))
	end
--match wind speeds
local s,f,tmph=string.find(allweather,"Wind Speed:</strong> (%d*)Mph",start)
local tmph=tonumber(tmph)
table.insert(wind_mph,tmph)
local s,f,t=string.find(allweather,"Mph%s*%((%d*)Km,",start)
table.insert(wind_km,t)
local s,f,t=string.find(allweather,"Km,%s*(%d*)Kts%)",start)
table.insert(wind_kts,t)
--match wind direction
local s,f,twd=string.find(allweather,"Wind Direction:</strong> ([%d&;%s%(%a%)]*)%s*</div>",start)
	if twd~=nil then
	local a,b,tdeg=string.find(twd,"(%d*)&deg;")
	table.insert(wind_deg,tdeg)
	--match wind font and nesw   
	local a,b,tnesw=string.find(twd,"%((%a*)%)")
	table.insert(wind_font,windfontt[tnesw])
		if tmph>0 and tmph<19 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph>18 and tmph<38 then
		table.insert(wind_icon,weathericons.."yellow_"..string.lower(tnesw)..".png")
		elseif tmph>37 and tmph<64 then
		table.insert(wind_icon,weathericons.."orange_"..string.lower(tnesw)..".png")
		elseif tmph>63 then
		table.insert(wind_icon,weathericons.."green_"..string.lower(tnesw)..".png")
		elseif tmph==0 then
		table.insert(wind_icon,weathericons.."no_wind.png")
		end
		if translate==1 then
		tnesw=neswtext[tnesw]
		else
		tnesw=tnesw
		end
	table.insert(wind_nesw,tnesw)
	end
if f==nil then break end
start=f
end--while
--#########################################################################################################################################

--#########################################################################
--get location
local a,b,wl=string.find(allweatherdata,"<title>%s*Intellicast%s%p%s(.*)</title>")
weather_location=string.gsub(wl," Extended Forecast in",",")
--#########################################################################

--#########################################################################
--format now weather
--extract current data
--get now weather chunk
local a,b,nowweather=string.find(allweatherdata,">Current Conditions&nbsp(.*)>View Detailed Observations for the last<br />")
now={}
monthlong={Jan="January",Feb="February",Mar="March",Apr="April",May="May",Jun="June",Jul="July",Aug="August",Sep="September",Oct="October",Nov="November",Dec="December"}
local s,f,tnow=string.find(nowweather,"<div style=\"float:right;color:#666;\">  As of ([%d%p%a%s]*) %(Local Time%)")
local s,f,t=string.find(tnow,"(%d*%p%d*%s%a*) on")
--get time only
local a,b,ntm=string.find(t,"(%d*%p%d*)")
--get suffix only
local a,b,nsf=string.find(t,"(%u%u)")
if translate==1 then
suf=tsuffix[nsf]
else
suf=nsf
end
now["time"]=ntm.." "..suf
now["time_lc"]=string.lower(ntm.." "..suf)
now["time_num"]=ntm
now["time_ampm"]=suf
now["time_ampm_lc"]=string.lower(suf)
--get day
local s,f,t=string.find(tnow,"on (%a*)%s%d*")
if translate==1 then
day=daynames[t]
else
day=t
end
now["day"]=day
now["day_caps"]=string.upper(day)
now["day_lc"]=string.lower(day)
--short day names
local ds=dayshort[t]
now["day_short"]=ds
now["day_short_caps"]=string.upper(ds)
now["day_short_lc"]=string.lower(ds)
--get date
local s,f,t=string.find(tnow,"%s(%d%d)%s")
now["date"]=t
--get months
local s,f,t=string.find(tnow,"%d%d%s(%a*)%s%d")
if translate==1 then
mnth=monthlong[t]
now["month_short"]=monthshort[mnth]
now["month_short_caps"]=string.upper(monthshort[mnth])
now["month_short_lc"]=string.lower(monthshort[mnth])
mnth=monthnames[mnth]
else
now["month_short"]=t
now["month_short_caps"]=string.upper(t)
now["month_short_lc"]=string.lower(t)
mnth=monthlong[t]
end
now["month"]=mnth
now["month_caps"]=string.upper(mnth)
now["month_lc"]=string.lower(mnth)
--get year
local s,f,t=string.find(tnow,"%a%a%a%s(%d%d%d%d)")
now["year"]=t
--get weather icon
local s,f,t=string.find(nowweather,"40_white/(wx_[%d]*)%ppng%p%stitle=%p")
now["weather_icon"]=weathericons..wimage[t]..".png"
now["weather_font"]=wfont[t]
--class=%pIcon%p /> ([%a%s]*)%s*</td>
local s,f,t=string.find(nowweather,"class=%pIcon%p /> ([%a%s%p]*)%s*%s*</td>%s*<td class=%pEmpty%p>&nbsp;")
now["conditions"]=t
now["conditions_caps"]=string.upper(t)
now["conditions_lc"]=string.lower(t)
--set short versions------------------------
	local cons=t
	for k,v in pairs(con_short) do
	cons=string.gsub(cons,k,v)
	end
	now["conditions_short"]=cons
	now["conditions_short_caps"]=string.upper(cons)
	now["conditions_short_lc"]=string.lower(cons)
--------------------------------------------
local s,f,t=string.find(nowweather,"Temperature\">([%p%d]*)&deg")
now["temp"]=t
local s,f,t=string.find(nowweather,">Feels Like: ([%p%d]*)&deg;</a>")
now["feels_like"]=t
local s,f,t=string.find(nowweather,">Wind Chill: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["wind_chill"]=t
local s,f,t=string.find(nowweather,">Ceiling: </a></td>%s*<td>([%a%d]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tc=t..ceiling_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tc=unlset
end
now["ceiling"]=tc
now["ceiling_caps"]=string.upper(tc)
now["ceiling_lc"]=string.lower(tc)
--get heat index
local s,f,t=string.find(nowweather,">Heat Index: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["heat_index"]=t
--get visibility
local s,f,t=string.find(nowweather,">Visibility: </a></td>%s*<td>([%a%d%p]*)</td>")
if t~="Unl" then
local s,f,t=string.find(t,"([%d%p]*)")
tv=t..visibility_unit
else
	if translate==1 then unlset=additional.Unl else unlset=t end
tv=unlset
end
now["visibility"]=tv
now["visibility_caps"]=string.upper(tv)
--get dew point
local s,f,t=string.find(nowweather,">Dew Point: </a></td>%s*<td>([%p%d]*)&deg;</td>")
now["dew_point"]=t
--get wind speed
local s,f,t=string.find(nowweather,">Wind: </a></td>%s*<td>(%d*)mph</td>")
local tmph=tonumber(t)
now["wind_mph"]=t..wind_mph_unit
now["wind_mph_caps"]=string.upper(t..wind_mph_unit)
--convert mph to km and knots #################################################
--[[1 mile per hour = 0.869 international nautical mile per hour (knot)
     1 mile per hour = 1.609 kilometers per hour
     1 mile per hour = 0.4470 meter per second
     1 knot = 1.852 kilometers per hour
     1 knot = 0.5144 meter per second
     1 meter per second = 3.6 kilometers per hour]]
now["wind_km"]=round(tonumber(t)*1.609)..wind_km_unit
now["wind_km_caps"]=string.upper(round(tonumber(t)*1.609)..wind_km_unit)
now["wind_kts"]=round(tonumber(t)*0.869)..wind_kts_unit
now["wind_kts_caps"]=string.upper(round(tonumber(t)*0.869)..wind_kts_unit)
--#############################################################################
local s,f,t=string.find(nowweather,">Humidity: </a></td>%s*<td>(%d*)</td>")
now["humidity"]=t
--get wind direction #######################################################
local s,f,twd=string.find(nowweather,">Direction: </a></td>%s*<td style=[%p%a]*>([%d&;%s%(%a%)]*)</td>%s*</tr>")
--check for NA
local a,b,t=string.find(twd,"(%a*)")
local tnesw=t
if tnesw~="NA" then
local a,b,t=string.find(twd,"(%d*)&deg;")
now["wind_deg"]=t..wind_degrees_unit
local a,b,tnesw=string.find(twd,"%((%a*)%)")
	if tmph>0 and tmph<19 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	elseif tmph>18 and tmph<38 then
	now["wind_icon"]=weathericons.."yellow_"..string.lower(tnesw)..".png"
	elseif tmph>37 and tmph<64 then
	now["wind_icon"]=weathericons.."orange_"..string.lower(tnesw)..".png"
	elseif tmph>63 then
	now["wind_icon"]=weathericons.."green_"..string.lower(tnesw)..".png"
	end
now["wind_font"]=windfontt[tnesw]
--################################
	if translate==1 then
	tnesw=neswtext[tnesw]
	else
	tnesw=tnesw
	end
--################################
now["wind_nesw"]=tnesw		
else
	if translate==1 then naset=additional.NA else naset="NA" end
now["wind_deg"]=naset
now["wind_icon"]=weathericons.."no_wind.png"
now["wind_nesw"]=naset
now["wind_font"]=windfontt["N"]
end
--END WIND DIRECTION #######################################################
--get pressure
local s,f,t=string.find(nowweather,">Pressure: </a></td>%s*<td>([%d%p]*)\"</td>")
now["pressure"]=t
--convert pressures ########################################################
--[[ 1 inch of mercury = 25.4 mm of mercury = 33.86 millibars
     = 33.86 hectoPascals]]
now["pressure_mb"]=round(tonumber(t)*33.86)
--##########################################################################
local s,f,t=string.find(nowweather,">Gusts: </a></td>%s*<td>([%d%a]*)</td>")
if t~="NA" then
local s,f,t=string.find(t,"(%d*)")
tg=t..wind_mph_unit
tgkm=round(tonumber(t)*1.609)..wind_km_unit
tgkts=round(tonumber(t)*0.869)..wind_kts_unit
else
	if translate==1 then naset=additional.NA else naset="NA" end
tg=naset
tgkm=naset
tgkts=naset
end
now["wind_gusts"]=tg
now["wind_gusts_caps"]=string.upper(tg)
now["wind_gusts_km"]=tgkm
now["wind_gusts_km_caps"]=string.upper(tgkm)
now["wind_gusts_kts"]=tgkts
now["wind_gusts_kts_caps"]=string.upper(tgkts)
--##########################################################################
--get hourly forecast options hour1--------------------
--get day 1 bit
local s,f,hfc=string.find(nowweather,"<td class=%pHour%p%sstyle=%ppadding%pleft([%a%d%p%s]*)%pdeg%p</strong>",1)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour%p
local a,b,t=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",1)
now["fc_hour1_time"]=t
local a,b,t=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",1)
		if translate==1 then
		t=tsuffix[t]
		else
		t=t
		end
now["fc_hour1_ampm"]=t
now["fc_hour1_ampm_lc"]=string.lower(t)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%p%s%a]*)%s*</td>%s*<td class=%pHour%p",1)
now["fc_hour1_cond"]=t
now["fc_hour1_cond_lc"]=string.lower(t)
now["fc_hour1_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
		for k,v in pairs(con_short) do
		cons=string.gsub(cons,k,v)
		end
	now["fc_hour1_cond_short"]=cons
	now["fc_hour1_cond_short_caps"]=string.upper(cons)
	now["fc_hour1_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",1)
now["fc_hour1_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour1_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",1)
now["fc_hour1_temp"]=t
--end of hour1 data gathering--repeat 2 more times
--get hourly forecast options hour2--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,t=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
now["fc_hour2_time"]=t
local a,b,t=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
		if translate==1 then
		t=tsuffix[t]
		else
		t=t
		end
now["fc_hour2_ampm"]=t
now["fc_hour2_ampm_lc"]=string.lower(t)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour2_cond"]=t
now["fc_hour2_cond_lc"]=string.lower(t)
now["fc_hour2_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
		for k,v in pairs(con_short) do
		cons=string.gsub(cons,k,v)
		end
	now["fc_hour2_cond_short"]=cons
	now["fc_hour2_cond_short_caps"]=string.upper(cons)
	now["fc_hour2_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour2_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour2_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)&deg;</strong></td>",start)
now["fc_hour2_temp"]=t
--end of hour2 data gathering--repeat 1 more times
--get hourly forecast options hour3--------------------
local start=tonumber(b)
--get time and conditions
--<strong>1 PM</strong><br />%s*P Cloudy%s*</td>%s*<td class=%pHour"%p
local a,b,t=string.find(hfc,"<strong>([%d%p]*)[%s%a]*</strong><br",start)
now["fc_hour3_time"]=t
local a,b,t=string.find(hfc,"<strong>[%d%p%s]*([%a]*)</strong><br",start)
		if translate==1 then
		t=tsuffix[t]
		else
		t=t
		end
now["fc_hour3_ampm"]=t
now["fc_hour3_ampm_lc"]=string.lower(t)
local a,b,t=string.find(hfc,"</strong><br%s/>%s*([%a%s%p]*)%s*</td>%s*<td class=%pHour%p",start)
now["fc_hour3_cond"]=t
now["fc_hour3_cond_lc"]=string.lower(t)
now["fc_hour3_cond_caps"]=string.upper(t)
----------set short versions--------------------------------
	local cons=t
		for k,v in pairs(con_short) do
		cons=string.gsub(cons,k,v)
		end
	now["fc_hour3_cond_short"]=cons
	now["fc_hour3_cond_short_caps"]=string.upper(cons)
	now["fc_hour3_cond_short_lc"]=string.lower(cons)
-------------------------------------------------------------
--get weather icon and font
local a,b,t=string.find(hfc,"32_white/(wx_[%d]*)%ppng%p%stitle=%p",start)
now["fc_hour3_wicon"]=weathericons..wimage[t]..".png"
now["fc_hour3_wfont"]=wfont[t]
--get temperature
--><strong>-5&deg;</strong></td>
local a,b,t=string.find(hfc,"><strong>([%p%d]*)",start)
now["fc_hour3_temp"]=t
--end of hour3 data gathering--finished for all hours
--ALERTS###############################################################
if alert_check==1 then
--set tables
alert_type={}
alert_issued={}
if alerttest~=0 then
alert_icon=weathericons.."icon_alert_1.gif"
--extract information into tables
local start=0
local f=1
while f~=nil do
local s,f,t=string.find(alertdata,"><strong class='Alert'>([%a%s]*)</strong><br/>",start)
	if t~=nil then
	table.insert(alert_type,string.upper(t))
	end--if t~=nil
local s,f,t=string.find(alertdata,"<br />([%d%a%s:]*)<br /><br />",start)
	if t~=nil then
	table.insert(alert_issued,t)
	end--if t~=nil
if f==nil then break end
start=f
alert_number=#alert_type
end--while
else
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"NO ALERTS")
table.insert(alert_issued,"")
alert_number=0
end--alerttest~=nil
else
alert_type={}
alert_issued={}
alert_icon=weathericons.."icon_alert_0.gif"
table.insert(alert_type,"alerts turned off")
table.insert(alert_issued,"")
alert_number=0
end--if alert check ###########################################
--###############end of data processing########################

--#########################################################################
if testing==0 then
processall=0
print ("processing complete")
elseif testing==1 then
processall=1
end--if testing ==0
--###################################################################################
end--of data processing section #####################################################
--###################################################################################
if processall==0 or testing==1 then
_G.weather_script()
end
--#########################################################################################################
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--end--####### end of if updates>5 #############################
--#########################################################################################################

cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
--######################################
end-- end main function ################
--######################################
function round(num)
	local idp=tonumber(settings_table[5])
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end--of round function #################################################################
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--string split #######################################################################
function xout(txj)--c,a,f,fs,x,y,txt,j ##################################################
c=nil
c=(txj.c or default_color)
a=nil
a=(txj.a or default_alpha)
f=nil
f=(txj.f or default_font)
fs=nil
fs=(txj.fs or default_font_size)
x=nil
x=(txj.x or 0)
y=nil
y=(txj.y or 0)
txt=nil
txt=(txj.txt or "set txt")
j=nil
j=(txj.j or "l")
	local function col(c,a)
	return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
	end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local text=string.gsub(txt," ","_")
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local wx=extents.width
cairo_set_source_rgba (cr,col(c,a))
if j=="l" then
cairo_move_to (cr,x,y)
adx=wx
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
adx=wx/2
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
adx=0
end
cairo_show_text (cr,txt)
cairo_stroke (cr)
nextx=nil
nextx=adx+x
return nextx
end--function xout ###################################################################
function out(tx)--####################################################################
c=nil
c=(tx.c or default_color)
a=nil
a=(tx.a or default_alpha)
f=nil
f=(tx.f or default_font)
fs=nil
fs=(tx.fs or default_font_size)
x=nil
x=(tx.x or 0)
y=nil
y=(tx.y or 0)
txt=nil
txt=(tx.txt or "set txt")
local function col(c,a)
return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
cairo_set_source_rgba (cr,col(c,a))
cairo_move_to (cr,x,y)
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--function out ###################################################################
function image(im)--#################################################################
x=nil
x=(im.x or 0)
y=nil
y=(im.y or 0)
w=nil
w=(im.w or default_image_width)
h=nil
h=(im.h or default_image_height)
file=nil
file=tostring(im.file)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(w)
end
if tonumber(h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x, y)
imlib_free_image()
show=nil
end--function image ##################################################################
--END OF SCRIPT

.v9000_config.lua

--SETTINGS AND PREFERENCES--SETTINGS AND PREFERENCES--SETTINGS AND PREFERENCES
function weather_settings()--#### DO NOT EDIT THIS LINE #################
--#######################################################################
--[[set update interval.  update interval is based on conky cycles
if your conkyrc has an update_interval of 1, ie updates every second
then if you enter 60 below, the script will update every 60 seconds
however, if your conkyrc update_interval is 10, then by setting 60 below,
v9000 will update every 600 seconds (10 minutes)]]
local update_interval=1800 --avoid an interval of 1
--get web address by going to the intellicast site and entering your location in the box
--click on "Extended Forecast" to get the necessary address
local web="http://www.intellicast.com/Local/Forecast.aspx?unit=F&location=USAZ0166"--insert unit=C& after aspx? for C
--set location of weather images (replace "benjamin" with your own username)
local weathericons="/home/michael/v9000/additional_files/weathericons/"
--short conditions setup
--this section allows you to set your own shorter terms to replace the terms foud in conditions
--to use for current: now["conditions_short"], now["conditions_short_caps"], now["conditions_short_lc"]
--to use for forecast: conditions_short[n], conditions_short_caps[n], conditions_short_lc[n]
--ALSO USE THIS TABLE TO ENTER CONDITIONS TRANSLATIONS
con_short={--start of table, put entries below in form eg: ["Thunderstorm"]="T.Strm",
["Wind Early"]="Wnd AM",
["Snow Showers"]="Sn Shws",
["Thunderstorm"]="T.Strm",--remember to put a comma at the end of every entry
["Scattered"]="Scat",
["Few Snow Showers"]="Fw Sn Shws",
["Wind"]="Wnd",
["Showers"]="Shws",
}--this bracket closes the table
--the script is capable of converting between several unit types
--set how many decimal places you want the conversions to show
local decimal_places=1
--some weather data options need to come with their own units attached as they can be NA on occasion
--set here what you want to have for units, or set "" for nothing
--include spaces, if desired, for formatting purposes. 
--NOTE ALSO EDIT THESE SETTINGS FOR TRANSLATION PURPOSES
local visibility_unit=" mi"
local wind_mph_unit=" mph"
local wind_km_unit=" kmh"
local wind_kts_unit=" kts"
local ceiling_unit=" ft"
local wind_degrees_unit="°"
--do you want the script to use translation tables?
--set 1 if you want to translate, 0 if not.
--the translation tables are located below
local translate=0
--set alerts on or off, set to 0 so that the script does not check for alerts
--set 1 to check for alerts
local alert_check=1
--#######################################################################
--TRANSLATION TABLES, activate by setting translate=1 above
--use con_short table above to translate weather conditions
--edit units settings above to complete translation
--translate NESW text
neswtext={
S="t_S",
SSW="tsetSSW",
SW="t_SW",
WSW="t_WSW",
W="t_W",
WNW="t_WNW",
NW="t_NW",
NNW="t_NNW",
N="t_N",
NNE="t_NNE",
NE="t_NE",
ENE="t_ENE",
E="t_E",
ESE="t_ESE",
SE="t_SE",
SSE="t_SSE",
}--end of  N E S W text table
--translate time suffix
tsuffix={
AM="t_AM",
PM="t_PM",
}--end of time suffix table
--enter translations for uv index text
uvindextext={
["Low"]="t_Low",
["Moderate"]="t_Moderate",
["High"]="t_High",
["Very High"]="t_Very High",--format is different because of the space in the text
["Extreme"]="t_Extreme",
}--end of uv text table
--enter translations for moonpahse
moonphases={
["New"]="t_New",
["Full"]="t_Full",
["First Quarter"]="t_First Quarter",
["Last Quarter"]="t_Last Quarter",
["Waning Gibbous"]="t_Waning Gibbous",
["Waning Crescent"]="t_Waning Crescent",
["Waxing Crescent"]="t_Waxing Crescent",
["Waxing Gibbous"]="t_Waxing Gibbous",
}--end of moon phase table
--enter translations for FULL day names
daynames={
Monday="t_Monday",
Tuesday="t_Tuesday",
Wednesday="t_Wednesday",
Thursday="t_Thursday",
Friday="t_Friday",
Saturday="t_Saturday",
Sunday="t_Sunday",
}--end day names table
--enter translations for SHORT day names
dayshort={
Monday="t_Mon",
Tuesday="t_Tue",
Wednesday="t_Wed",
Thursday="t_Thu",
Friday="t_Fri",
Saturday="t_Sat",
Sunday="t_Sun"
}--end short day names table
--enter translation for FULL month names
monthnames={
January="t_January",
February="t_February",
March="t_March",
April="t_April",
May="t_May",
June="t_June",
July="t_July",
August="t_August",
September="t_September",
October="t_October",
November="t_November",
December="t_December"
}--end of month name translations
--enter translations for SHORT month names
monthshort={
January="t_Jan",
February="t_Feb",
March="t_Mar",
April="t_Apr",
May="t_May",
June="t_Jun",
July="t_Jul",
August="t_Aug",
September="t_Sep",
October="t_Oct",
November="t_Nov",
December="t_Dec"
}--end of short month name translations
--enter some additional translations
additional={
NA="t_NA",
Unl="t_Unl"--for ceiling data option
}--end of additional translations
--END OF TRANSLATION TABLES
--#######################################################################
--NOTE if you make changes to these settings, they will only take effect at the next weather update
--or after killall conky and restart
--#######################################################################
if translate==1 then
return {update_interval,web,weathericons,con_short,decimal_places,visibility_unit,wind_mph_unit,wind_km_unit,wind_kts_unit,ceiling_unit,wind_degrees_unit,translate,alert_check,neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort,additional}
else
return {update_interval,web,weathericons,con_short,decimal_places,visibility_unit,wind_mph_unit,wind_km_unit,wind_kts_unit,ceiling_unit,wind_degrees_unit,translate,alert_check}
end
end--OF SETTINGS AND PREFERENCES ########################################
--#######################################################################

weather_script.lua

--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION--DISPLAY FUNCTION-
_G.weather_script = function()--#### DO NOT EDIT THIS LINE ##############
--#######################################################################
--these tables hold the coordinates for each repeat do not edit #########
top_left_x_coordinate={}--###############################################
top_left_y_coordinate={}--###############################################
--#######################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="mono"--font must be in quotes
default_font_size=12
default_color=0xffffff--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
starty=15
gap=15
ypos=0
ypos=starty+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=15,y=ypos,txt=weather_location})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=15,y=ypos,txt="Current Weather for "..now["time"]})
image({x=20,y=55,h=40,w=40,file=now["weather_icon"]})
image({x=204,y=30,h=50,w=50,file=now["wind_icon"]})
--data titles
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=15,y=ypos,txt="Conditions:"})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=70,y=ypos,txt="Temperature:"})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=70,y=ypos,txt="Feels Like:"})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=70,y=ypos,txt="      Wind:"})
--output of data options
ypos=0
ypos=starty+gap+gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=105,y=ypos,txt=now["conditions_short"]})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=170,y=ypos,txt=now["temp"].."°"})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=170,y=ypos,txt=now["feels_like"].."°"})
ypos=gap+ypos
out({c=0xffffff,a=1,f="mono",fs=12,x=170,y=ypos,txt=now["wind_mph"]})

out({x=15,y=115,txt="NEXT 3 HOURS"})
image({w=30,h=30,x=20,y=125,file=now["fc_hour1_wicon"]})--good
out({x=80,y=135,txt=now["fc_hour1_time"].." "..now["fc_hour1_ampm"]..".  TEMP: "..now["fc_hour1_temp"].."°"})
out({x=80,y=150,txt=now["fc_hour1_cond"]})

image({w=30,h=30,x=20,y=160,file=now["fc_hour2_wicon"]})--good
out({x=80,y=170,txt=now["fc_hour2_time"].." "..now["fc_hour2_ampm"]..".  TEMP: "..now["fc_hour2_temp"].."°"})
out({x=80,y=185,txt=now["fc_hour2_cond"]})

image({w=30,h=30,x=20,y=195,file=now["fc_hour3_wicon"]})--good
out({x=80,y=205,txt=now["fc_hour3_time"].." "..now["fc_hour3_ampm"]..".  TEMP: "..now["fc_hour3_temp"].."°"})
out({x=80,y=220,txt=now["fc_hour3_cond"]})
--########################################################################################
--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=4
topy=240
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
ady=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,ady
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do--start of day repeat, do not edit ########
local tlx=top_left_x_coordinate[i]--sets top left x position for each repeat ###################
local tly=top_left_y_coordinate[i]--sets top left y position for each repeat ###################
--########################################################################################
out({c=0xffffff,a=1,f="mono",fs=12,x=tlx,y=tly,txt=forecast_day[i].." "..forecast_date[i]})
image({x=tlx,y=tly+5,h=30,w=30,file=weather_icon[i]})
out({c=0xffffff,a=1,f="mono",fs=12,x=tlx+35,y=tly+15,txt=high_temp[i].."°/"..low_temp[i].."°"})
out({c=0xffffff,a=1,f="mono",fs=12,x=tlx,y=tly+50,txt=conditions_short[i]})
--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
--ALERTS SECTION
--show alert icon
image({x=0,y=390,h=20,w=20,file=alert_icon})
--show number of alerts
out({x=24,y=408,fs=20,txt=alert_number})
--display alert information
display_alerts=2--set number of alerts to show,set 0 to show all
top_left_alert_x=50--set top left coordinates for entire alerts section
top_left_alert_y=400--^alerts will display in a single column
alert_gap=40--sets the gap between the TOP of one alert and the Top of the next alert
--#######################################################################################################################################
if alert_number==0 then noal=1 elseif alert_number~=0 and display_alerts>alert_number then noal=alert_number else noal=display_alerts end
for i=1,noal do--start of alerts display section. do not edit ###########################################################################
local tlx=top_left_alert_x--write output relative to tlx #################################
local tly=top_left_alert_y+((i-1)*alert_gap)--write output relative to tlx ###############
--########################################################################################
out({c=0xffffff,a=1,f="mono",fs=8,x=tlx,y=tly,   txt=alert_type[i]})
out({c=0xffffff,a=1,f="mono",fs=8,x=tlx,y=tly+15,txt=alert_issued[i]})
--########################################################################################
end--of alert display section ############################################################
--########################################################################################

--########################################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ---
--#######################################################################
end--of weather_display function do not edit this line ##################
--#######################################################################

Thanks.

Offline

Help fund CrunchBang, donate to the project!

#875 2013-02-16 02:41:29

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,691
Website

Re: weather in conky (LUA scripts) updated 12/26/13!

@ impantsless

Your conky-weather tells the story:

lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
lua_load ~/v9000/weather_testing.lua

You are running the "test" lua that gives all the possible outputs.  Not a real weather script.

Try one of these:
~/v9000/weather_script.lua
~/v9000/s11template.lua

lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
##lua_load ~/v9000/weather_testing.lua
lua_load ~/v9000/weather_script.lua
##lua_load ~/v9000/s11template.lua

## Blank line required after TEXT ##
TEXT

abvxMkcU.jpg

or:

lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
##lua_load ~/v9000/weather_testing.lua
##lua_load ~/v9000/weather_script.lua
lua_load ~/v9000/s11template.lua

## Blank line required after TEXT ##
TEXT

aclEzKqD.jpg

Those are two working examples for you to start with.

Did you get your location code from weather.com ?

Last edited by Sector11 (2013-02-16 02:42:15)


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Online

Board footer

Powered by FluxBB

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

Debian Logo