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!

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 ###################################################################

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

Offline

Be excellent to each other!

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

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

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!

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!

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

Offline

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

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

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

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, )

Offline

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

McLovin
#! CrunchBanger
From: my computer chair
Registered: 2009-02-28
Posts: 105
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?

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: 105
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!

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: 105
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.

Offline

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

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

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

local username = "mclovin"

Offline

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

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

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

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

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!

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: 459

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: 459

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

now["conditions_short_lc"]

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: 459

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

shaded='yes'

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)

Offline

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

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

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

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

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: 459

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

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

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!

[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
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

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

Offline

#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!

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

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!

##############################################
#  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}

Offline

Help fund CrunchBang, donate to the project!

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

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

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

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

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

Offline

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.
Server: bleh

Debian Logo