SEARCH

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

You are not logged in.

#876 2013-02-16 18:16:43

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

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

Thanks, that worked. I appreciate the help.

Offline

Help fund CrunchBang, donate to the project!

#877 2013-02-16 18:52:47

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!

impantsless wrote:

Thanks, that worked. I appreciate the help.

Your welcome.  When you "make your own" I hope you come and share it with us.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#878 2013-03-12 23:04:26

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

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

It seems that if there is an NA response from Intellicast, it causes a crash at that point in the script, for example, if I go to intellicast to look up the weather in my area, it has everything but a few items show na for some reason, and when the v9000 lua config i have set up hits that point, it stops and shows no more info at all. I've downloaded a new v9000 package, and done a whole new setup, but the na response is causing it to stop. Not sure if this is known at all, or if anyone else has this issue, but thought I would put it out there, and see if anyone has a solution to it.

here is my weather lua just for referance

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbang.org/forums/viewtopic.php?id=16100

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

 mrppeachys LUA Tutorial
 http://crunchbang.org/forums/viewtopic.php?id=17246
 This config originally made by Sector11, and then edited by myself (McLovin) on 3/1/2013
]]
_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="Antipasto"--font must be in quotes
default_font_size=12
default_color=0xffffff	--white
default_alpha=1		--fully opaque
default_image_width=50
default_image_height=50
-- ## New Options ###
default_face="normal"
-- "normal" for normal/normal
-- "bold" for normal/bold
-- "italic" for italic/normal
-- "bolditalic" for italic/bold
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

-- =============================================================================
-- Moon Phase - Top Center Circle ----------------------------------------------
   out({c=0xFAFAEC,fs=15,a=1,x=175,y=370,txt="Moon Phase:"})
   out({c=0x48D1CC,fs=15,a=1,x=155,y=385,txt=moon_phase[1]})
   image({x=090,y=384,w=162,h=162,file=weather_icon[1]})
   out({c=0x48D1CC,a=1,f="Antipasto:face=bold",fs=20,x=85,y=530,txt=now["conditions"]})
   out({c=0xFAFAEC,a=1,f="Antipasto:face=bold",fs=18,x=100,y=555,txt="Feels Like:"})
   out({c=0x48D1CC,a=1,f="Antipasto:face=bold",fs=18,x=200,y=555,txt=now["feels_like"].."°"})
-- Sun & Moon Rise -------------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=10,y=350,txt="Sunrise"})
     out({c=0xFAFAEC,a=1,x=65,y=350,txt=sun_rise_24[1]})
   out({c=0xC0C0C0,a=1,x=245,y=350,txt="Moonrise"})
      out({c=0xC0C0C0,a=1,x=310,y=350,txt=moon_rise_24[1]})
-- Sun & Moon Set --------------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=10,y=415,txt="Sunset"})
      out({c=0xFAFAEC,a=1,x=65,y=415,txt=sun_set_24[1]})
   out({c=0xC0C0C0,a=1,x=245,y=415,txt="Moonset"})
     out({c=0xC0C0C0,a=1,x=310,y=415,txt=moon_set_24[1]})
     image({x=250,y=350,w=60,h=60,file=moon_icon[1]})
      image({x=15,y=350,w=70,h=70,file='/home/mclovin/v9000/additional_files/weathericons/32.png'})
-- Forecast for Today --- 9 o'clock --------------------------------------------
   out({c=0xFAFAEC,f="Antipasto:face=bold",fs=25,a=1,x=25,y=440,txt="Temp:"})
   out({c=0xFAFAEC,f="Antipasto:face=bold",fs=20,a=1,x=0,y=465,txt="Hi:"})
   out({c=0xFF4800,f="Antipasto:face=bold",fs=20,a=1,x=45,y=465,txt=high_temp[1].."°"})
   out({c=0xFAFAEC,f="Antipasto:face=bold",fs=20,a=1,x=0,y=485,txt="Low:"})
   out({c=0x00BFFF,f="Antipasto:face=bold",fs=20,a=1,x=55,y=485,txt=low_temp[1].."°"})
   out({c=0xFAFAEC,f="Antipasto:face=bold",fs=20,a=1,x=0,y=505,txt="Current:"})
   out({c=0x48D1CC,f="Antipasto:face=bold",fs=20,a=1,x=87,y=505,txt=now["temp"].."°"})
-- Wind Info --- 3 o'clock -----------------------------------------------------
   image({x=280,y=435,w=60,h=60,file=now["wind_icon"]})
   out({c=0x48D1CC,a=1,x=280,y=435,txt=now["wind_deg"]})
   out({c=0x48D1CC,a=1,x=315,y=435,txt=now["wind_nesw"]})
   out({c=0xFAFAEC,a=1,x=285,y=505,txt="@ :"})
   out({c=0x48D1CC,a=1,x=305,y=505,txt=now["wind_mph"]})
-- Humidity --- left -----------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=005,y=525,txt="Hum:"})
      out({c=0x48D1CC,a=1,x=040,y=525,txt=now["humidity"].."%"})
-- Dew Point --- right ---------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=270,y=525,txt="Dew P:"})
      out({c=0x48D1CC,a=1,x=315,y=525,txt=now["dew_point"].."°"})
-- Chance of Rain --- left -----------------------------------------------------
   out({c=0xFAFAEC,a=1,x=005,y=540,txt="Rain:"})
      out({c=0x48D1CC,a=1,x=040,y=540,txt=precipitation[1].."%"})
      -- Ceiling --- right -----------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=255,y=540,txt="Ceiling:"})
      out({c=0x48D1CC,a=1,x=295,y=540,txt=now["ceiling"]})
-- Barometric Pressure --- left ------------------------------------------------
out({c=0xFAFAEC,a=1,x=005,y=555,txt="BP:"})
	out({c=0x48D1CC,a=1,x=030,y=555,txt=now["pressure_mb"].." mb"})
-- Cloud Cover --- right -------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=240,y=555,txt="Cloud Cover:"})
      out({c=0x48D1CC,a=1,x=315,y=555,txt=cloud_cover[1].."%"})
-- something here --. left -----------------------------------------------------
   -- need something here
      -- need something here
-- UV --- left -----------------------------------------------------------------
out({c=0xFAFAEC,a=1,x=005,y=570,txt="UV:"})
   out({c=0x48D1CC,a=1,x=030,y=570,txt=uv_index_num[1]})
      out({c=0x48D1CC,a=1,x=050,y=570,txt=uv_index_txt[1]})

-- =============================================================================
-- Forecast for NOW & the next 3 hours -----------------------------------------
      out({c=0xFAFAEC,a=1,x=085,y=589,txt="Current & the next 3 Hours"})

-- Current for Today --- 6 o'clock ---------------------------------------------
out({c=0x48D1CC,x=020,y=605,txt="Current"})
   image({x=005,y=607,w=80,h=80,file=now["weather_icon"]})
   out({c=0xFAFAEC,a=1,x=005,y=690,txt="T"})
      out({c=0x9ACD32,fs=14,a=1,x=015,y=690,txt=now["temp"].."°"})
   out({c=0xFAFAEC,a=1,x=050,y=690,txt="±"})
      out({c=0x00BFFF,fs=14,a=1,x=060,y=690,txt=now["feels_like"].."°"})
-- 1st hour
out({c=0x48D1CC,x=120,y=605,txt=now["fc_hour1_time"]..":00"})
   image({x=090,y=607,w=80,h=80,file=now["fc_hour1_wicon"]})
   out({c=0x00BFFF,fs=18,x=125,y=695,txt=now["fc_hour1_temp"] .."°"})
-- 2nd hour
out({c=0x48D1CC,x=205,y=605,txt=now["fc_hour2_time"]..":00"})
   image({x=175,y=607,w=80,h=80,file=now["fc_hour2_wicon"]})
   out({c=0x00BFFF,fs=18,x=210,y=695,txt=now["fc_hour2_temp"] .."°"})
-- 3rd hour
out({c=0x48D1CC,x=290,y=605,txt=now["fc_hour3_time"]..":00"})
   image({x=260,y=607,w=80,h=80,file=now["fc_hour3_wicon"]})
   out({c=0x00BFFF,fs=18,x=295,y=695,txt=now["fc_hour3_temp"] .."°"})
-- line

-- FORECAST for the next 9 days ------------------------------------------------
-- x = l|r  y = u|d
datay=580
datayy=18 --datay+(datayy*1)

datafx1=20

imgx=35
imgy=730
imgyy=80 -- imgy+(imgyy*1)
-- =============================================================================
-- Forecast day 2 -- x = l|r  y = u|d
out({c=0x9ACD32,a=1,x=datafx1*0.4,y=datay+(datayy*8),txt=forecast_day[2]})
 out({c=0x9ACD32,a=1,x=datafx1*4,y=datay+(datayy*8),txt=forecast_date[2]})
image({x=imgx*1,y=imgy,file=weather_icon[2]})
out({c=0xFF8C00,a=1,x=datafx1*0.2,y=datay+(datayy*8.9),txt="Hi"})
out({c=0xFF8C00,a=1,x=datafx1*0.4,y=datay+(datayy*9.5),txt=high_temp[2].."°"})
out({c=0x00BFFF,a=1,x=datafx1*0.2,y=datay+(datayy*10.4),txt="Low"})
out({c=0x00BFFF,a=1,x=datafx1*0.4,y=datay+(datayy*11),txt=low_temp[2].."°"})
-- Forecast day 3 -- x = l|r  y = u|d
out({c=0x9ACD32,a=1,x=datafx1*6.6,y=datay+(datayy*8),txt=forecast_day[3]})
 out({c=0x9ACD32,a=1,x=datafx1*10,y=datay+(datayy*8),txt=forecast_date[3]})
image({x=imgx*4.2,y=imgy,file=weather_icon[3]})
out({c=0xFF8C00,a=1,x=datafx1*6.3,y=datay+(datayy*8.9),txt="Hi"})
out({c=0xFF8C00,a=1,x=datafx1*6.5,y=datay+(datayy*9.5),txt=high_temp[3].."°"})
out({c=0x00BFFF,a=1,x=datafx1*6.3,y=datay+(datayy*10.4),txt="Low"})
out({c=0x00BFFF,a=1,x=datafx1*6.5,y=datay+(datayy*11),txt=low_temp[3].."°"})
-- Forecast day 4 -- x = l|r  y = u|d
out({c=0x9ACD32,a=1,x=datafx1*12.4,y=datay+(datayy*8),txt=forecast_day[4]})
 out({c=0x9ACD32,a=1,x=datafx1*16,y=datay+(datayy*8),txt=forecast_date[4]})
image({x=imgx*7.52,y=imgy,file=weather_icon[4]})
out({c=0xFF8C00,a=1,x=datafx1*12.2,y=datay+(datayy*8.9),txt="Hi"})
out({c=0xFF8C00,a=1,x=datafx1*12.4,y=datay+(datayy*9.5),txt=high_temp[4].."°"})
out({c=0x00BFFF,a=1,x=datafx1*12.2,y=datay+(datayy*10.4),txt="Low"})
out({c=0x00BFFF,a=1,x=datafx1*12.4,y=datay+(datayy*11),txt=low_temp[4].."°"})
-- =============================================================================
-- Forecast day 5 -- x = l|r  y = u|d
  out({c=0x9ACD32,a=1,x=datafx1*0.4,y=datay+(datayy*17),txt=forecast_day_short[5]})
   out({c=0x9ACD32,a=1,x=datafx1*2.1,y=datay+(datayy*17),txt=forecast_date[5]})
    out({c=0x9ACD32,a=1,x=datafx1*3.7,y=datay+(datayy*17),txt=forecast_month_short[5]})
  image({x=imgx*0.6,y=imgy+(imgyy*1.2),file=weather_icon[5]})
  out({c=0xFF8C00,a=1,x=datafx1*0.4,y=datay+(datayy*18.5),txt=high_temp[5].."°"})
  out({c=0x00BFFF,a=1,x=datafx1*0.4,y=datay+(datayy*20),txt=low_temp[5].."°"})
-- Forecast day 6 -- x = l|r  y = u|d
  out({c=0x9ACD32,a=1,x=datafx1*6.6,y=datay+(datayy*17),txt=forecast_day_short[6]})
   out({c=0x9ACD32,a=1,x=datafx1*8.2,y=datay+(datayy*17),txt=forecast_date[6]})
    out({c=0x9ACD32,a=1,x=datafx1*9.8,y=datay+(datayy*17),txt=forecast_month_short[6]})
  image({x=imgx*4.18,y=imgy+(imgyy*1.2),file=weather_icon[6]})
  out({c=0xFF8C00,a=1,x=datafx1*6.7,y=datay+(datayy*18.5),txt=high_temp[6].."°"})
  out({c=0x00BFFF,a=1,x=datafx1*6.7,y=datay+(datayy*20),txt=low_temp[6].."°"})
-- Forecast day 7 -- x = l|r  y = u|d
  out({c=0x9ACD32,a=1,x=datafx1*12.4,y=datay+(datayy*17),txt=forecast_day_short[7]})
   out({c=0x9ACD32,a=1,x=datafx1*14.3,y=datay+(datayy*17),txt=forecast_date[7]})
    out({c=0x9ACD32,a=1,x=datafx1*15.7,y=datay+(datayy*17),txt=forecast_month_short[7]})
  image({x=imgx*7.49,y=imgy+(imgyy*1.2),file=weather_icon[7]})
  out({c=0xFF8C00,a=1,x=datafx1*12.4,y=datay+(datayy*18.5),txt=high_temp[7].."°"})
  out({c=0x00BFFF,a=1,x=datafx1*12.4,y=datay+(datayy*20),txt=low_temp[7].."°"})
-- =============================================================================

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

and this is my .v9000_config.lua

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

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

Offline

#879 2013-03-13 04:33:36

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

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

Hi McLovin

I just popped in to look around and I saw your post.

I haven't had any time for lua or conky for a while, but I should be able to look into whats causing the problem in a few days.

When you get the problem could you take a screenshot of the intellicast page for your area so i can see what data it is showing as NA

thanks

Offline

#880 2013-03-13 16:43:24

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!

@ McLovin

What happens if you kill the conky and re-run it?
Does it refresh the info?


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#881 2013-03-13 16:58:52

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

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

i have a little problem when i run this script my v9000.
i could create a second instance of v9000 (for another location) but because of this: i only need several datas (sunrise, sunset) and NOT the whole powerful v9000.

generally it works but the interval has to run once!

function grab(wert,tz)

--[[
 grove greek observatory, new south wales
 location code: ASXX0001
 zeitzone:  UTC +10:30
 
 paranal/la silla: 
 location code: CIXX0047
 zeitzone: MEZ+4
 
 yellowknife, north western terriotory
 location code: CAXX0557
 zeitzone: GMT -7 Stunde
 
]]--

upd=tonumber(conky_parse("${updates}"))
intv=100
timer=(upd % intv)
if timer==0 or conky_start==1 then
used_table={}
local loc_code=tz
local adr="http://www.intellicast.com/Local/Forecast.aspx?location="..loc_code
local grab_file = io.popen("curl "..adr)
grab_out=grab_file:read("*a")
grab_file:close()
conky_start=nil
end

local grab_text = nil
local s = nil
local f = nil

if wert=='sunrise' then
 s,f,grab_text=string.find(grab_out,"Rise:</strong> (%d*:%d*%s%u%u)</td>")
 local a,b,tm=string.find(grab_text,"([%d%p]*)") -- uhrzeit / only time
 local a,b,suf=string.find(grab_text,"(%u%u)")  -- endung / ending
 grab_text=convert24(tm,suf)
elseif wert=="sunset" then
 s,f,grab_text=string.find(grab_out,"Set:</strong> (%d*:%d*%s%u%u)</td>")
 local a,b,tm=string.find(grab_text,"([%d%p]*)") -- uhrzeit
 local a,b,suf=string.find(grab_text,"(%u%u)") -- endung
 grab_text=convert24(tm,suf)
elseif wert=="time" then
 s,f,grab_text=string.find(grab_out,"(%d*%p%d*%s%a*) on")
 local a,b,tonly=string.find(grab_text,"(%d*%p%d*)")
 local a,b,sonly=string.find(grab_text,"(%u%u)")
 grab_text=convert24(tonly,sonly)
end


--local s,f,grab_text=string.find(grab_out,"<div style=\"float:right;color:#666;\">  As of ([%d%p%a%s]*) %(Local Time%)")


--print (grab_text)
return grab_text

end

Last edited by lionhead (2013-03-13 17:52:15)

Offline

#882 2013-03-19 16:17:52

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

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

@mrpeachy

do u have an idea why the option now["conditions"] is still in english?

now["conditions_short"] is in german smile


here you will find an improved version of my v9000:

-- weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
-- official update by mrpeachy
-- additional features by lionhead, arclance and dk75
-- last update 07.05.2013
require 'cairo'
require 'imlib2'
local username = os.getenv("USERNAME")
--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"
local username = "alexander"
package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

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

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

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

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

function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end--string split


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

-- all following functions are working stand-alone
-- they can be copied because they do not have any dependance to work

function out(txj) -- function to output text
	local extents=cairo_text_extents_t:create()
	tolua.takeownership(extents)
	local blurred=nil
	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 face=txj.face					or default_face			or "normal"
	local size=txj.size     			or default_size         or "normal_c"
	--------------------------------------------------------------------
	local hj=txj.hj						or default_hj			or "l"
	--local vj=txj.vj						or default_vj			or "n"
	--------------------------------------------------------------------
	local shaded=txj.shaded				or default_shaded		or "no"
	local shade_color=txj.shade_color	or default_shade_color	or 0x000000
	local shade_alpha=txj.shade_alpha	or default_shade_alpha	or 1
	--------------------------------------------------------------------
	local underline=txj.underline     	or default_underline    or "no"
	local line_color=txj.line_color    	or   default_line_color or   c
	local line_space=txj.line_space    	or default_line_space   or  5
	local line_width=txj.line_width     or default_line_width   or  1
	--------------------------------------------------------------------
	local number=txj.number  or 8
	local radius=txj.radius or 1.75
	local blurred=txj.blurred or no
	local blurred_color=txj.blurred_color or c
	local blurred_alpha=txj.blurred_alpha or 1
	--------------------------------------------------------------------
	local border=txj.border
	local bc=txj.bc or 0x000000
	local ba=txj.ba or 1
	local bw=txj.bw or 1
	--------------------------------------------------------------------
	cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	----------------------
	if size=="big_c" then
	txt=string.upper(txt) -- converts letter into capitals
	elseif size=="small_c" then
	txt=string.lower(txt) -- converts letter into lower case
	elseif size=="normal_c" then
	txt=txt
	end
	----------------------
	cairo_set_font_size (cr, fs)
	cairo_text_extents(cr,txt,extents)
	local wx=extents.x_advance -- measure spaces too
	local wd=extents.width
	local hy=extents.height
	local bx=extents.x_bearing
	local by=extents.y_bearing+hy
	local tx=x
	local ty=y
	--set horizontal alignment
	if hj=="l" then
		x=x-bx
	elseif hj=="c" then
		x=x-((wx-bx)/2)-bx
	elseif hj=="r" then
		x=x-wx
	end
	-- set shade
	if shaded == "yes" then
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,col(shade_color,shade_alpha))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	end -- if
	-------------------------------------------------
	cairo_move_to (cr,x,y)
	cairo_set_source_rgba (cr,col(c,a))
	cairo_show_text (cr,txt)
	cairo_stroke (cr)
	--------------------------------------------------
	if border=="yes" then
	-- draw border (line around text)
    cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	cairo_set_font_size (cr, fs);
	cairo_move_to (cr, x, y);
	cairo_text_path (cr,txt);
	cairo_set_source_rgba (cr,col(c,a));
	cairo_fill_preserve (cr);
	cairo_set_source_rgba (cr,col(bc,ba));
	cairo_set_line_width (cr, bw);
	cairo_stroke (cr);
	end

	-- #################################################################
	-- ## decrease alpha if u want to use a small size #################
	-- ## for example fs=12,blurred="yes",ba=0.1 #######################
	-- #################################################################
	if blurred=="yes" then
	 radi=radius
	 inum=number
	 horiz=x
	 verti=y
	
	 for i=1,inum do
	 deg=360/inum
	 text_arc=((2*math.pi/inum)*i)
	 txs=0+radi*(math.sin(text_arc))
	 tys=0-radi*(math.cos(text_arc))
	 -------------------------------------------------------------------
	 cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	 -------------------------------------------------------------------
	 cairo_set_font_size (cr, fs);
	 cairo_set_source_rgba (cr, col(blurred_color,blurred_alpha));
	 cairo_move_to (cr, txs+horiz, tys+verti);
	 cairo_show_text (cr, txt)
     end
	 
	elseif blurred=="no" then
	 txt=txt
	end
	--------------------------------------------------
		if string.find(underline,"yes") ~= nil 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
		-- draw line beyond text ---------------------
		cairo_set_line_width (cr,line_width)
		cairo_set_line_cap  (cr, line_cap)
		cairo_set_source_rgba (cr,col(line_color,a))
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wd,endy)
		cairo_stroke (cr)
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) --# reset antialiasing so we don't screw up other code
		elseif string.find(underline,"no") ~= nil then
		txt=txt
		end
	--------------------------------------------------------

end--of function out 

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

function font_weight(value)

 	if string.find(value,"normal") ~= nil then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif value=="bold" then
	fw=CAIRO_FONT_WEIGHT_BOLD
	elseif value=="italic" then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif value =="bolditalic" then
    fw=CAIRO_FONT_WEIGHT_BOLD
	elseif string.find(value,"oblique") ~= nil then 
    fw=CAIRO_FONT_WEIGHT_NORMAL
	end
	    
	return fw
end



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

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

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

function m2n(mn)
--[[
function converts the name of the month into numbers
tonumber -> change type of a value (into a number)
]]--
------------------------------------------------------------------------
local m2n_input=nil
local m2n_input=mn.input or 0
local m2n_input=string.lower(m2n_input) -- convert text into lowercase to match the 'table-entries'
local m2n_lang=nil
local m2n_lang=mn.l or "en"
local month_to_num={} -- initalize table (array)
local output=nil
------------------------------------------------------------------------
if m2n_lang=="de" then
 month_to_num={"januar","februar","märz","april","mai","juni","juli","august","september","oktober","november","dezember"}
elseif m2n_lang=="it" then
 month_to_num={"gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"}
elseif m2n_lang=="en" then
 month_to_num={"january","february","march","april","may","june","juli","august","september","octobre","november","december"}
end
------------------------------------------------------------------------
for i,v in ipairs(month_to_num) do
    if tostring(m2n_input)==tostring(v) then
       if tonumber(i)<=9 then
	   output="0"..tonumber(i)
	   elseif tonumber(i)>=10 then
	   output=tonumber(i)
	   end
	end
end--of loop
return output
end--of function


-- #####################################################################
-- ## display external and local images ################################
-- #####################################################################

function image(im) -- display local images
	local x = nil
	local y = nil
	local w = nil	
	local h = nil
	x =im.x or 0
	y =im.y or 0
	w =im.w or default_image_width -- default width is defined within the template
	h =im.h or default_image_height -- default height is defined within the template
	local 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 --# if show == nil then 
	imlib_context_set_image(show)
	local WIDTH = nil
	if tonumber(w) == 0 then 
		WIDTH = imlib_image_get_width() 
	else
		WIDTH = tonumber(w)
	end -- if
	local HEIGHT = nil
	if tonumber(h) == 0 then HEIGHT = imlib_image_get_height() else HEIGHT = tonumber(h) end --# if tonumber(h) == 0 then 
	local scaled = imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), WIDTH, HEIGHT)
	imlib_free_image_and_decache()
	imlib_context_set_image(scaled)
	imlib_render_image_on_drawable(x, y)
	imlib_free_image_and_decache()
	show = nil
	WIDTH = nil
	HEIGHT = nil
	x = nil
	y = nil
	w = nil
	h = nil
	file = nil
	scaled = nil
end --# function

function extern(wb) -- display external images (i.a. webcams)

	local img_nw=nil
	local img_x=nil
	local img_y=nil
	local s=nil
	local j=nil
	local img_w=nil
	local img_h=nil
	local imgwidth=nil
	local imgheight=nil
	local imgt=nil
	local imgw=nil
	local imgh=nil
	--------------------------------------------------------------------
	img_x=wb.posx or 0 -- horizontal postion
	img_y=wb.posy or 0 -- vertical position
	img_w=wb.imgw -- image width
	img_h=wb.imgh -- image height
	j=wb.j or "l" -- justification
	scaled=wb.scaled or "no" -- scale image or use default value
	scale_size=wb.scale_size or 200 -- set scaled width or use default value
	
	img_nw=wb.imghdd or "external_img.jpg" -- set name of the image
	s=wb.imgurl -- url of the external image (webcam etc.)
	img_file='/home/'..username.."/"..img_nw -- define storage location
	img_intervall=wb.imgiv or 60 -- set intervall
	
	-- grab external image from url and save it to hdd
	local updates = tonumber(conky_parse('${updates}'))
	if (math.mod(updates, img_intervall) == 0) then
		os.execute("wget  -q -O "..img_file..' "'..s..'"')
	end
	-- print error message when no image is defined
	if img_file==nil then print("set image file") end
	--------------------------------------------------------------------
	if scaled=="yes" then
		local show = imlib_load_image(img_file)
		if show == nil then return 	end
		imlib_context_set_image(show) -- display defined image if image file exists
		imgwidth= imlib_image_get_width() -- get image width
		imgheight=imlib_image_get_height() -- get image height
		imgw=scale_size
		imgh=(imgw*imgheight)/imgwidth
		imlib_free_image_and_decache() -- remove from cache
	else
		imgw=img_w
		imgh=img_h
	end
	-- set alignment ---------------------------------------------------
	if j=="l" then -- justify left
	 img_x=img_x
	elseif j=="r" then -- justify right
	 img_x=img_x-imgw
	end
	--------------------------------------------------------------------
	image({x=img_x,y=img_y,w=imgw,h=imgh,file=img_file}) -- load image, function image() must exist
end--of function


-- #####################################################################
-- ## functions to modify conky-output #################################
-- #####################################################################

function os_capture(cmd, raw) -- parse shell in lua
	local f = assert(io.popen(cmd, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	if raw then return s end
	s = string.gsub(s, '^%s+', '')
	s = string.gsub(s, '%s+$', '')
	s = string.gsub(s, '[\n\r]+', ' ')
	return s
end

function command(value,device,del,se)

if value=="cpu" then
	cmd=[[cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //'| uniq]]
	ms=os_capture(cmd, raw) -- excecute function (see above)
elseif value=="today" then
	cmd=[[vnstat -i ]]..device..[[ | grep "today" | awk '{print $2 $3}']]
	todayVnstat=os_capture(cmd, raw)
	ms=conky_parse("${if_up "..device.."}"..parse(todayVnstat,del,se).."${else}n/a${endif}")
elseif value=="week" then
	cmd=[[vnstat -i ]]..device..[[ -w | grep "current week" | awk '{print $3 $4}']]
	weekVnstat=os_capture(cmd, raw)
	ms=conky_parse("${if_up "..device.."}"..parse(weekVnstat,del,se).."${else}n/a${endif}")
elseif value=="month" then
	cmd=[[vnstat -i ]]..device..[[ -m | mawk '$0 ~ "'`date +"%b.+%y"`'" {print $3, $4}']]
	monthVnstat = os_capture(cmd, raw)
	ms=conky_parse("${if_up "..device.."}"..parse(monthVnstat,del,se).."${else}n/a${endif}")
end

return ms
end		


function parseValue(value,value1,value2,del,ending) -- remove ending and add custom ending
	jn=value:gsub(value1,"") 
	if ending=="no" then mv=chgFormat(jn,ending) else mv=chgFormat(jn,ending)..' '..value2 end
return mv
end

		
function nounit(var,ending,value)
		if var=="no" then ms=value else ms=value.." "..ending end
		return ms
end


function chgDel(value,del)

local ausgang=nil
local ersteZahl=nil
local rest=nil
local outputNumber=nil

ausgang=string.gsub(value, "(%d*\.*%d+).*", "%1") -- remove ending
ausgang=tonumber(ausgang)

if not ausgang then ausgang=0; end

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

return outputNumber

end -- of function



function chgFormat(number,ending)
--#####################
--replace deimal point with ,
point=string.find(number,"%p")
if point~=nil then
n1=string.sub(number,1,point-1)
n2=string.sub(number,point,string.len(number))
n2=string.gsub(n2,"^.",",")
	if string.len(n2)==2 then
	n2=n2..""
	elseif string.len(n2)>3 then
	n2=string.sub(n2,1,3)	
	end
else
n1=number
n2=",0"
end
--put in divisions
n1len=string.len(n1)
divs=math.floor((n1len-1)/3)
if n1len>3 then
	for i=1,divs do
	n=n1len-(i*3)
	bit1=string.sub(n1,1,n)
	bit2=string.sub(n1,n+1)
	n1=bit1.."."..bit2
	end
end
output=n1..n2

return output
end


function add_decimal(input,sign)  -- add decimal place, i.e. 5,0
--if string.find(input,"%a")==nil then -- look for string
        if string.find(input,"%p")==nil then         -- only add decimal place when value is a number
        input=input..sign..'0'
        end
--end
return input
end

function parse(value,delimiter,ending)
	local ms=nil
	value = value:gsub(" ","") --# remove spaces to account for inconsistencies in the inclusion of spaces in the output of different conky objects.
	if value==nil then value=0 end
	
	---- short_units no ------------------------------------------------
	if ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=parseValue(value,"B",'byte',delimiter,ending)
	elseif string.find(value, 'KiB') ~= nil then
		ms=parseValue(value,"KiB",'kb',delimiter,ending)
	elseif string.find(value, 'MiB') ~= nil then
		ms=parseValue(value,"MiB",'mb',delimiter,ending)
	elseif string.find(value, 'GiB') ~= nil then
		ms=parseValue(value,"GiB",'gb',delimiter,ending)
	elseif string.find(value, "TiB") ~= nil then
		ms=parseValue(value,"TiB",'tb',delimiter,ending)
	---- short_units yes -----------------------------------------------
	elseif ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=parseValue(value,"B",'byte',delimiter,ending)
	elseif string.find(value, "K") ~= nil then
		ms=parseValue(value,"K",'kb',delimiter,ending)
	elseif string.find(value, "M") ~= nil then
		ms=parseValue(value,"M",'mb',delimiter,ending)
	elseif string.find(value, "G") ~= nil then
		ms=parseValue(value,"G",'gb',delimiter,ending)
	elseif string.find(value, "T") ~= nil then
		ms=parseValue(value,"T",'tb',delimiter,ending)
	else
		ms=value:gsub(" ","") -- remove space
	end

	return ms
end -- of function


function system(cd)
-- you can call the function like this (example)
-- system({variable="totaldown",device="wlan0",del=',',se="no"})
-- conky_parse -> parse external variable from conky

local conky_order=nil
local variable=nil
local device=nil
local del=nil
local cs = nil
local ms = nil
local tf = nil
local txt=nil
local se=nil -- show extension
------------------------------------------------------------------------
variable=cd.variable
device=cd.device or ''
del=cd.del or '.' -- delimiter
tf=cd.tf or '24' -- time format
se=cd.se or "yes" -- show ending

rawdata=conky_parse("${"..variable..' '..device.."}")
adv=parse(rawdata,del,se)

	if string.find(variable,"cpu") ~= nil then
		ms=nounit(se,"%",rawdata)
	elseif string.find(variable,"uptime") ~= nil or string.find(variable,"user_number") ~= nil then
		ms=rawdata
	elseif ((string.find(variable, "perc") ~= nil) or (string.find(variable, "percent") ~= nil)) then
		ms=nounit(se,"%",rawdata)
	--------------------------------------------------------------------
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") == nil)) then
		jn=chgDel(adv,del)
		ms=nounit(se,"mhz",jn)
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") ~= nil)) then
		jn=chgDel(adv,del)
		ms=nounit(se,"ghz",add_decimal(jn,del))
	elseif string.find(variable,"loadavg") ~= nil then
		ms=rawdata
	--------------------------------------------------------------------
	elseif string.find(variable,"wireless_bitrate") ~= nil then
		txt=rawdata:gsub("Mb/s","")
		txt=txt:gsub(" ","") -- remove spaces
		ms=conky_parse("${if_up "..device.."}"..nounit(se,"mb/s",chgFormat(tonumber(txt),del)).."${else}n/a${endif}")
	elseif string.find(variable,"wireless_essid") ~= nil or string.find(variable,"wireless_mode") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..rawdata.."${else}n/a${endif}")
	elseif string.find(variable,"wireless_link_qual") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..nounit(se,"%",adv).."${else}n/a${endif}")
	elseif string.find(variable,"upspeedf") ~= nil or string.find(variable,"downspeedf") ~= nil then
		jn=chgDel(adv,del) -- chg format
		ms=conky_parse("${if_up "..device.."}"..nounit(se,"kb/s",jn).."${else}n/a${endif}")
	elseif string.find(variable,"battery") ~= nil then
		ms=rawdata
	--------------------------------------------------------------------
	elseif string.find(variable,"prozessor") ~= nil or string.find(variable,"processor") ~= nil then
		ms=command("cpu",device,del,se)
	elseif string.find(variable,"download") ~= nil and string.find(variable,"today") ~= nil then
		ms=command("today",device,del,se)
	elseif string.find(variable,"download") ~= nil and string.find(variable,"week") ~= nil then
		ms=command("week",device,del,se)
	elseif string.find(variable,"download") ~= nil and string.find(variable,"month") ~= nil then
		ms=command("month",device,del,se)
	--------------------------------------------------------------------
	elseif string.find(variable,"up") == nil and string.find(variable,"time") ~= nil then
		if tf == "24" then ms=nounit(se,"uhr",adv) elseif tf == "12" then ms=convert12(rawdata,tf) end 
	else
	--------------------------------------------------------------------
		if string.find(device,"wlan") ~= nil or string.find(device,"eth") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..adv.."${else}n/a${endif}")
		elseif string.find(device,"media") ~= nil then
		--ms=conky_parse("${if_mounted "..device.."}"..add_decimal(adv,del).."${else}n/a${endif}")
		ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}n/a${endif}")
		else ms=adv  end 
	--------------------------------------------------------------------
	end

	return ms
end -- of function


function convert12(value,format) 
--[[ 
convert 24h-format into 12h-format, for example 16:00 -> 4:00 pm
string.sub - returns part of a string, i.e. string.sub(value,1,2)
]]--
local stunden=nil
local minuten=nil
local zeit=nil
local sekunden=nil

local stunden=string.sub(value,1,2) -- hours
local stunden=tonumber(stunden) -- convert hours into numbers
local minuten=string.sub(value,4,5) -- minutes
local sekunden=string.sub(value,7,8) -- seconds

-- still calculate if string doesn't exists
if not sekunden then sekunden=''; end

if stunden > 12 and stunden < 24 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' pm'
	elseif sekunden == '' then
	zeit=(stunden-12)..':'..minuten..' pm'
	end
elseif stunden < 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' am'
	elseif sekunden == '' then
	zeit=stunden..':'..minuten..' am'
	end
elseif stunden == 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' pm'
	elseif sekunden == '' then
	zeit=stunden..':'..minuten..' pm'
	end
elseif stunden == 24 or stunden == 0 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' am'
	elseif sekunden == '' then
	zeit=(stunden-12)..':'..minuten..' am'
	end
end

return zeit

end


function dropZero(wert) -- drop leading charcacter

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

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

return ausgabe

end -- of function

--[[

function whatever()
val=tonumber(conky_parse("whatever"))
tcol=get_color({val,{20,0x00ffff},{40,0x00ff00},{60,0xffff00},{80,0xff7f00},{100,0xff0000}})
draw_bar({val=val, all the other settings},tcol)
end

]]--

function get_color(ctab)
--by mrpeachy 04/2013
local ncol=#ctab
local val=ctab[1]
--local val=ctab.val
local lownum=(ctab[2])[1]
local lowcol=col((ctab[2])[2])
local highnum=col((ctab[ncol])[1])
local highcol=col((ctab[ncol])[2])

if val<=lownum then 
color=lowcol
elseif val>=highnum then
color=highcol
else
	for i=2,ncol do
	entry1=ctab[i]
	entry2=ctab[i+1] or ctab[i]
	lower=entry1[1]
	upper=entry2[1]
		if val>=lower and val<=upper then
		nentry=i
		end
	end
ctop=color((ctab[nentry+1] or nentry)[2])
ntop=(ctab[nentry+1] or nentry)[1]
clow=color((ctab[nentry])[2])
nlow=(ctab[nentry])[1]
i1=ntop-nlow
i2=val-nlow
c1=clow[1]+((ctop[1]-clow[1])*i2/i1)
c2=clow[2]+((ctop[2]-clow[2])*i2/i1)
c3=clow[3]+((ctop[3]-clow[3])*i2/i1)
c4=clow[4]+((ctop[4]-clow[4])*i2/i1)
color={c1,c2,c3,c4}
end
ctab=nil
return color

end--function

function draw_bar(db,farbe) -- improved bars by mrpeachy (2010)

local var=nil
local dev=nil
local width=nil
local height=nil
local across=nil
local down=nil
local bgc=nil
local bga=nil
--local inc=nil
--local ina=nil
local lc=nil
local la=nil
local lw=nil
local rotate=nil
local justify=nil
------------------------------------------------------------------------
var=db.var or ""
dev=db.dev or ""
width=db.w
height=db.h
across=db.x
down=db.y
bgc=db.bgc -- background color
bga=db.bga or 1

lc=db.lc -- line color
la=db.la or 1
lw=db.lw
rotate=db.r or 0
justify=db.j or "l"

--indicator calculation
if not dev then dev=''; end

conum=conky_parse("${"..var..' '..dev.."}")
conum=tonumber(conum)

local inum=(((width-lw)/100)*(conum or 0))

if justify=="r" then
across=across-width
elseif justify=="l" then
across=across
end

--background bar
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, col(bgc, bga));
cairo_rectangle (cr, 0, 0, (width-lw), (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
--indicator bar
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
--cairo_set_source_rgba (cr, col(inc,ina));
cairo_set_source_rgba (cr, farbe[1],farbe[2],farbe[3],farbe[4]);
cairo_rectangle (cr, 0, 0, inum, (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
--boundary line
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_line_width (cr, lw);
cairo_set_source_rgba (cr, col(lc,la));
cairo_rectangle (cr, -lw/2, -lw/2, width, height)
cairo_stroke (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
end


-- #####################################################################
-- ## end of functions to modify conky-output ##########################
-- #####################################################################




-- #####################################################################
-- ## gimmicks #########################################################
-- #####################################################################

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


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

function get_color(ctab)
--by mrpeachy 04/2013
local function color(col)
return {((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, 1}
end
local ncol=#ctab
local val=ctab[1]
local lownum=(ctab[2])[1]
local lowcol=color((ctab[2])[2])
local highnum=(ctab[ncol])[1]
local highcol=color((ctab[ncol])[2])
if val<=lownum then 
color=lowcol
elseif val>=highnum then
color=highcol
else
	for i=2,ncol do
	entry1=ctab[i]
	entry2=ctab[i+1] or ctab[i]
	lower=entry1[1]
	upper=entry2[1]
		if val>=lower and val<=upper then
		nentry=i
		end
	end
ctop=color((ctab[nentry+1] or nentry)[2])
ntop=(ctab[nentry+1] or nentry)[1]
clow=color((ctab[nentry])[2])
nlow=(ctab[nentry])[1]
i1=ntop-nlow
i2=val-nlow
c1=clow[1]+((ctop[1]-clow[1])*i2/i1)
c2=clow[2]+((ctop[2]-clow[2])*i2/i1)
c3=clow[3]+((ctop[3]-clow[3])*i2/i1)
c4=clow[4]+((ctop[4]-clow[4])*i2/i1)
color={c1,c2,c3,c4}
end
ctab=nil
return color
end--function
--#############################################################################################################################################################
function thermometer(therm)
--by mrpeachy 04/2013
local mx=therm.x or 0
local my=therm.y or 0
local tcol=therm.tcol
local temp=therm.val or 0
local label=therm.label or nil
local scale=therm.scale or 1
local units=therm.units or "F"
local font=therm.f or "Mono"
local fsize=therm.fs or "10"
local lines=therm.lines or 1
local numbers=therm.numbers or 1
therm=nil
--by mrpeachy 2011
if units=="F" then height=150 elseif units=="C" then height=160 end
local mx=mx*(1/scale)
local my=my*(1/scale)
cairo_scale (cr,scale,scale)
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,1) -- aussenlinie

--graphics outer
--bottom circle
r_outer=25
local lang_outer=335
local rang_outer=0+(360-lang_outer)
local h_outer=height-4--maybe make this a percentage?###########
cairo_arc (cr,mx,my,r_outer,(math.pi/180)*(rang_outer-90),(math.pi/180)*(lang_outer-90))
--coordinates,left line
local arc=(math.pi/180)*lang_outer
local lxo=0+r_outer*(math.sin(arc))
local lyo=0-r_outer*(math.cos(arc))
cairo_line_to (cr,mx+lxo,my+lyo-h_outer)
--coordinates,left line
local arc=(math.pi/180)*rang_outer
local rxo=0+r_outer*(math.sin(arc))
local ryo=0-r_outer*(math.cos(arc))
--top circle
cairo_arc (cr,mx+lxo+((rxo-lxo)/2),my+lyo-h_outer,(rxo-lxo)/2,(math.pi/180)*(270-90),(math.pi/180)*(90-90))
--right line
cairo_line_to (cr,mx+lxo+((rxo-lxo)),my+lyo)
cairo_stroke (cr)
----------------------------------------------
--graphics inner
--####################################################
if units=="F" then
cairo_set_source_rgba (cr,tcol[1],tcol[2],tcol[3],tcol[4])
--bottom circle
r_inner=r_outer-6
local lang_inner=lang_outer+9
local rang_inner=0+(360-lang_inner)
local h_inner=temp+30
cairo_arc (cr,mx,my,r_inner,(math.pi/180)*(rang_inner-90),(math.pi/180)*(lang_inner-90))
--coordinates,left line
local arc=(math.pi/180)*lang_inner
lxi=0+r_inner*(math.sin(arc))
local lyi=0-r_inner*(math.cos(arc))
cairo_line_to (cr,mx+lxi,my+lyi-h_inner)
--coordinates,left line
local arc=(math.pi/180)*rang_inner
rxi=0+r_inner*(math.sin(arc))
local ryi=0-r_inner*(math.cos(arc))
--top circle
cairo_arc (cr,mx+lxi+((rxi-lxi)/2),my+lyi-h_inner,(rxi-lxi)/2,(math.pi/180)*(270-90),(math.pi/180)*(90-90))
--right line
cairo_line_to (cr,mx+lxi+((rxi-lxi)),my+lyi)
cairo_fill (cr)
----------------------------
if lines==1 then
--scale lines
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,0,0.5)
local grad=10
local lnn=15
local lnx=mx+lxo
local lnw=(rxo-lxo)
	for i=1,lnn do
	lny=my-r_inner-(10+((i-1)*grad))-((rxi-lxi)/2)
		if i==lnn then
		lnx=lnx+2
		lnw=lnw-4
		end
	cairo_move_to (cr,lnx,lny)
	cairo_rel_line_to (cr,lnw,0)
	cairo_stroke (cr)
	end
end--if lines
if numbers==1 then
--numbers
cairo_set_source_rgba (cr,1,1,1,1)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
local grad=20
local lnn=8
local lnx=mx+lxo+(rxo-lxo)+4
num={-20,"0°"..units,20,40,60,80,100,120}
for i=1,lnn do
lny=my-r_inner-(10+((i-1)*grad))-((rxi-lxi)/2)+(fsize/3)
cairo_move_to (cr,lnx,lny)
cairo_show_text (cr,num[i])
cairo_stroke (cr)
end
end--if label
end--if units=F
--#################################################
if units=="C" then
cairo_set_source_rgba (cr,tcol[1],tcol[2],tcol[3],tcol[4])
--cairo_set_source_rgba (cr,0,1,1,1)
--bottom circle
r_inner=r_outer-6
local lang_inner=lang_outer+9
local rang_inner=0+(360-lang_inner)
local h_inner=(temp*2)+60
cairo_arc (cr,mx,my,r_inner,(math.pi/180)*(rang_inner-90),(math.pi/180)*(lang_inner-90))
--coordinates,left line
local arc=(math.pi/180)*lang_inner
lxi=0+r_inner*(math.sin(arc))
local lyi=0-r_inner*(math.cos(arc))
cairo_line_to (cr,mx+lxi,my+lyi-h_inner)
--coordinates,left line
local arc=(math.pi/180)*rang_inner
rxi=0+r_inner*(math.sin(arc))
local ryi=0-r_inner*(math.cos(arc))
--top circle
cairo_arc (cr,mx+lxi+((rxi-lxi)/2),my+lyi-h_inner,(rxi-lxi)/2,(math.pi/180)*(270-90),(math.pi/180)*(90-90))
--right line
cairo_line_to (cr,mx+lxi+((rxi-lxi)),my+lyi)
cairo_fill (cr)
----------------------------
if lines==1 then
--scale lines
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,0.5)
local grad=10
local lnn=17
local lnx=mx+lxo
local lnw=(rxo-lxo)
	for i=1,lnn do
	lny=my-r_inner-(((i-1)*grad))-((rxi-lxi)/2)
		if i==lnn then
		lnx=lnx+2
		lnw=lnw-4
		end
	cairo_move_to (cr,lnx,lny)
	cairo_rel_line_to (cr,lnw,0)
	cairo_stroke (cr)
	end
end--if lines
if numbers==1 then
--numbers
cairo_set_source_rgba (cr,1,1,1,1)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
local grad=20
local lnn=9
local lnx=mx+lxo+(rxo-lxo)+4
num={-30,-20,-10,"0°"..units,10,20,30,40,50}
for i=1,lnn do
lny=my-r_inner-(((i-1)*grad))-((rxi-lxi)/2)+(fsize/3)
cairo_move_to (cr,lnx,lny)
cairo_show_text (cr,num[i])
cairo_stroke (cr)
end
end--if label=none
end--if units=C
--#################################################
--label
if label~=nil then
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
local lbx=mx+lxo-5
local lby=my-r_inner-10-((rxi-lxi)/2)
cairo_move_to (cr,lbx,lby)
cairo_rotate (cr,(math.pi/180)*(-90))
--cairo_show_text (cr,label)
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(90))
--temperature readout
cairo_set_source_rgba (cr,0,0,0,1)
local text=temp.."°"..units
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,mx-(width/2),my+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end--if label
------------------------------------
cairo_scale (cr,1/scale,1/scale)
end--thermometer function


--END OF SCRIPT

this is a screenshot of my 'test-template': http://i.imgbox.com/acpThgel.png

the script converts the conky-output of the time into 12h-format.

system({variable="time %k:%M",tf="12"})

the default-format is 24h-format. if u wanna use this format u do not have to define it:

tf="24"

here u can find my test-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="mono" --font must be in quotes
default_font_size=10
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=25
local posy=170
local hell=dnc(0xd1cf3d,0xb3a7a7)
local dunkel=dnc(0xa3a23f,0xb3a7a7)

-- aktuelle Temperatur
out({x=50,y=30,c=dnc(0xffff00,0xb3a7a7),f='Anonymous Pro:bold',fs=20,face="bold",blurred="no",txt=now["temp"].." °C"})

out({x=400,y=20,c=hell,f='Anonymous Pro:bold',fs=20,face="bold",border="yes",underline="yes",txt=now["conditions_short"],hj='r'})

-- weather icon
--image({x=650,y=0,h=65,w=65,file=now["weather_icon"]})

-- moon icon
--image({x=650,y=100,w=40,h=40,file=moon_icon[1]})



out({f="Moon Phases",fs=40,x=930,y=50,c=hell,shaded="yes",txt=moon_font[1],hj='r'})
out({f="ConkyWeather",fs=32,x=500,y=30,w=50,h=50,shaded="yes",txt=now["weather_font"]})




local fs_folder_home=system({variable="fs_free",device="/home/alexander",del=','})
local fs_folder_used=system({variable="fs_used",device="/home/alexander",del=',',se="yes"})

out({x=0,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='fs_free (home):',hj='l'})
out({x=150,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=fs_folder_home,hj='r'})



out({x=0,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='fs_free (home):',hj='l'})
out({x=150,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_free /home/alexander}'),hj='r'})



out({x=200,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used (home):',hj='l'})
out({x=350,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=fs_folder_used,hj='r'})

out({x=200,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used (home):',hj='l'})
out({x=350,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used /home/alexander}'),hj='r'})

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

out({x=400,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used (usb-stick):',hj='l'})
out({x=400,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used (usb-stick):',hj='l'})

out({x=600,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_used",device="/media/DD23-11E9",del=','}),hj='r'})
out({x=600,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used /media/DD23-11E9}'),hj='r'})

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

out({x=400,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used (usb-hdd):',hj='l'})
out({x=600,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_used",device="/media/Elements",del=','}),hj='r'})

out({x=400,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used (usb-hdd):',hj='l'})
out({x=600,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used /media/Elements}'),hj='r'})


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

local geschw_1=conky_parse('${downspeed wlan0}')
local geschw_2=conky_parse('${downspeedf wlan0}')

local geschw_3=conky_parse('${upspeed wlan0}')
local geschw_4=conky_parse('${upspeedf wlan0}')

local total_1=conky_parse('${totalup wlan0}')
local total_2=conky_parse('${totaldown wlan0}')

out({x=0,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='downspeed:',hj='l'})
out({x=150,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="downspeed",device="wlan0",del=',',se="yes"}),hj='r'})

out({x=0,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='downspeed:',hj='l'})
out({x=150,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=geschw_1,hj='r'})

out({x=0,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='downspeedf:',hj='l'})
out({x=150,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="downspeedf",device="wlan0",del=',',se="yes"}),hj='r'})

out({x=0,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='downspeedf:',hj='l'})
out({x=150,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=geschw_2,hj='r'})

-----

out({x=200,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='upspeed:',hj='l'})
out({x=350,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="upspeed",device="wlan0",del=','}),hj='r'})

out({x=200,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='upspeed:',hj='l'})
out({x=350,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=geschw_3,hj='r'})


out({x=200,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='upspeedf:',hj='l'})
out({x=350,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="upspeedf",device="wlan0",del=',',se="yes"}),hj='r'})

out({x=200,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='upspeedf:',hj='l'})
out({x=350,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=geschw_4,hj='r'})


out({x=0,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='totalup:',hj='l'})
out({x=150,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="totalup",device="wlan0",del=','}),hj='r'})

out({x=0,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='totalup:',hj='l'})
out({x=150,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=total_1,hj='r'})

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

out({x=200,y=270,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='essid:',hj='l'})
out({x=200,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='essid:',hj='l'})

out({x=350,y=270,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_essid",device="wlan0"}),hj='r'})
out({x=350,y=285,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_essid wlan0}'),hj='r'})

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

out({x=200,y=320,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='link_qual:',hj='l'})
out({x=200,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='wireless_link_qual:',hj='l'})

out({x=350,y=320,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_link_qual",device="wlan0"}),hj='r'})
out({x=350,y=335,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_link_qual wlan0}'),hj='r'})


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

out({x=0,y=320,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='conky-version:',hj='l'})
out({x=0,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='conky-version:',hj='l'})

out({x=150,y=320,c=0xffff00,f="mono",fs=10,face="italic",size="big_c",shaded="yes",txt=system({variable="conky_version"}),hj='r'})
out({x=150,y=335,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${conky_version}'),hj='r'})


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

out({x=200,y=370,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='wireless mode:',hj='l'})
out({x=200,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='wireless mode:',hj='l'})

out({x=350,y=370,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_mode",device="wlan0"}),hj='r'})
out({x=350,y=385,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_mode wlan0}'),hj='r'})

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

out({x=200,y=420,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='lokale ip:',hj='l'})
out({x=200,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='lokale ip:',hj='l'})

out({x=350,y=420,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="addr",device="wlan0"}),hj='r'})
out({x=350,y=435,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${addr wlan0}'),hj='r'})

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

out({x=200,y=470,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='globale ip:',hj='l'})
out({x=200,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='globale ip:',hj='l'})

out({x=350,y=470,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=conky_parse('${execi 7200 wget http://v4.ipv6-test.com/api/myip.php -q -O -}'),hj='r'})
out({x=350,y=485,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${execi 7200 wget http://v4.ipv6-test.com/api/myip.php -q -O -}'),hj='r'})

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



out({x=200,y=520,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='bitrate:',hj='l'})
out({x=200,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='bitrate:',hj='l'})

out({x=350,y=520,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_bitrate",device="wlan0",del=","}),hj='r'})
out({x=350,y=535,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_bitrate wlan0}'),hj='r'})

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







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

out({x=0,y=370,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='memory (mem):',hj='l'})
out({x=0,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='arbeitsspeicher:',hj='l'})

out({x=150,y=370,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="mem",del=","}),hj='r'})
out({x=150,y=385,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${mem}'),hj='r'})

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

out({x=0,y=420,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='memeasyfree:',hj='l'})
out({x=0,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='arbeitsspeicher:',hj='l'})

out({x=150,y=420,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="memeasyfree",del=","}),hj='r'})
out({x=150,y=435,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${memeasyfree}'),hj='r'})

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

out({x=0,y=470,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='memfree:',hj='l'})
out({x=0,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='arbeitsspeicher:',hj='l'})

out({x=150,y=470,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="memfree",del=","}),hj='r'})
out({x=150,y=485,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${memfree}'),hj='r'})

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

out({x=0,y=520,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='memmax:',hj='l'})
out({x=0,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='arbeitsspeicher:',hj='l'})

out({x=150,y=520,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="memmax",del=",",se="yes"}),hj='r'})
out({x=150,y=535,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${memmax}'),hj='r'})

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


--${execi 7200 ~/.conky/publicip.sh}

--conky_draw_graph()
-----------------

out({x=0,y=270,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='machine:',hj='l'})
out({x=0,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='machine:',hj='l'})

out({x=150,y=270,c=0xffff00,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="machine"}),hj='r'})
out({x=150,y=285,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${machine}'),hj='r'})

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

--out({x=200,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='totaldown:',hj='l'})
--out({x=350,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="totaldown",device="wlan0",del=','}),hj='r'})

--out({x=200,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='totaldown:',hj='l'})
--out({x=350,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=total_2,hj='r'})




out({x=200,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='totaldown:',hj='l'})
out({x=350,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="totaldown",device="wlan0",del=',',se="yes"}),hj='r'})

out({x=200,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='totaldown:',hj='l'})
out({x=350,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=total_2,hj='r'})

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


out({x=400,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='zeit (deutsch):',hj='l'})
out({x=600,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="time %k:%M"}),hj='r'})

out({x=400,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable time:',hj='l'})
out({x=600,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${time %k:%M:%S}'),hj='r'})

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

out({x=400,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='zeit (englisch):',hj='l'})
out({x=600,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="time %k:%M",tf="12"}),hj='r'})

out({x=400,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable time:',hj='l'})
out({x=600,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${time %k:%M:%S}'),hj='r'})



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

out({x=400,y=270,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='variable uptime:',hj='l'})
out({x=600,y=270,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="uptime"}),hj='r'})

out({x=400,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable uptime:',hj='l'})
out({x=600,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${uptime}'),hj='r'})
-------------------

out({x=400,y=320,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt="batterie:",hj='l'})
out({x=600,y=320,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="battery",device="BAT1"}),hj='r'})

out({x=400,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable:',hj='l'})
out({x=600,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${battery BAT1}'),hj='r'})

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

out({x=400,y=370,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='batterie %:',hj='l'})
out({x=600,y=370,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="battery_percent",device="BAT1",se="yes"}),hj='r'})

out({x=400,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable:',hj='l'})
out({x=600,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${battery_percent BAT1}'),hj='r'})

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

out({x=400,y=420,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='batterie short:',hj='l'})
out({x=600,y=420,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="battery_short",device="BAT1"}),hj='r'})

out({x=400,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable:',hj='l'})
out({x=600,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${loadavg cpu0}'),hj='r'})

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

out({x=400,y=470,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='batterie time:',hj='l'})
out({x=600,y=470,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="battery_time",device="BAT1"}),hj='r'})

out({x=400,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable:',hj='l'})
out({x=600,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${battery_time BAT1}'),hj='r'})


-------------------
out({x=400,y=520,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='nodename:',hj='l'})
out({x=600,y=520,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="nodename"}),hj='r'})

out({x=400,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable:',hj='l'})
out({x=600,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${nodename}'),hj='r'})

-------------------
out({x=650,y=320,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='ram prozent:',hj='l'})
out({x=650,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='ram prozent:',hj='l'})

out({x=850,y=320,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="memperc",del=","}),hj='r'})
out({x=850,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${memperc}'),hj='r'})

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

out({x=650,y=270,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='swap benutzt:',hj='l'})
out({x=650,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='variable:',hj='l'})

out({x=850,y=270,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swap",del=","}),hj='r'})
out({x=850,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swap}'),hj='r'})

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

out({x=650,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='swap:',hj='l'})
out({x=650,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='swapfree:',hj='l'})

out({x=850,y=220,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swapfree",del=","}),hj='r'})
out({x=850,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swapfree}'),hj='r'})

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

out({x=650,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='swap gesamt:',hj='l'})
out({x=650,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='swapmax:',hj='l'})

out({x=850,y=170,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swapmax",del=",",se="yes"}),hj='r'})
out({x=850,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swapmax}'),hj='r'})

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

out({x=650,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='swap prozent:',hj='l'})
out({x=650,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='swapperc:',hj='l'})

out({x=850,y=120,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swapperc",se="yes"}),hj='r'})
out({x=850,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swapperc}'),hj='r'})


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

out({x=650,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='user_number:',hj='l'})
out({x=650,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='user_number:',hj='l'})

out({x=850,y=65,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="user_number"}),hj='r'})
out({x=850,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${user_number}'),hj='r'})

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

out({x=650,y=370,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='cpu prozent:',hj='l'})
out({x=850,y=370,c=0xffff00,f="mono",fs=10,face="italic",size="big_c",shaded="yes",txt=system({variable="cpu",device="cpu0",se="yes"}),hj='r'})


out({x=650,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='cpu prozent:',hj='l'})
out({x=850,y=385,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${cpu}'),hj='r'})


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



out({x=650,y=420,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='cpu frequenz (freq):',hj='l'})
out({x=650,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='cpu frequenz (freq):',hj='l'})

out({x=850,y=420,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="freq",device="cpu0",del=",",se="yes"}),hj='r'})
out({x=850,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${freq}'),hj='r'})

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

out({x=650,y=470,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='cpu frequenz (freq_g):',hj='l'})
out({x=850,y=470,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="freq_g",del=",",se="yes"}),hj='r'})

out({x=650,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='cpu frequenz (freq_g):',hj='l'})
out({x=850,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${freq_g}'),hj='r'})

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

out({x=650,y=520,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt='prozesse:',hj='l'})
out({x=850,y=520,c=0xffff00,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="processes"}).." ("..system({variable="running_processes"})..")",hj='r'})

out({x=650,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='running_processes:',hj='l'})
out({x=850,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${running_processes}'),hj='r'})








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

Last edited by lionhead (2013-05-07 10:03:18)

Offline

#883 2013-04-07 10:19:24

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

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

here u can see all possible features that are possible (until i add more *g*):  http://ompldr.org/vaTR5Zw
just conky-output: http://ompldr.org/vaTBubA

everything you can see is built within lua!

Last edited by lionhead (2013-04-18 14:11:26)

Offline

#884 2013-04-10 15:22:23

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

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

i worked a bit on my custom v9000. u will find the newest code in an earlier posting (see above).

this shows displays some conky-variables: http://ompldr.org/vaTF1OQ
this is the offline-status (when u do not have an internet connection):  http://ompldr.org/vaTJ4Nw

the next 'point' on my todo-list is to integrate the ability to use 'conky-graphs'. if u want to help me then feel free to post the code wink

Last edited by lionhead (2013-04-24 16:13:12)

Offline

#885 2013-04-25 14:29:47

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

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

try this if u want to display and format the 'conky-output':

system({variable="totaldown",device="wlan0",del=',',se="no"})

you can disable the ability the ending, for example:

se="no"

the standard-setting is 'yes'. you do not have to note this but it also works if u note it.

this is the function. it is part of my improved v9000. you will find the whole code in the posting above.

-- ###############################################################
-- ## parse conky-variables ###########################################
-- ###############################################################

function chgDel(value,del)

local ausgang=nil
local ersteZahl=nil
local rest=nil
local outputNumber=nil

ausgang=string.gsub(value, "(%d*\.*%d+).*", "%1") -- remove ending
ausgang=tonumber(ausgang)

if not ausgang then ausgang=0; end

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

return outputNumber

end -- of function


function parse(value,delimiter,ending)
	local ms=nil
	value = value:gsub(" ","") --# remove spaces to account for inconsistencies in the inclusion of spaces in the output of different conky objects.
	local txt=nil
	local jn=nil
	
	if value==nil then value=0 end
	
	---- short_units no ------------------------------------------------
	if ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		jn=value:gsub("B","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." byte" end
	elseif string.find(value, 'KiB') ~= nil then
		jn=value:gsub("KiB","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." kb" end
	elseif string.find(value, 'MiB') ~= nil then
		jn=value:gsub("MiB","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." mb" end
	elseif string.find(value, 'GiB') ~= nil then
		jn=value:gsub("GiB","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." gb" end
	elseif string.find(value, "TiB") ~= nil then
		jn=value:gsub("TiB","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." tb" end
	---- short_units yes -----------------------------------------------
	elseif ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		jn=value:gsub("B","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." byte" end
	elseif string.find(value, "K") ~= nil then
		jn=value:gsub("K","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." kb" end
	elseif string.find(value, "M") ~= nil then
		jn=value:gsub("M","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." mb" end
	elseif string.find(value, "G") ~= nil then
		jn=value:gsub("G","") 
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." gb" end
	elseif string.find(value, "T") ~= nil then
		jn=value:gsub("T","")
		jn=chgDel(jn,delimiter)
		if ending=="no" then ms=add_decimal(jn,delimiter) else ms=add_decimal(jn,delimiter).." tb" end
	else
		ms=value:gsub(" ","")
	end
	--------------------------------------------------------------------
	return ms
end -- of function


function system(cd) ----------------------------------------------------
-- system({variable="totaldown",device="wlan0",del=',',se="no"})
local conky_order=nil
local variable=nil
local device=nil
local del=nil
local cs = nil
local ms = nil
local tf = nil
local se=nil

variable=cd.variable
device=cd.device or ''
del=cd.del or '.' -- delimiter
tf=cd.tf or '24' -- time format
se=cd.se or "yes" -- show ending

conky_order=conky_parse("${"..variable..' '..device.."}")
adv=parse(conky_order,del,se)

	if string.find(variable,"cpu") ~= nil then -------------------------
		ms=conky_order.." %"
	elseif string.find(variable,"uptime") ~= nil or string.find(variable,"user_number") ~= nil then
		ms=conky_order
	elseif ((string.find(variable, "perc") ~= nil) or (string.find(variable, "percent") ~= nil)) then
		ms=conky_order.." %"
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") == nil)) then
		jn=chgDel(adv,del)
		ms=jn.." mhz"
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") ~= nil)) then
		jn=chgDel(adv,del)
		jn=add_decimal(jn,del)
		ms=jn.." ghz"
	--------------------------------------------------------------------
	elseif string.find(variable,"addr") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..conky_order.."${else}offline${endif}")
	elseif string.find(variable,"wireless_bitrate") ~= nil then
		txt=conky_order:gsub("Mb/s","")
		txt=txt:gsub(" ","")
		ms=conky_parse("${if_up "..device.."}"..add_decimal(txt,del).." mb/s".."${else}offline${endif}")
	elseif string.find(variable,"wireless_essid") ~= nil or string.find(variable,"wireless_mode") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..conky_order.."${else}offline${endif}")
	elseif string.find(variable,"wireless_link_qual") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..adv.." %".."${else}offline${endif}")
	elseif string.find(variable,"upspeedf") ~= nil or string.find(variable,"downspeedf") ~= nil then
		jn=chgDel(adv,del) -- chg format
		jn=add_decimal(jn,del)
		ms=conky_parse("${if_up "..device.."}"..jn.." kb/s".."${else}offline${endif}")
	--------------------------------------------------------------------
	elseif string.find(variable,"battery") ~= nil then
		ms=conky_order
	elseif string.find(variable,"prozessor") ~= nil or string.find(variable,"processor") ~= nil then
		ms=conky_parse("${execi 1000 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //'| uniq}")
	elseif string.find(variable,"up") == nil and string.find(variable,"time") ~= nil then
		if tf == "24" then ---------------------------------------------
			if se=="no" then ms=adv else ms=adv.." uhr" end
		elseif tf == "12" then
		ms=convert12(conky_order,tf) end -------------------------------
	else
	--------------------------------------------------------------------
		if string.find(device,"wlan") ~= nil or string.find(device,"eth") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..adv.."${else}offline${endif}")
		elseif string.find(device,"media") ~= nil then
		ms=conky_parse("${if_mounted "..device.."}"..add_decimal(adv,del).."${else}not plugged in${endif}")
		else 
		ms=adv 
		end 
	--------------------------------------------------------------------
	end

	return ms
end -- of function


function convert12(value,format) -- convert 24h-format into 12h-format

local stunden=nil -- hours
local minuten=nil -- minutes
local sekunden=nil -- seconds
local zeit=nil 

local stunden=string.sub(value,1,2)
local stunden=tonumber(stunden)
local minuten=string.sub(value,4,5)
local sekunden=string.sub(value,7,8)

if not sekunden then sekunden=''; end

if stunden > 12 and stunden < 24 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' pm'
	elseif sekunden == '' then
	zeit=(stunden-12)..':'..minuten..' pm'
	end
elseif stunden < 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' am'
	elseif sekunden == '' then
	zeit=stunden..':'..minuten..' am'
	end
elseif stunden == 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' pm'
	elseif sekunden == '' then
	zeit=stunden..':'..minuten..' pm'
	end
elseif stunden == 24 or stunden == 0 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' am'
	elseif sekunden == '' then
	zeit=(stunden-12)..':'..minuten..' am'
	end
end

return zeit

end

function add_decimal(input,sign) -- add decimal place

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

return input
end

-- ############################################################
-- ## end of functions to modify conky-output ##########################
-- ############################################################

if u have a proposal what i should include next then feel free to contact me. and if u find something that should be optimized then drop a line smile

Last edited by lionhead (2013-04-25 17:46:39)

Offline

#886 2013-05-04 09:22:54

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

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

i do not understand why it won't work.

this is the error-message:

Conky: llua_do_call: function conky_weather execution failed: /home/alexander/v9000/allinone-test.lua:255: attempt to index global 'tcol' (a number value)

this is line 255:

cairo_set_source_rgba (cr, tcol[1],tcol[2],tcol[3],tcol[4]);

the whole code:

function col(c,a)
return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
end--local function

function get_color(ctab)
--by mrpeachy 04/2013
local ncol=#ctab
local val=ctab[1]
local lownum=(ctab[2])[1]
local lowcol=col((ctab[2])[2])
local highnum=col((ctab[ncol])[1])
local highcol=col((ctab[ncol])[2])

if val<=lownum then 
color=lowcol
elseif val>=highnum then
color=highcol
else
	for i=2,ncol do
	entry1=ctab[i]
	entry2=ctab[i+1] or ctab[i]
	lower=entry1[1]
	upper=entry2[1]
		if val>=lower and val<=upper then
		nentry=i
		end
	end
ctop=color((ctab[nentry+1] or nentry)[2])
ntop=(ctab[nentry+1] or nentry)[1]
clow=color((ctab[nentry])[2])
nlow=(ctab[nentry])[1]
i1=ntop-nlow
i2=val-nlow
c1=clow[1]+((ctop[1]-clow[1])*i2/i1)
c2=clow[2]+((ctop[2]-clow[2])*i2/i1)
c3=clow[3]+((ctop[3]-clow[3])*i2/i1)
c4=clow[4]+((ctop[4]-clow[4])*i2/i1)
color={c1,c2,c3,c4}
end
ctab=nil
return color
end--function

function draw_bar(db) -- improved bars by mrpeachy (2010)

local var=nil
local dev=nil
local width=nil
local height=nil
local across=nil
local down=nil
local bgc=nil
local bga=nil
local ina=nil
local lc=nil
local la=nil
local lw=nil
local rotate=nil
local justify=nil
local tcol=nil
------------------------------------------------------------------------
var=db.var or 0
dev=db.dev or ""
width=db.w
height=db.h
across=db.x
down=db.y
bgc=db.bgc -- background color
bga=db.bga or 1
lc=db.lc -- line color
la=db.la or 1
lw=db.lw
rotate=db.r or 0
justify=db.j or "l"
tcol=0

--indicator calculation
if not dev then dev=''; end

conum=conky_parse("${"..var..' '..dev.."}")
conum=tonumber(conum)

tcol=get_color({conum,{20,0x00ffff},{40,0x00ff00},{60,0xffff00},{80,0xff7f00},{100,0xff0000}})


local inum=(((width-lw)/100)*(conum or 0))

if justify=="r" then
across=across-width
elseif justify=="l" then
across=across
end

--background bar
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, col(bgc, bga));
cairo_rectangle (cr, 0, 0, (width-lw), (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 

--indicator bar
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, tcol[1],tcol[2],tcol[3],tcol[4]);
cairo_rectangle (cr, 0, 0, inum, (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 

--boundary line
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_line_width (cr, lw);
cairo_set_source_rgba (cr, col(lc,la));
cairo_rectangle (cr, -lw/2, -lw/2, width, height)
cairo_stroke (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
end

Offline

#887 2013-05-09 13:01:50

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

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

i've included several new features to v9000. it's possible to draw simple bars. u can use all conky-output within your template.

-- weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
-- official update by mrpeachy
-- additional features by lionhead, arclance and dk75
-- optimize lua: http://lua-users.org/wiki/OptimizedStrRep
-- examples: http://cairographics.org/samples/
-- last update 06.07.2013

require 'cairo'
require 'imlib2'

-- #####################################################################
-- ## settings #########################################################
-- #####################################################################

--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"

local username = os.getenv("USERNAME")
local username = "alexander"

local t1="frei" -- when u use fs_free or fs_free_perc
local t2="belegt" -- when u use fs_size
local t3="nicht verfügbar" -- display text when hardrive/usb-stick is unmounted
local t4="n/a" -- display text when internet connection is not avaiable
local t5="gesamt" -- when u use fs_used or fs_used_perc
local t6="verbleibend" -- remaining

local e1="byte" -- B
local e2="kb" -- KiB
local e3="mb"  -- MiB
local e4="gb" -- GiB
local e5="tb" -- TiB
local e6="%"
local e7="mhz" -- cpu frequenz #1
local e8="ghz" -- cpu frequenz #2
local e9="mb/s" -- bitrate
local e10="kb/s" -- downspeedf
local e11="uhr" -- time 24h-format
local e12="prozent"

package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

-- #####################################################################
-- ## end of settings ##################################################
-- #####################################################################

start=1
--INITIALIZE SETTINGS-- need only be run once
settings_table=weather_settings()
--##################################
--######## main function ########### 
function conky_weather()--##########

-- function to convert color into hex-code
function col(c,a)
return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
end--local function

if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]

f=io.popen("curl --max-time 60 --compressed '"..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 --compressed 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")

	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section

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

	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort

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

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

function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end--string split


function xout(txj)
c=nil
a=nil
f=nil
fs=nil
x=nil
y=nil
txt=nil
j=nil

c=(txj.c or default_color)
a=(txj.a or default_alpha)
f=(txj.f or default_font)
fs=(txj.fs or default_font_size)
x=(txj.x or 0)
y=(txj.y or 0)
txt=(txj.txt or "set txt")
j=(txj.j or "l")

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

-- all following functions are working stand-alone
-- they can be copied because they do not have any dependance to work

function out(txj) -- function to output text
	local extents=cairo_text_extents_t:create()
	tolua.takeownership(extents)
	local blurred=nil
	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 face=txj.face					or default_face			or "normal"
	local size=txj.size     			or default_size         or "normal_c"
	--------------------------------------------------------------------
	local hj=txj.hj						or default_hj			or "l"
	--------------------------------------------------------------------
	local shaded=txj.shaded				or default_shaded		or "no"
	local shade_color=txj.shade_color	or default_shade_color	or 0x000000
	local shade_alpha=txj.shade_alpha	or default_shade_alpha	or 1
	--------------------------------------------------------------------
	local underline=txj.underline     	or default_underline    or "no"
	local line_color=txj.line_color    	or   default_line_color or   c
	local line_space=txj.line_space    	or default_line_space   or  5
	local line_width=txj.line_width     or default_line_width   or  1
	--------------------------------------------------------------------
	local number=txj.number  or 8
	local radius=txj.radius or 1.75
	local blurred=txj.blurred or no
	local blurred_color=txj.blurred_color or c
	local blurred_alpha=txj.blurred_alpha or 1
	--------------------------------------------------------------------
	local border=txj.border
	local bc=txj.bc or 0x000000
	local ba=txj.ba or 1
	local bw=txj.bw or 1
	--------------------------------------------------------------------
	cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	----------------------
	if size=="big_c" then
	txt=string.upper(txt)
	elseif size=="small_c" then
	txt=string.lower(txt)
	elseif size=="normal_c" then
	txt=txt
	end
	----------------------
	cairo_set_font_size (cr, fs)
	cairo_text_extents(cr,txt,extents)
	local wx=extents.x_advance -- measure spaces too
	local wd=extents.width
	local hy=extents.height
	local bx=extents.x_bearing
	local by=extents.y_bearing+hy
	local tx=x
	local ty=y
	--set horizontal alignment
	if hj=="l" then
		x=x-bx
	elseif hj=="c" then
		x=x-((wx-bx)/2)-bx
	elseif hj=="r" then
		x=x-wx
	end
	if shaded == "yes" then
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,col(shade_color,shade_alpha))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	end -- if
	-------------------------------------------------
	cairo_move_to (cr,x,y)
	cairo_set_source_rgba (cr,col(c,a))
	cairo_show_text (cr,txt)
	cairo_stroke (cr)
	--------------------------------------------------
	if border=="yes" then
    cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	cairo_set_font_size (cr, fs);
	cairo_move_to (cr, x, y);
	cairo_text_path (cr,txt);
	cairo_set_source_rgba (cr,col(c,a));
	cairo_fill_preserve (cr);
	cairo_set_source_rgba (cr,col(bc,ba));
	cairo_set_line_width (cr, bw);
	cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
	cairo_stroke (cr);
	end


	-- #################################################################
	-- ## decrease alpha if u want to use a small size #################
	-- ## for example fs=12,blurred="yes",ba=0.1 #######################
	-- #################################################################
	if blurred=="yes" then
	 radi,inum,horiz,verti=radius,number,x,y
	
	 for i=1,inum do
	 deg=360/inum
	 text_arc=((2*math.pi/inum)*i)
	 txs=0+radi*(math.sin(text_arc))
	 tys=0-radi*(math.cos(text_arc))
	 -------------------------------------------------------------------
	 cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	 -------------------------------------------------------------------
	 cairo_set_font_size (cr, fs);
	 cairo_set_source_rgba (cr, col(blurred_color,blurred_alpha));
	 cairo_move_to (cr, txs+horiz, tys+verti);
	 cairo_show_text (cr, txt)
     end
	 
	elseif blurred=="no" then
	 txt=txt
	end
	--------------------------------------------------
		if string.find(underline,"yes") ~= nil then

		cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE)
		----------------------------------------------
		startx=x
		endx=startx+wd
		starty=y+line_space
		endy=y+line_space
		-- draw line beyond text ---------------------
		cairo_set_line_width (cr,line_width)
		cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND)
		cairo_set_source_rgba (cr,col(line_color,a))
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wd,endy)
		cairo_stroke (cr)
		
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) --# reset antialiasing
		elseif string.find(underline,"no") ~= nil then
		txt=txt
		end
		
-- different kinds of caps: http://cairographics.org/samples/set_line_cap/
-- different kinds of line join: http://cairographics.org/samples/set_line_join/

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

end--of function out 

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

function font_weight(value)
	fw=nil
	
 	if string.find(value,"normal") ~= nil then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif value=="bold" then
	fw=CAIRO_FONT_WEIGHT_BOLD
	elseif value=="italic" then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif value =="bolditalic" then
    fw=CAIRO_FONT_WEIGHT_BOLD
	elseif string.find(value,"oblique") ~= nil then 
    fw=CAIRO_FONT_WEIGHT_NORMAL
	end
	    
	return fw
end



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

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

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


-- #####################################################################
-- ## display external and local images ################################
-- #####################################################################

function image(im) -- display local images
	local x,y,w,h = nil,nil,nil,nil
	local file = nil
	
	x =im.x or 0
	y =im.y or 0
	w =im.w or default_image_width -- default width is defined within the template
	h =im.h or default_image_height -- default height is defined within the template

	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 --# if show == nil then 
	imlib_context_set_image(show)
	local WIDTH = nil
	if tonumber(w) == 0 then 
		WIDTH = imlib_image_get_width() 
	else
		WIDTH = tonumber(w)
	end -- if
	local HEIGHT = nil
	if tonumber(h) == 0 then HEIGHT = imlib_image_get_height() else HEIGHT = tonumber(h) end --# if tonumber(h) == 0 then 
	local scaled = imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), WIDTH, HEIGHT)
	imlib_free_image_and_decache()
	imlib_context_set_image(scaled)
	imlib_render_image_on_drawable(x, y)
	imlib_free_image_and_decache()
	show = nil
	WIDTH = nil
	HEIGHT = nil
	x = nil
	y = nil
	w = nil
	h = nil
	file = nil
	scaled = nil
end --# function

function extern(wb)

	local s,j=nil,nil
	local imgw,imgh=nil,nil
	local img_w,img_h=nil,nil
	local imgwidth,imgheight=nil,nil
	local img_nw,img_x,imgy=nil,nil,nil
	--------------------------------------------------------------------
	img_x=wb.posx or 0
	img_y=wb.posy or 0
	img_w,imgh=wb.imgw,wb.imgh
	j=wb.j or "l"
	scaled=wb.scaled or "no"
	scale_size=wb.scale_size or 200
	
	img_nw=wb.imghdd or "external_img.jpg"
	s=wb.imgurl
	img_file='/home/'..username.."/"..img_nw
	img_intervall=wb.imgiv or 60
	
	local updates = tonumber(conky_parse('${updates}'))
	if (math.mod(updates, img_intervall) == 0) then
		os.execute("wget  -q -O "..img_file..' "'..s..'"')
	end

	if img_file==nil then print("set image file") end -- stop script when img isn't avaiable
	--------------------------------------------------------------------
	if scaled=="yes" then
		local show = imlib_load_image(img_file)
		if show == nil then return 	end
		imlib_context_set_image(show)
		imgwidth= imlib_image_get_width()
		imgheight=imlib_image_get_height()
		imgw=scale_size
		imgh=(imgw*imgheight)/imgwidth
		imlib_free_image_and_decache() -- remove from cache
	else
		imgw=img_w
		imgh=img_h
	end
	-- set alignment (sometimes very useful) ---------------------------
	if j=="l" then
	 img_x=img_x
	elseif j=="r" then
	 img_x=img_x-imgw
	end
	--------------------------------------------------------------------
	image({x=img_x,y=img_y,w=imgw,h=imgh,file=img_file}) -- load image
	
end--of function


-- #####################################################################
-- ## functions to modify conky-output #################################
-- #####################################################################

function os_capture(cmd, raw) -- parse shell in lua
	local f = assert(io.popen(cmd, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	if raw then return s end
	s = string.gsub(s, '^%s+', '')
	s = string.gsub(s, '%s+$', '')
	s = string.gsub(s, '[\n\r]+', ' ')
	return s
end



function parseValue(value,value1,value2,del,ending) -- remove ending and add custom ending
	jn=value:gsub(value1,"") 
	if ending=="no" then mv=chgFormat(jn,del) else mv=chgFormat(jn,del)..' '..value2 end
return mv
end


function nounit(device,var,ending,value)
	if var=="no" then ms=value else ms=value.." "..ending end
	return ms
end

function snu(ending,ct,cn)
		if ending=="yes" then mv=cn.." "..ct else mv=cn end
		return mv
end

function dropSign(dev,sign)
ms=conky_parse("${if_mounted "..dev.."}"..sign.."${else}".."".."${endif}")
return ms
end


function chgFormat(number,del) --replace decimal point with ,

point=string.find(number,"%p")
if point~=nil then
n1=string.sub(number,1,point-1)
n2=string.sub(number,point,string.len(number))
n2=string.gsub(n2,"^.",",")

	if string.len(n2)==2 then
	n2=n2..""
	elseif string.len(n2)>3 then
	n2=string.sub(n2,1,3)	
	end
else
n1=number
n2=del.."0"
end

--put in divisions
n1len=string.len(n1)
divs=math.floor((n1len-1)/3)
if n1len>3 then
	for i=1,divs do
	n=n1len-(i*3)
	bit1=string.sub(n1,1,n)
	bit2=string.sub(n1,n+1)
	n1=bit1.."."..bit2
	end
end
output=n1..n2

return output
end


function ram(dev,value,del,se,e)

local re,ln,d=nil,nil,nil

re=string.gsub(tostring(value), "(%d*\.*%d+).*", "%1") -- remove ending
ln=string.len(re)
ln=tonumber(ln)
d=del

local st1,st2,stg=nil,nil,nil

if del=="," then t="." else t="," end

if ln == 4 then
st1=string.sub(re,1,1)
st2=string.sub(re,2,ln)
v=st1..t..st2
stg=nounit(dev,se,e3,v)
elseif ln == 5 then
st1=string.sub(re,1,2)
st2=string.sub(re,3,ln)
v=st1..t..st2
stg=nounit(dev,se,e3,v)
else
stg=re.." mb"
end

return stg
end


function chgDel(value,del)

local ausgang=nil
local ersteZahl=nil
local rest=nil
local outputNumber=nil

ausgang=string.gsub(value, "(%d*\.*%d+).*", "%1") -- remove ending
ausgang=tonumber(ausgang)

if not ausgang then ausgang=0; end

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

return outputNumber

end -- of function


function add_decimal(input,sign)  -- add decimal place, i.e. 5,0
if string.find(input,"%a")==nil then -- look for string
        if string.find(input,"%p")==nil then         -- only add decimal place when value is a number
        input=input..sign..'0'
        end
end
return input
end

function parse(value,delimiter,ending)

	local ms=nil
	value = value:gsub(" ","")
	if value==nil then value=0 end
	
	---- short_units no ------------------------------------------------
	if ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=parseValue(value,"B",e1,delimiter,ending)
	elseif string.find(value, 'KiB') ~= nil then
		ms=parseValue(value,"KiB",e2,delimiter,ending)
	elseif string.find(value, 'MiB') ~= nil then
		ms=parseValue(value,"MiB",e3,delimiter,ending)
	elseif string.find(value, 'GiB') ~= nil then
		ms=parseValue(value,"GiB",e4,delimiter,ending)
	elseif string.find(value, "TiB") ~= nil then
		ms=parseValue(value,"TiB",e5,delimiter,ending)
	---- short_units yes -----------------------------------------------
	elseif ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=parseValue(value,"B",e1,delimiter,ending)
	elseif string.find(value, "K") ~= nil then
		ms=parseValue(value,"K",e2,delimiter,ending)
	elseif string.find(value, "M") ~= nil then
		ms=parseValue(value,"M",e3,delimiter,ending)
	elseif string.find(value, "G") ~= nil then
		ms=parseValue(value,"G",e4,delimiter,ending)
	elseif string.find(value, "T") ~= nil then
		ms=parseValue(value,"T",e5,delimiter,ending)
	else
		ms=value:gsub(" ","") -- remove space
	end

	return ms
end -- of function

function notxt(txt,text)
 if txt=="yes" then nt=text else nt="" end
return nt
end

function nomt(txt,text)
if txt=="yes" then mv=text else mv="" end
return mv
end

function display_text_fs(dev,val,text,ch)
          if ch=="no" then
           ms=conky_parse("${if_mounted "..dev.."}"..val.."${else}"..nomt(st,t3).."${endif}")
          elseif ch=="yes" then
           ms=conky_parse("${if_mounted "..dev.."}"..val.." "..text.."${else}"..nomt(st,t3).."${endif}")
          end
      
return ms
end

	
function display_text_perc(status1,status2,ending,name,value,dev,n)
ms=nil
print(name)
if string.find(n,"yes") ~= nil then ms=n2w4d(value).." "..e12 
elseif string.find(n,"no") ~= nil then 
ms=nounit(dev,status2,ending,value) 
end
          
return ms
end

function display_text_fs_perc(status1,status2,status3,ending,name,value,dev)
 if status1=="no" then
 ms=conky_parse("${if_mounted "..dev.."}"..nounit(dev,status2,ending,value).."${else}"..nomt(status3,t3).."${endif}")
 elseif status1=="yes" then
 ms=conky_parse("${if_mounted "..dev.."}"..nounit(dev,status2,ending,value).." "..name.."${else}"..nomt(status3,t3).."${endif}")
 end  
          
return ms
end

function system(cd)

--[[
variable --> argument for example fs_free
device 	--> system-device for example wlan0
del --> delimiter of number
tf --> format of shown time for example 13:15 uhr or 1:15 pm
se --> show ending for example 1.000 instead of 1.000 mb
dt --> show current date
st --> display text for example unmounted yes or no
txt --> show word for example 10 mb frei
cn --> convert numbers into words
you can call the function like this (example):
]]--

local t,x,ms=nil,nil,nil

local variable=cd.variable
local device=cd.device or ''
local del=cd.del or '.'
local tf=cd.tf or '24'
local se=cd.se or "yes"
local txt=cd.txt or "yes"
local dt=cd.dt or "no"
local st=cd.st or "yes"
local cn=cd.cn or "no"

if conky_window == nil then return end -- stop script when conky_window doesn't exist

local rawdata=conky_parse("${"..variable..' '..device.."}")
local adv=parse(rawdata,del,se)

	if string.find(variable,"cpu") ~= nil then
		ms=display_text_perc(txt,se,e6,t2,rawdata,device,cn)
	elseif string.find(variable,"uptime") ~= nil or string.find(variable,"user_number") ~= nil then
		ms=rawdata
	elseif ((string.find(variable, "perc") ~= nil) or (string.find(variable, "percent") ~= nil)) then
	--------------------------------------------------------------------	
		if string.find(variable, "fs_free_perc") ~= nil then
		ms=display_text_fs_perc(txt,se,st,e6,t1,rawdata,device,cn)
		elseif string.find(variable, "fs_used_perc") ~= nil then
		ms=display_text_fs_perc(txt,se,st,e6,t2,rawdata,device,cn)		
		elseif string.find(variable, "memperc") ~= nil then
		ms=display_text_perc(txt,se,e6,t2,rawdata,device,cn)
		elseif string.find(variable, "battery_percent") ~= nil then
		ms=display_text_perc(txt,se,e6,t6,rawdata,device,cn)		 
		elseif string.find(variable, "swapperc") ~= nil then
		ms=display_text_perc(txt,se,e6,t2,rawdata,device,cn)
		else ms=nounit(device,se,e6,rawdata) end
	--------------------------------------------------------------------
	elseif string.find(variable,"freq") ~= nil and string.find(variable,"_g") == nil then
		jn=chgDel(adv,del)
		ms=nounit(device,se,e7,jn)
	elseif string.find(variable,"freq") ~= nil and string.find(variable,"_g") ~= nil then
		jn=chgFormat(adv,del)
		ms=nounit(device,se,e8,add_decimal(jn,del))
	--------------------------------------------------------------------
	elseif string.find(variable,"swapfree") ~= nil then
		ms=snu(txt,t1,adv)
	elseif string.find(variable, "swapmax") ~= nil then
	    ms=snu(txt,t5,adv)
	elseif string.find(variable, "memmax") ~= nil then
		ms=ram(device,rawdata,del,se,e3)
	--------------------------------------------------------------------
	elseif string.find(variable,"memfree") ~= nil or string.find(variable,"memeasyfree") ~= nil then
		ms=snu(txt,t1,adv)
	--------------------------------------------------------------------
	elseif string.find(variable,"wireless_bitrate") ~= nil then
		t=rawdata:gsub("Mb/s","")
		t=chgDel(t,del)
		t=add_decimal(t,del)
		t=t:gsub(" ","")
		ms=conky_parse("${if_up "..device.."}"..nounit(device,se,e9,t).."${else}"..t4.."${endif}")
	elseif string.find(variable,"wireless_essid") ~= nil or string.find(variable,"wireless_mode") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..rawdata.."${else}"..t4.."${endif}")
	elseif string.find(variable,"wireless_link_qual") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..nounit(device,se,e6,adv).."${else}"..t4.."${endif}")
	elseif string.find(variable,"upspeedf") ~= nil or string.find(variable,"downspeedf") ~= nil then
		jn=chgFormat(adv,del)
		ms=conky_parse("${if_up "..device.."}"..nounit(device,se,e10,add_decimal(jn,del)).."${else}"..t4.."${endif}")
	elseif string.find(variable,"battery") ~= nil or string.find(variable,"loadavg") ~= nil then
		ms=rawdata
------------------------------------------------------------------------
    elseif variable=="fs_free" and device=="/" then
     ms=display_text_fs(device,adv,t1,txt)
    elseif variable=="fs_used" and device=="/" then
     ms=display_text_fs(device,adv,t2,txt)
    elseif variable=="fs_size" and device=="/" then
     ms=display_text_fs(device,adv,t5,txt)
------------------------------------------------------------------------
    elseif string.find(variable,"fs_free") ~= nil and string.find(device,"/home") ~= nil then
     ms=display_text_fs(device,adv,t1,txt)
    elseif string.find(variable,"fs_used") ~= nil and string.find(device,"/home") ~= nil then
     ms=display_text_fs(device,adv,t2,txt)
    elseif string.find(variable,"fs_size") ~= nil and string.find(device,"/home") ~= nil then
     ms=display_text_fs(device,adv,t5,txt)
	--------------------------------------------------------------------
	elseif string.find(variable,"up") == nil and string.find(variable,"time") ~= nil then

if dt=="yes" then
ms=nounit(device,se,"",adv)
ms=ms:gsub(" ","")
else  ------------------------------------------------------------------
 if tf == "24" then ms=nounit(device,se,e11,adv) elseif tf == "12" then ms=convert12(rawdata) end 
end --------------------------------------------------------------------

--[[
time/date: http://search.cpan.org/~gbarr/TimeDate-2.30/lib/Date/Format.pm

%B name of the month
%m month number, for example 05
%y year short number, for example 13
%Y year long number, for example 2013
%d day number
]]--

	else
	--------------------------------------------------------------------
		if string.find(device,"wlan") ~= nil or string.find(device,"eth") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..adv.."${else}"..t4.."${endif}")
		elseif string.find(device,"media") ~= nil then
		  --------------------------------------------------------------
          if txt=="no" and string.find(variable,"free") ~= nil then
           ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}"..nomt(st,t3).."${endif}")
          elseif txt=="yes" and string.find(variable,"free") ~= nil then
           ms=conky_parse("${if_mounted "..device.."}"..adv.." "..t1.."${else}"..nomt(st,t3).."${endif}")

		  elseif txt=="no" and string.find(variable,"used") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}"..nomt(st,t3).."${endif}")
		  elseif txt=="yes" and string.find(variable,"used") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.." "..t2.."${else}"..nomt(st,t3).."${endif}")
		   
		  elseif txt=="no" and string.find(variable,"size") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}"..t3.."${endif}")
		  elseif txt=="yes" and string.find(variable,"size") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.." "..t5.."${else}"..nomt(st,t3).."${endif}")
		   
		  end
		  --------------------------------------------------------------
		else ms=adv  end 
	--------------------------------------------------------------------
	end

	return ms

end -- of function



function dropZero(wert) -- drop leading charcacter

local ausgabe,erstezahl=nil,nil

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

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

return ausgabe

end -- of function


function draw_bar(db) -- draw simple bar
------------------------------------------------------------------------
local var,dev=nil,nil
local width,height=nil,nil
local across,down=nil,nil
local bgc,bga=nil,nil
local inc,ina=nil,nil
local lc,la=nil,nil
local lw,rotate,justify=nil,nil,nil
------------------------------------------------------------------------

m=db.max or 100 -- maximal value
dev=db.dev or "" -- device
width,height,lw=db.w,db.h,db.lw
across,down,var=db.x,db.y,db.var
bgc,inc,lc=db.bgc,db.indc,db.lc
------------------------------------------------------------------------
bga=db.bga or 1
ina=db.inda or 1
la=db.la or 1
------------------------------------------------------------------------
rotate=db.r or 0
justify=db.j or "l"
------------------------------------------------------------------------
if conky_window == nil then return end

local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
------------------------------------------------------------------------
if updates>5 then -- starts the display

--indicator calculation
if not dev then dev=''; end

conum=conky_parse("${"..var..' '..dev.."}")
conum=tonumber(conum)

local inum=(((width-lw)/100)*(conum or 0))
local x =  100 * inum / m

-- justify bar (sometimes useful)
if justify=="r" then across=across-width elseif justify=="l" then across=across end

-- background bar ------------------------------------------------------
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, col(bgc, bga));
cairo_rectangle (cr, 0, 0, (width-lw), (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
--indicator bar --------------------------------------------------------
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, col(inc,ina));
cairo_rectangle (cr, 0, 0, x, (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
--boundary line --------------------------------------------------------
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_line_width (cr, lw);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_source_rgba (cr, col(lc,la));
cairo_rectangle (cr, -lw/2, -lw/2, width, height)
cairo_stroke (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
	end
end

--[[
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);  --- pointed corner (default)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);  --- bevel corner	
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);  --- rounded corner
]]--

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

function convert12(value) 

local stunden,minuten=nil,nil
local zeit,sekunden=nil,nil

local stunden=string.sub(value,1,2) 	-- hours
local stunden=tonumber(stunden) 		-- convert hours into numbers
local minuten=string.sub(value,4,5)	 	-- minutes
local sekunden=string.sub(value,7,8) 	-- seconds

-- still calculate if string doesn't exists
if not stunden then stunden=0; end

if stunden > 12 and stunden < 24 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' pm'
	else zeit=(stunden-12)..':'..minuten..' pm' end
elseif stunden < 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' am'
	else zeit=stunden..':'..minuten..' am' end
elseif stunden == 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' pm'
	else zeit=stunden..':'..minuten..' pm' end
elseif stunden == 24 or stunden == 0 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' am'
	else zeit=(stunden-12)..':'..minuten..' am' end
end

return zeit

end -- of function



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

 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

-- #####################################################################
-- ## end of functions to modify conky-output ##########################
-- #####################################################################


-- #####################################################################
-- ## gimmicks #########################################################
-- #####################################################################

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


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


function conky_battbar() -- display graphical battery bar

if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))

if updates>5 then
------------------------------------------------------------------------

cairo_set_line_width (cr, 20); --set line thickness
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
cairo_rotate (cr, 50)

x_position,y_position=45,530 -- position of bar
length=80 --set total length of line

cairo_set_source_rgba (cr,1,1,1,0.5) --set color and alpha for background
cairo_move_to (cr,x_position,y_position)--reference positions set above
cairo_rel_line_to (cr,length,0)--reference length set above
cairo_stroke (cr)-- draws the line

--draw indicator line, draw after background so it draws ontop
battperc=tonumber(conky_parse("${battery_percent BAT1}"))--tonumber makes sure battvalue is a number
battvalue=(length/100)*battperc
cairo_set_source_rgba (cr,1,1,0,0.8) -- define color
cairo_move_to (cr,x_position,y_position)--reference positions set above
cairo_rel_line_to (cr,battvalue,0)--reference battvalue calculated above
cairo_stroke (cr)-- draws the line
------------------------------------------------------------------------
end-- if updates

cairo_destroy(cr) -- avoid memory leaks
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

-- #####################################################################
-- ## end of script ####################################################
-- #####################################################################

can see the most of the features that are possible: http://ompldr.org/vaWN0ag

this is my current screenshot: http://i.imgbox.com/adsx8qhW.png

i think that i should rename the file v9000.lua into allinone.lua smile

edit: the improved script only uses less then 10% cpu-power. the screenshot shows another value but the browser and the email-client are open at this time! the browser 'google chrome' uses a lot of power.

you can use the date within v9000:

out({x=145,y=90,c=0xF47B20,fs=14,size="small_c",txt=system({variable="time %d.%m.",dt="yes"})})

to utilize this use the setting

dt="yes""

the standard-setting is NO, you do not have to declare it.


if u want to use the 'standard-output' of conky then use this (for example):

conky_parse("${"$fs_free_perc /"}")

this will not look so good but it's still possible smile

this is an example of the customized conky-output: http://i.imgbox.com/acwON1NT.png

if u want to display the free percentage of your home-folder then declare:

out({x=posx_3b,y=posy+60,c=dunkel,fs=10,txt=system({variable="fs_free_perc",device="/home",txt="yes"}),hj='r'})

sometimes it is neccessary that we use sign like ( this. but it's still there when drive is unmounted. therefore i've wrote a little function:

function dropSign(dev,sign)
ms=conky_parse("${if_mounted "..dev.."}"..sign.."${else}".."".."${endif}")
return ms
end

you can call this function like this:

dropSign("/home","(")

you can manipulate the words (for example 'frei'). furthermore you also can disable the unit (for example 'gb')

acnHS1nZ.jpg
abvGuCz6.jpg

this code shows the content of the images:

out({x=posx_1a,y=posy,c=hell,txt="home:"})
out({x=posx_1b,y=posy,c=dunkel,fs=10,txt=system({variable="fs_free",device="/home",txt="yes",st="no",se="yes"}).." "..dropSign("/home","(")..system({variable="fs_size",device="/home",txt="no",st="yes"})..dropSign("/home",")"),hj='r'})

sometimes it looks better when the number is converted into a word. because the output now inlucdes the ending the whole output is a string. that's why i included a switch:

cn="yes"

when i use this setting the output is now 'acht' (eight) instead of 8

the standardsetting is

cn="no"

.
u do not have to declare it but it won't hurt smile call the function like this:

system({variable="cpu",device="CPU0",cn="yes",st="no",se="yes"})

the function that converts the numbers only in german words. but i will include an option for english output.

Last edited by lionhead (2013-07-06 17:53:46)

Offline

#888 2013-05-19 15:32:32

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

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

i fixed a minor bug within my function.

it should work with existing templates.

Last edited by lionhead (2013-05-19 15:34:27)

Offline

#889 2013-07-05 06:09:23

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

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

Ok, I have tried everything I can think of to figure it out, but I'm lost, the v9000 has completely stopped working for me, I have downloaded new versions, restored old versions, changed things a bit, nothing works, is there something I'm missing somewhere? Is anyone else having issues with v9000?


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

Offline

#890 2013-07-05 07:17:48

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

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

please dont say that you have problems with my custom v9000.

i tried it yesterday with an other computer. and everything worked perfect!

when i start my v9000 via console i do not have any error messages!

have u changed the username within v9000.lua?

--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"

local username = os.getenv("USERNAME")
local username = "alexander"

Offline

#891 2013-07-05 07:44:46

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

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

yesI have, and I have the same issues, with yours, the stock one, older versions, newer versions, i can't get it to work at all


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

Offline

#892 2013-07-05 08:50:55

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

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

I need to start it from the console and see what the deal is, stupid me I haven't done that yet lol. Will post back when I have some terminal output to show what the hell is going on.


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

Offline

#893 2013-07-05 09:21:38

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

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

McLovin wrote:

yesI have, and I have the same issues, with yours, the stock one, older versions, newer versions, i can't get it to work at all

normally you should unpack it and everything is ok. but i did it 'the hard way'. smile

copy the file '.v9000_config.lua' from your place to this:

/home/yourname/.v9000_config.lua

create a directory, named v9000 and copy v9000.lua to this folder:

/home/yourname/v9000/v9000.lua


and then use your template. i created a test-template that contains everything (try it):

--[[
 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="mono" --font must be in quotes
default_font_size=10
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=25
local posy=170
local hell=dnc(0xd1cf3d,0xb3a7a7)
local dunkel=dnc(0xa3a23f,0xb3a7a7)


local f=dnc(0xffff00,0xb3a7a7)

-- aktuelle Temperatur
out({x=50,y=30,c=dnc(0xffff00,0xb3a7a7),f='Anonymous Pro:bold',fs=20,face="bold",blurred="no",txt=now["temp"].." °C"})

-- weather icon
image({x=650,y=0,h=65,w=65,file=now["weather_icon"]})

-- moon icon
image({x=650,y=100,w=40,h=40,file=moon_icon[1]})



out({f="Moon Phases",fs=40,x=910,y=100,c=hell,shaded="yes",txt=moon_font[1],hj='c'})
out({f="ConkyWeather",fs=32,x=900,y=150,w=50,h=50,shaded="yes",txt=now["weather_font"]})
out({x=900,y=200,c=hell,f='mono',fs=20,face="bold",border="yes",underline="no",txt=now["temp"].." °C",hj='l'})

local geschw_1=conky_parse('${downspeed wlan0}')
local geschw_2=conky_parse('${downspeedf wlan0}')

local geschw_3=conky_parse('${upspeed wlan0}')
local geschw_4=conky_parse('${upspeedf wlan0}')

local total_1=conky_parse('${totalup wlan0}')
local total_2=conky_parse('${totaldown wlan0}')

local fs_folder_home=system({variable="fs_free",device="/home",txt="yes",se="yes"})
local fs_folder_used=system({variable="fs_used",device="/home",txt="yes",se="yes"})

local fs_folder_root=system({variable="fs_free",device="/",txt="yes",se="yes"})
local fs_root_used=system({variable="fs_used",device="/",txt="yes",se="yes"})

spalte_1a=0
spalte_1b=170

spalte_2a=220
spalte_2b=390

spalte_3a=440
spalte_3b=620

spalte_4a=670
spalte_4b=860


-- ## spalte 1 #########################################################

out({x=spalte_1a,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_free:',hj='l'})
out({x=spalte_1a,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='root-folder:',hj='l'})

out({x=spalte_1b,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=fs_folder_root,hj='r'})
out({x=spalte_1b,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_free /}'),hj='r'})

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

out({x=spalte_1a,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_free:',hj='l'})
out({x=spalte_1a,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='home-folder:',hj='l'})

out({x=spalte_1b,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=fs_folder_home,hj='r'})
out({x=spalte_1b,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_free /home}'),hj='r'})

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

out({x=spalte_1a,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_free_perc:',hj='l'})
out({x=spalte_1a,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='home-folder:',hj='l'})

out({x=spalte_1b,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_free_perc",device="/home",txt="yes",st="yes",se="yes"}),hj='r'})
out({x=spalte_1b,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_free_perc /home}'),hj='r'})

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

out({x=spalte_1a,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='downspeedf:',hj='l'})
out({x=spalte_1a,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="downspeedf",device="wlan0",del=',',se="yes"}),hj='r'})
out({x=spalte_1b,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=geschw_2,hj='r'})

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

out({x=spalte_1a,y=320,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='conky-version:',hj='l'})
out({x=spalte_1a,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=320,c=f,f="mono",fs=10,face="italic",size="big_c",shaded="yes",txt=system({variable="conky_version"}),hj='r'})
out({x=spalte_1b,y=335,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${conky_version}'),hj='r'})

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

out({x=spalte_1a,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='totalup:',hj='l'})
out({x=spalte_1a,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="totalup",device="wlan0",del=','}),hj='r'})
out({x=spalte_1b,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=total_1,hj='r'})

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

out({x=spalte_1a,y=270,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='machine:',hj='l'})
out({x=spalte_1a,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=270,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="machine"}),hj='r'})
out({x=spalte_1b,y=285,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${machine}'),hj='r'})

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

out({x=spalte_1a,y=370,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='mem:',hj='l'})
out({x=spalte_1a,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=370,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="mem",txt="yes",del=","}),hj='r'})
out({x=spalte_1b,y=385,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${mem}'),hj='r'})

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

out({x=spalte_1a,y=420,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='memeasyfree:',hj='l'})
out({x=spalte_1a,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=420,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="memeasyfree",txt="yes",del=",",se="yes"}),hj='r'})
out({x=spalte_1b,y=435,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${memeasyfree}'),hj='r'})

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

out({x=spalte_1a,y=470,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='memfree:',hj='l'})
out({x=spalte_1a,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=470,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="memfree",txt="yes",del=".",se="yes"}),hj='r'})
out({x=spalte_1b,y=485,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${memfree}'),hj='r'})

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

out({x=spalte_1a,y=520,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='memmax:',hj='l'})
out({x=spalte_1a,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_1b,y=520,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="memmax",txt="no",del=",",se="yes"}),hj='r'})
out({x=spalte_1b,y=535,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${memmax}'),hj='r'})



-- ## spalte 2 #########################################################

out({x=spalte_2a,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used:',hj='l'})
out({x=spalte_2a,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='root-folder:',hj='l'})

out({x=spalte_2b,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=fs_root_used,hj='r'})
out({x=spalte_2b,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used /}'),hj='r'})

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

out({x=spalte_2a,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used:',hj='l'})
out({x=spalte_2a,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='home-folder:',hj='l'})

out({x=spalte_2b,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=fs_folder_used,hj='r'})
out({x=spalte_2b,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used /home}'),hj='r'})

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

out({x=spalte_2a,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used_perc:',hj='l'})
out({x=spalte_2a,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='home-folder:',hj='l'})

out({x=spalte_2b,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_used_perc",device="/home",txt="yes",se="yes"}),hj='r'})
out({x=spalte_2b,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used_perc /home}'),hj='r'})

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

out({x=spalte_2a,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='upspeedf:',hj='l'})
out({x=spalte_2a,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="upspeedf",device="wlan0",del=',',se="yes"}),hj='r'})
out({x=spalte_2b,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=geschw_4,hj='r'})

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

out({x=spalte_2a,y=270,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='router:',hj='l'})
out({x=spalte_2a,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=270,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_essid",device="wlan0"}),hj='r'})
out({x=spalte_2b,y=285,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_essid wlan0}'),hj='r'})

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

out({x=spalte_2a,y=320,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='link_qual:',hj='l'})
out({x=spalte_2a,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=320,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_link_qual",device="wlan0"}),hj='r'})
out({x=spalte_2b,y=335,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_link_qual wlan0}'),hj='r'})

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

out({x=spalte_2a,y=370,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='wireless mode:',hj='l'})
out({x=spalte_2a,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=370,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_mode",device="wlan0"}),hj='r'})
out({x=spalte_2b,y=385,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_mode wlan0}'),hj='r'})

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

out({x=spalte_2a,y=420,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='lokale ip:',hj='l'})
out({x=spalte_2a,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=420,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="addr",device="wlan0"}),hj='r'})
out({x=spalte_2b,y=435,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${addr wlan0}'),hj='r'})

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

out({x=spalte_2a,y=470,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='globale ip:',hj='l'})
out({x=spalte_2a,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=470,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=conky_parse('${execi 7200 wget http://v4.ipv6-test.com/api/myip.php -q -O -}'),hj='r'})
out({x=spalte_2b,y=485,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${execi 7200 wget http://v4.ipv6-test.com/api/myip.php -q -O -}'),hj='r'})

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

out({x=spalte_2a,y=520,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='bitrate:',hj='l'})
out({x=spalte_2a,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=520,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="wireless_bitrate",device="wlan0",del=","}),hj='r'})
out({x=spalte_2b,y=535,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${wireless_bitrate wlan0}'),hj='r'})

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

out({x=spalte_2a,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='totaldown:',hj='l'})
out({x=spalte_2a,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_2b,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="totaldown",device="wlan0",del=',',se="yes"}),hj='r'})
out({x=spalte_2b,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=total_2,hj='r'})



-- ## spalte 3 #########################################################

out({x=spalte_3a,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used:',hj='l'})
out({x=spalte_3a,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='usb-stick:',hj='l'})

out({x=spalte_3b,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_used",device="/media/3873-0B71",st="yes",txt="yes",se="yes"}),hj="r"})
out({x=spalte_3b,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used /media/3873-0B71}'),hj='r'})

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

out({x=spalte_3a,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='fs_used_perc:',hj='l'})
out({x=spalte_3a,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='usb-stick:',hj='l'})

out({x=spalte_3b,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_used_perc",device="/media/3873-0B71",txt="yes",st="yes",se="yes"}) ,hj='r'})
out({x=spalte_3b,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_used_perc /media/3873-0B71}'),hj='r'})

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

out({x=spalte_3a,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='zeit (deutsch):',hj='l'})
out({x=spalte_3a,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="time %k:%M"}),hj='r'})
out({x=spalte_3b,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${time %k:%M}'),hj='r'})

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

out({x=spalte_3a,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='zeit (englisch):',hj='l'})
out({x=spalte_3a,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="time %k:%M",tf="12"}),hj='r'})
out({x=spalte_3b,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${time %k:%M:%S}'),hj='r'})

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

out({x=spalte_3a,y=270,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='variable uptime:',hj='l'})
out({x=spalte_3a,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=270,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="uptime"}),hj='r'})
out({x=spalte_3b,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${uptime}'),hj='r'})

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

out({x=spalte_3a,y=320,c=f,f="mono",fs=10,face="italic",shaded="yes",txt="batterie:",hj='l'})
out({x=spalte_3a,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=320,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="battery",device="BAT1"}),hj='r'})
out({x=spalte_3b,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${battery BAT1}'),hj='r'})

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

out({x=spalte_3a,y=370,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='batterie %:',hj='l'})
out({x=spalte_3a,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=370,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="battery_percent",device="BAT1",txt="yes",st="yes",se="yes"}),hj='r'})
out({x=spalte_3b,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${battery_percent BAT1}'),hj='r'})

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

out({x=spalte_3a,y=420,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='datum:',hj='l'})
out({x=spalte_3a,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=420,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="time %d.%m.%Y",dt="yes"}),hj='r'})
out({x=spalte_3b,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${time %d.%m.%Y}'),hj='r'})

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

out({x=spalte_3a,y=470,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='praxis #1:',hj='l'})
out({x=spalte_3a,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='usb-stick:',hj='l'})

out({x=spalte_3b,y=470,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_free",device="/media/3873-0B71",txt="no",st="no",se="no"}).." "..dropSign("/media/3873-0B71","/").." "..system({variable="fs_size",device="/media/3873-0B71",txt="no",st="yes"}),hj='r'})
out({x=spalte_3b,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_free /media/3873-0B71}').." / "..conky_parse('${fs_size /media/3873-0B71}'),hj='r'})

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

out({x=spalte_3a,y=520,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='praxis #2:',hj='l'})
out({x=spalte_3a,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='externe hdd:',hj='l'})

out({x=spalte_3b,y=520,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="fs_free",device="/media/Elements",txt="no",st="no",se="no"}).." "..dropSign("/media/Elements","/").." "..system({variable="fs_size",device="/media/Elements",txt="no",st="yes"}),hj='r'})
out({x=spalte_3b,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${fs_free /media/Elements}').." / "..conky_parse('${fs_size /media/Elements}'),hj='r'})

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

out({x=spalte_3a,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='nodename:',hj='l'})
out({x=spalte_3a,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_3b,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="nodename"}),hj='r'})
out({x=spalte_3b,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${nodename}'),hj='r'})

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

out({x=spalte_4a,y=320,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='memperc:',hj='l'})
out({x=spalte_4a,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=320,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="memperc",txt="yes"}),hj='r'})
out({x=spalte_4b,y=335,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${memperc}'),hj='r'})

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

out({x=spalte_4a,y=270,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='swap:',hj='l'})
out({x=spalte_4a,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=270,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swap",del=","}),hj='r'})
out({x=spalte_4b,y=285,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swap}'),hj='r'})

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

out({x=spalte_4a,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='swapfree:',hj='l'})
out({x=spalte_4a,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=220,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swapfree",txt="yes"}),hj='r'})
out({x=spalte_4b,y=235,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swapfree}'),hj='r'})

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

out({x=spalte_4a,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='swapmax:',hj='l'})
out({x=spalte_4a,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=170,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swapmax",txt="yes",se="yes"}),hj='r'})
out({x=spalte_4b,y=185,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swapmax}'),hj='r'})

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

out({x=spalte_4a,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='swapperc:',hj='l'})
out({x=spalte_4a,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=120,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="swapperc",txt="yes",se="yes"}),hj='r'})
out({x=spalte_4b,y=135,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${swapperc}'),hj='r'})


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

out({x=spalte_4a,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='user_number:',hj='l'})
out({x=spalte_4a,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=65,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=n2w(system({variable="user_number"})),hj='r'})
out({x=spalte_4b,y=80,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${user_number}'),hj='r'})

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

out({x=spalte_4a,y=370,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='cpu prozent:',hj='l'})
out({x=spalte_4a,y=385,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=370,c=f,f="mono",fs=10,face="italic",size="small_c",shaded="yes",txt=system({variable="cpu",device="cpu0",txt="yes",se="yes"}),hj='r'})
out({x=spalte_4b,y=385,c=0xffffff,f="mono",fs=10,face="italic",size="normal_c",shaded="yes",txt=conky_parse('${cpu}'),hj='r'})

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

out({x=spalte_4a,y=420,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='cpu frequenz (freq):',hj='l'})
out({x=spalte_4a,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=420,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="freq",device="cpu0",se="yes",del=","}),hj='r'})
out({x=spalte_4b,y=435,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${freq}'),hj='r'})

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

out({x=spalte_4a,y=470,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='cpu frequenz (freq_g):',hj='l'})
out({x=spalte_4a,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=470,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="freq_g",se="yes"}),hj='r'})
out({x=spalte_4b,y=485,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${freq_g}'),hj='r'})

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

out({x=spalte_4a,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='prozesse:',hj='l'})
out({x=spalte_4a,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=10,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="processes"}).." ("..system({variable="running_processes"})..")",hj='r'})
out({x=spalte_4b,y=25,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${running_processes}'),hj='r'})

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

out({x=spalte_4a,y=520,c=f,f="mono",fs=10,face="italic",shaded="yes",txt='kernel-version:',hj='l'})
out({x=spalte_4a,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt='original:',hj='l'})

out({x=spalte_4b,y=520,c=f,f="mono",fs=10,face="italic",shaded="yes",txt=system({variable="kernel"}),hj='r'})
out({x=spalte_4b,y=535,c=0xffffff,f="mono",fs=10,face="italic",shaded="yes",txt=conky_parse('${kernel}'),hj='r'})



--conky_battbar()
draw_bar({var="cpu",dev="cpu0", w=100,h=40, x=900,y=500, bgc=0xffff00,indc=0xff0000,lc=0x000000,la=0.3,lw=5, r=270,max=100})

--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,y=tly,c=dunkel,txt=tagkurz..','})
xout({x=tlx+70,y=tly,c=dunkel,txt=datum,j='r'})

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

xout({x=tlx+70,y=tly+20,c=dunkel,txt=high_temp[i].."°C",j='r'})
xout({x=tlx+70,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 ##################
--#######################################################################



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

the name of this template should be template_test.lua

/home/yourname/v9000/template_test.lua

then u need your conky-config:

# — Conky settings — #
background yes
update_interval 1

cpu_avg_samples 2
net_avg_samples 2

override_utf8_locale yes

# in config part, but then, all values will be in bytes, not only 'memmax'
#format_human_readable = no

double_buffer yes
no_buffers yes

text_buffer_size 1440
imlib_cache_size 0

# — Window specifications — #

own_window yes
own_window_type desktop
own_window_transparent no
own_window_colour blue
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below

border_inner_margin 0
border_outer_margin 0

minimum_size 960 580
maximum_width 1000

alignment tl
gap_x 15
gap_y 10

#default_color a3a23f

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

TEXT

create the config-file and place it here:

/home/yourname/v9000/conky-test

run from the terminal:

conky -c /home/yourname/v9000/conky-test

this should work. it should look like this: http://i.imgbox.com/acbcuuzZ.png

if it don't work then post the error-code.

with my additional code you can even display your conky-output. in my opinion it looks better then before wink

this are the additional features: http://i.imgbox.com/abl1WmuM.png

Last edited by lionhead (2013-07-05 09:41:34)

Offline

#894 2013-07-05 12:12:18

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!

@ McLovin

I'm running mrpeachy's script. It runs just fine.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#895 2013-07-05 22:14:41

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

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

ok, so I ran the conky setp from a terminal, and I got this output
http://pastebin.com/RDr34zKs
this is my v9000.lua file

-- weather v9000 by mrpeachy 01/10/12; released: Feb 29, 2012
-- official update by mrpeachy
-- additional features by lionhead, arclance and dk75
-- optimize lua: http://lua-users.org/wiki/OptimizedStrRep
-- last update 01.07.2013

require 'cairo'
require 'imlib2'

-- #####################################################################
-- ## settings #########################################################
-- #####################################################################

--you can enter your username here in case of errors, 
--enter username in quotes like this username = "yourname"

local username = os.getenv("USERNAME")
local username = "mclovin"

local t1="frei" -- when u use fs_free or fs_free_perc
local t2="belegt" -- when u use fs_size
local t3="nicht verfügbar" -- display text when hardrive/usb-stick is unmounted
local t4="n/a" -- display text when internet connection is not avaiable
local t5="gesamt" -- when u use fs_used or fs_used_perc
local t6="verbleibend" -- remaining

local e1="byte" -- B
local e2="kb" -- KiB
local e3="mb"  -- MiB
local e4="gb" -- GiB
local e5="tb" -- TiB
local e6="%"
local e7="mhz" -- cpu frequenz #1
local e8="ghz" -- cpu frequenz #2
local e9="mb/s" -- bitrate
local e10="kb/s" -- downspeedf
local e11="uhr" -- time 24h-format


package.path = '/home/'..username..'/.v9000_config.lua'
require '.v9000_config'

-- #####################################################################
-- ## end of settings ##################################################
-- #####################################################################

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

if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
--###UNCOMMENT THE BELOW LINE TO ENABLE CPU DELAY##########################################################
--if updates>5 then--###### YOU WILL ALSO HAVE TO UNCOMMENT THE MATCHING end ON LINE 923 ####################
--#########################################################################################################
local testing=0--this setting is for script testing, if not in testing set to 0
--#########################################################################################################
--############start of timed section#######################################################################
--#########################################################################################################
local timer=(updates %tonumber(settings_table[1]))
if timer==0 or start==1 then--######
start=nil--#######################################
local web=settings_table[2]
local alert_check=settings_table[13]

f=io.popen("curl --max-time 60 --compressed '"..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 --compressed 'http://www.intellicast.com"..alertsite.."' | sed 's/%//g'")

	alertdata=f:read("*a")
	f:close()
	alertdata=string.gsub(alertdata,"[\n\r]","")
	alerttest=string.find(alertdata,"%a")
	else
	print ("you have no weather alerts")
	alerttest=0
	end--if alert~=nil
else
print ("not checking for alerts")
alerttest=1
end--if testall and alert check
processall=1
end--of timed data gathering section

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

	else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort

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

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

function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end--string split


function xout(txj)
c=nil
a=nil
f=nil
fs=nil
x=nil
y=nil
txt=nil
j=nil

c=(txj.c or default_color)
a=(txj.a or default_alpha)
f=(txj.f or default_font)
fs=(txj.fs or default_font_size)
x=(txj.x or 0)
y=(txj.y or 0)
txt=(txj.txt or "set txt")
j=(txj.j or "l")

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

-- all following functions are working stand-alone
-- they can be copied because they do not have any dependance to work

function out(txj) -- function to output text
	local extents=cairo_text_extents_t:create()
	tolua.takeownership(extents)
	local blurred=nil
	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 face=txj.face					or default_face			or "normal"
	local size=txj.size     			or default_size         or "normal_c"
	--------------------------------------------------------------------
	local hj=txj.hj						or default_hj			or "l"
	--------------------------------------------------------------------
	local shaded=txj.shaded				or default_shaded		or "no"
	local shade_color=txj.shade_color	or default_shade_color	or 0x000000
	local shade_alpha=txj.shade_alpha	or default_shade_alpha	or 1
	--------------------------------------------------------------------
	local underline=txj.underline     	or default_underline    or "no"
	local line_color=txj.line_color    	or   default_line_color or   c
	local line_space=txj.line_space    	or default_line_space   or  5
	local line_width=txj.line_width     or default_line_width   or  1
	--------------------------------------------------------------------
	local number=txj.number  or 8
	local radius=txj.radius or 1.75
	local blurred=txj.blurred or no
	local blurred_color=txj.blurred_color or c
	local blurred_alpha=txj.blurred_alpha or 1
	--------------------------------------------------------------------
	local border=txj.border
	local bc=txj.bc or 0x000000
	local ba=txj.ba or 1
	local bw=txj.bw or 1
	--------------------------------------------------------------------
	cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	----------------------
	if size=="big_c" then
	txt=string.upper(txt)
	elseif size=="small_c" then
	txt=string.lower(txt)
	elseif size=="normal_c" then
	txt=txt
	end
	----------------------
	cairo_set_font_size (cr, fs)
	cairo_text_extents(cr,txt,extents)
	local wx=extents.x_advance -- measure spaces too
	local wd=extents.width
	local hy=extents.height
	local bx=extents.x_bearing
	local by=extents.y_bearing+hy
	local tx=x
	local ty=y
	--set horizontal alignment
	if hj=="l" then
		x=x-bx
	elseif hj=="c" then
		x=x-((wx-bx)/2)-bx
	elseif hj=="r" then
		x=x-wx
	end
	if shaded == "yes" then
		cairo_move_to (cr,(x + 1),(y + 1))
		cairo_set_source_rgba (cr,col(shade_color,shade_alpha))
		cairo_show_text (cr,txt)
		cairo_stroke (cr)
	end -- if
	-------------------------------------------------
	cairo_move_to (cr,x,y)
	cairo_set_source_rgba (cr,col(c,a))
	cairo_show_text (cr,txt)
	cairo_stroke (cr)
	--------------------------------------------------
	if border=="yes" then
    cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	cairo_set_font_size (cr, fs);
	cairo_move_to (cr, x, y);
	cairo_text_path (cr,txt);
	cairo_set_source_rgba (cr,col(c,a));
	cairo_fill_preserve (cr);
	cairo_set_source_rgba (cr,col(bc,ba));
	cairo_set_line_width (cr, bw);
	cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
	cairo_stroke (cr);
	end

	-- #################################################################
	-- ## decrease alpha if u want to use a small size #################
	-- ## for example fs=12,blurred="yes",ba=0.1 #######################
	-- #################################################################
	if blurred=="yes" then
	 radi,inum,horiz,verti=radius,number,x,y
	
	 for i=1,inum do
	 deg=360/inum
	 text_arc=((2*math.pi/inum)*i)
	 txs=0+radi*(math.sin(text_arc))
	 tys=0-radi*(math.cos(text_arc))
	 -------------------------------------------------------------------
	 cairo_select_font_face (cr, f, font_slant(face),font_weight(face));
	 -------------------------------------------------------------------
	 cairo_set_font_size (cr, fs);
	 cairo_set_source_rgba (cr, col(blurred_color,blurred_alpha));
	 cairo_move_to (cr, txs+horiz, tys+verti);
	 cairo_show_text (cr, txt)
     end
	 
	elseif blurred=="no" then
	 txt=txt
	end
	--------------------------------------------------
		if string.find(underline,"yes") ~= nil then

		cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE)
		----------------------------------------------
		startx=x
		endx=startx+wd
		starty=y+line_space
		endy=y+line_space
		-- draw line beyond text ---------------------
		cairo_set_line_width (cr,line_width)
		cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND)
		cairo_set_source_rgba (cr,col(line_color,a))
		cairo_move_to (cr,x,starty)
		cairo_line_to (cr,x+wd,endy)
		cairo_stroke (cr)
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT) --# reset antialiasing
		elseif string.find(underline,"no") ~= nil then
		txt=txt
		end
	--------------------------------------------------------

end--of function out 

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

function font_weight(value)
	fw=nil
	
 	if string.find(value,"normal") ~= nil then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif value=="bold" then
	fw=CAIRO_FONT_WEIGHT_BOLD
	elseif value=="italic" then
	fw=CAIRO_FONT_WEIGHT_NORMAL
    elseif value =="bolditalic" then
    fw=CAIRO_FONT_WEIGHT_BOLD
	elseif string.find(value,"oblique") ~= nil then 
    fw=CAIRO_FONT_WEIGHT_NORMAL
	end
	    
	return fw
end



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

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

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


function m2n(mn)

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


-- #####################################################################
-- ## display external and local images ################################
-- #####################################################################

function image(im) -- display local images
	local x,y,w,h = nil,nil,nil,nil
	local file = nil
	
	x =im.x or 0
	y =im.y or 0
	w =im.w or default_image_width -- default width is defined within the template
	h =im.h or default_image_height -- default height is defined within the template

	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 --# if show == nil then 
	imlib_context_set_image(show)
	local WIDTH = nil
	if tonumber(w) == 0 then 
		WIDTH = imlib_image_get_width() 
	else
		WIDTH = tonumber(w)
	end -- if
	local HEIGHT = nil
	if tonumber(h) == 0 then HEIGHT = imlib_image_get_height() else HEIGHT = tonumber(h) end --# if tonumber(h) == 0 then 
	local scaled = imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), WIDTH, HEIGHT)
	imlib_free_image_and_decache()
	imlib_context_set_image(scaled)
	imlib_render_image_on_drawable(x, y)
	imlib_free_image_and_decache()
	show = nil
	WIDTH = nil
	HEIGHT = nil
	x = nil
	y = nil
	w = nil
	h = nil
	file = nil
	scaled = nil
end --# function

function extern(wb)

	local s,j=nil,nil
	local imgw,imgh=nil,nil
	local img_w,img_h=nil,nil
	local imgwidth,imgheight=nil,nil
	local img_nw,img_x,imgy=nil,nil,nil
	--------------------------------------------------------------------
	img_x=wb.posx or 0
	img_y=wb.posy or 0
	img_w,imgh=wb.imgw,wb.imgh
	j=wb.j or "l"
	scaled=wb.scaled or "no"
	scale_size=wb.scale_size or 200
	
	img_nw=wb.imghdd or "external_img.jpg"
	s=wb.imgurl
	img_file='/home/'..username.."/"..img_nw
	img_intervall=wb.imgiv or 60
	
	local updates = tonumber(conky_parse('${updates}'))
	if (math.mod(updates, img_intervall) == 0) then
		os.execute("wget  -q -O "..img_file..' "'..s..'"')
	end

	if img_file==nil then print("set image file") end
	--------------------------------------------------------------------
	if scaled=="yes" then
		local show = imlib_load_image(img_file)
		if show == nil then return 	end
		imlib_context_set_image(show)
		imgwidth= imlib_image_get_width()
		imgheight=imlib_image_get_height()
		imgw=scale_size
		imgh=(imgw*imgheight)/imgwidth
		imlib_free_image_and_decache() -- remove from cache
	else
		imgw=img_w
		imgh=img_h
	end
	-- set alignment (sometimes very useful) ---------------------------
	if j=="l" then
	 img_x=img_x
	elseif j=="r" then
	 img_x=img_x-imgw
	end
	--------------------------------------------------------------------
	image({x=img_x,y=img_y,w=imgw,h=imgh,file=img_file}) -- load image
	
end--of function


-- #####################################################################
-- ## functions to modify conky-output #################################
-- #####################################################################

function os_capture(cmd, raw) -- parse shell in lua
	local f = assert(io.popen(cmd, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	if raw then return s end
	s = string.gsub(s, '^%s+', '')
	s = string.gsub(s, '%s+$', '')
	s = string.gsub(s, '[\n\r]+', ' ')
	return s
end



function parseValue(value,value1,value2,del,ending) -- remove ending and add custom ending
	jn=value:gsub(value1,"") 
	if ending=="no" then mv=chgFormat(jn,del) else mv=chgFormat(jn,del)..' '..value2 end
return mv
end



function nounit(device,var,ending,value)
	if var=="no" then ms=value else ms=value.." "..ending end
	return ms
end

function snu(ending,ct,cn)
		if ending=="yes" then mv=cn.." "..ct else mv=cn end
		return mv
end

function dropSign(dev,sign)
ms=conky_parse("${if_mounted "..dev.."}"..sign.."${else}".."".."${endif}")
return ms
end


function chgFormat(number,del) --replace decimal point with ,

point=string.find(number,"%p")
if point~=nil then
n1=string.sub(number,1,point-1)
n2=string.sub(number,point,string.len(number))
n2=string.gsub(n2,"^.",",")

	if string.len(n2)==2 then
	n2=n2..""
	elseif string.len(n2)>3 then
	n2=string.sub(n2,1,3)	
	end
else
n1=number
n2=del.."0"
end

--put in divisions
n1len=string.len(n1)
divs=math.floor((n1len-1)/3)
if n1len>3 then
	for i=1,divs do
	n=n1len-(i*3)
	bit1=string.sub(n1,1,n)
	bit2=string.sub(n1,n+1)
	n1=bit1.."."..bit2
	end
end
output=n1..n2

return output
end


function ram(dev,value,del,se,e)

re=string.gsub(tostring(value), "(%d*\.*%d+).*", "%1") -- remove ending
ln=string.len(re)
ln=tonumber(ln)
d=del

local st1,st2,stg=nil,nil,nil

if del=="," then t="." else t="," end

if ln == 4 then
st1=string.sub(re,1,1)
st2=string.sub(re,2,ln)
v=st1..t..st2
stg=nounit(dev,se,e3,v)
elseif ln == 5 then
st1=string.sub(re,1,2)
st2=string.sub(re,3,ln)
v=st1..t..st2
stg=nounit(dev,se,e3,v)
else
stg=re.." mb"
end

return stg
end


function chgDel(value,del)

local ausgang=nil
local ersteZahl=nil
local rest=nil
local outputNumber=nil

ausgang=string.gsub(value, "(%d*\.*%d+).*", "%1") -- remove ending
ausgang=tonumber(ausgang)

if not ausgang then ausgang=0; end

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

return outputNumber

end -- of function


function add_decimal(input,sign)  -- add decimal place, i.e. 5,0
if string.find(input,"%a")==nil then -- look for string
        if string.find(input,"%p")==nil then         -- only add decimal place when value is a number
        input=input..sign..'0'
        end
end
return input
end

function parse(value,delimiter,ending)

	local ms=nil
	value = value:gsub(" ","")
	if value==nil then value=0 end
	
	---- short_units no ------------------------------------------------
	if ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=parseValue(value,"B",e1,delimiter,ending)
	elseif string.find(value, 'KiB') ~= nil then
		ms=parseValue(value,"KiB",e2,delimiter,ending)
	elseif string.find(value, 'MiB') ~= nil then
		ms=parseValue(value,"MiB",e3,delimiter,ending)
	elseif string.find(value, 'GiB') ~= nil then
		ms=parseValue(value,"GiB",e4,delimiter,ending)
	elseif string.find(value, "TiB") ~= nil then
		ms=parseValue(value,"TiB",e5,delimiter,ending)
	---- short_units yes -----------------------------------------------
	elseif ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=parseValue(value,"B",e1,delimiter,ending)
	elseif string.find(value, "K") ~= nil then
		ms=parseValue(value,"K",e2,delimiter,ending)
	elseif string.find(value, "M") ~= nil then
		ms=parseValue(value,"M",e3,delimiter,ending)
	elseif string.find(value, "G") ~= nil then
		ms=parseValue(value,"G",e4,delimiter,ending)
	elseif string.find(value, "T") ~= nil then
		ms=parseValue(value,"T",e5,delimiter,ending)
	else
		ms=value:gsub(" ","") -- remove space
	end

	return ms
end -- of function

function notxt(txt,text)
 if txt=="yes" then nt=text else nt="" end
return nt
end

function nomt(txt,text)
if txt=="yes" then mv=text else mv="" end
return mv
end

function display_text_fs(dev,val,text,ch)
          if ch=="no" then
           ms=conky_parse("${if_mounted "..dev.."}"..val.."${else}"..nomt(st,t3).."${endif}")
          elseif ch=="yes" then
           ms=conky_parse("${if_mounted "..dev.."}"..val.." "..text.."${else}"..nomt(st,t3).."${endif}")
          end
      
return ms
end

function display_text_perc(status1,status2,ending,name,value)
 if status1=="no" then
 ms=nounit(dev,status2,ending,value)
 elseif status1=="yes" then
 ms=nounit(dev,status2,ending,value).." "..name
 end  
          
return ms
end

function display_text_fs_perc(status1,status2,status3,ending,name,value,dev)
 if status1=="no" then
 ms=conky_parse("${if_mounted "..dev.."}"..nounit(dev,status2,ending,value).."${else}"..nomt(status3,t3).."${endif}")
 elseif status1=="yes" then
 ms=conky_parse("${if_mounted "..dev.."}"..nounit(dev,status2,ending,value).." "..name.."${else}"..nomt(status3,t3).."${endif}")
 end  
          
return ms
end

function system(cd)
--[[
variable -> argument for example fs_free
device --> system-device for example wlan0
del --> delimiter of number
tf --> format of shown time for example 13:15 uhr or 1:15 pm
se --> show ending for example 1.000 instead of 1.000 mb
dt --> show current date
st --> display extra-text for example unmounted yes or no
txt --> show word for example 10 mb frei

you can call the function like this (example):
system({variable="totaldown",device="wlan0",txt='yes',st='yes',del=',',se="no"})
]]--

local t,x,ms=nil,nil,nil

local variable,device=cd.variable,cd.device or ''
local del=cd.del or '.'
local tf=cd.tf or '24'
local se=cd.se or "yes"
local txt=cd.txt or "yes"
local dt=cd.dt or "no" -- display date
local st=cd.st or "yes"

------------------------------------------------------------------------
if conky_window == nil then return end
------------------------------------------------------------------------

local rawdata=conky_parse("${"..variable..' '..device.."}")
local adv=parse(rawdata,del,se)

	if string.find(variable,"cpu") ~= nil then
		ms=display_text_perc(txt,se,e6,t2,rawdata,device)
	elseif string.find(variable,"uptime") ~= nil or string.find(variable,"user_number") ~= nil then
		ms=rawdata
	elseif ((string.find(variable, "perc") ~= nil) or (string.find(variable, "percent") ~= nil)) then
	--------------------------------------------------------------------	
		if string.find(variable, "fs_free_perc") ~= nil then
		ms=display_text_fs_perc(txt,se,st,e6,t1,rawdata,device)
		elseif string.find(variable, "fs_used_perc") ~= nil then
		ms=display_text_fs_perc(txt,se,st,e6,t2,rawdata,device)		
		elseif string.find(variable, "memperc") ~= nil then
		ms=display_text_perc(txt,se,e6,t2,rawdata,device)
		elseif string.find(variable, "swapperc") ~= nil then
		ms=display_text_perc(txt,se,e6,t2,rawdata,device)
		elseif string.find(variable, "battery_percent") ~= nil then
		ms=display_text_perc(txt,se,e6,t6,rawdata,device)		 
		else ms=nounit(device,se,e6,rawdata) end
	--------------------------------------------------------------------
	elseif string.find(variable,"freq") ~= nil and string.find(variable,"_g") == nil then
		jn=chgDel(adv,del)
		ms=nounit(device,se,e7,jn)
	elseif string.find(variable,"freq") ~= nil and string.find(variable,"_g") ~= nil then
		jn=chgFormat(adv,del)
		ms=nounit(device,se,e8,add_decimal(jn,del))
	--------------------------------------------------------------------
	elseif string.find(variable,"swapfree") ~= nil then
		ms=snu(txt,t1,adv)
	elseif string.find(variable, "swapmax") ~= nil then
	    ms=snu(txt,t5,adv)
	elseif string.find(variable, "memmax") ~= nil then
		ms=ram(device,rawdata,del,se,e3)
		
		
	--------------------------------------------------------------------
	elseif string.find(variable,"memfree") ~= nil or string.find(variable,"memeasyfree") ~= nil then
		ms=snu(txt,t1,adv)
	--------------------------------------------------------------------
	elseif string.find(variable,"wireless_bitrate") ~= nil then
		t=rawdata:gsub("Mb/s","")
		t=chgDel(t,del)
		t=add_decimal(t,del)
		t=t:gsub(" ","")
		ms=conky_parse("${if_up "..device.."}"..nounit(device,se,e9,t).."${else}"..t4.."${endif}")
	elseif string.find(variable,"wireless_essid") ~= nil or string.find(variable,"wireless_mode") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..rawdata.."${else}"..t4.."${endif}")
	elseif string.find(variable,"wireless_link_qual") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..nounit(device,se,e6,adv).."${else}"..t4.."${endif}")
	elseif string.find(variable,"upspeedf") ~= nil or string.find(variable,"downspeedf") ~= nil then
		jn=chgFormat(adv,del)
		ms=conky_parse("${if_up "..device.."}"..nounit(device,se,e10,add_decimal(jn,del)).."${else}"..t4.."${endif}")
	elseif string.find(variable,"battery") ~= nil or string.find(variable,"loadavg") ~= nil then
		ms=rawdata
------------------------------------------------------------------------
    elseif variable=="fs_free" and device=="/" then
     ms=display_text_fs(device,adv,t1,txt)
    elseif variable=="fs_used" and device=="/" then
     ms=display_text_fs(device,adv,t2,txt)
    elseif variable=="fs_size" and device=="/" then
     ms=display_text_fs(device,adv,t5,txt)
------------------------------------------------------------------------
    elseif string.find(variable,"fs_free") ~= nil and string.find(device,"/home") ~= nil then
     ms=display_text_fs(device,adv,t1,txt)
    elseif string.find(variable,"fs_used") ~= nil and string.find(device,"/home") ~= nil then
     ms=display_text_fs(device,adv,t2,txt)
    elseif string.find(variable,"fs_size") ~= nil and string.find(device,"/home") ~= nil then
     ms=display_text_fs(device,adv,t5,txt)
	--------------------------------------------------------------------
	elseif string.find(variable,"up") == nil and string.find(variable,"time") ~= nil then

if dt=="yes" then
ms=nounit(device,se,"",adv)
ms=ms:gsub(" ","")
else  ------------------------------------------------------------------
 if tf == "24" then ms=nounit(device,se,e11,adv) elseif tf == "12" then ms=convert12(rawdata) end 
end --------------------------------------------------------------------

--[[
time/date: http://search.cpan.org/~gbarr/TimeDate-2.30/lib/Date/Format.pm

%B name of the month
%m month number, for example 05
%y year short number, for example 13
%Y year long number, for example 2013
%d day number
]]--

	else
	--------------------------------------------------------------------
		if string.find(device,"wlan") ~= nil or string.find(device,"eth") ~= nil then
		ms=conky_parse("${if_up "..device.."}"..adv.."${else}"..t4.."${endif}")
		elseif string.find(device,"media") ~= nil then
		  --------------------------------------------------------------
          if txt=="no" and string.find(variable,"free") ~= nil then
           ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}"..nomt(st,t3).."${endif}")
          elseif txt=="yes" and string.find(variable,"free") ~= nil then
           ms=conky_parse("${if_mounted "..device.."}"..adv.." "..t1.."${else}"..nomt(st,t3).."${endif}")

		  elseif txt=="no" and string.find(variable,"used") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}"..nomt(st,t3).."${endif}")
		  elseif txt=="yes" and string.find(variable,"used") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.." "..t2.."${else}"..nomt(st,t3).."${endif}")
		   
		  elseif txt=="no" and string.find(variable,"size") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.."${else}"..t3.."${endif}")
		  elseif txt=="yes" and string.find(variable,"size") ~= nil then
		   ms=conky_parse("${if_mounted "..device.."}"..adv.." "..t5.."${else}"..nomt(st,t3).."${endif}")
		   
		  end
		  --------------------------------------------------------------
		else ms=adv  end 
	--------------------------------------------------------------------
	end

	return ms

--	end -- of updates

end -- of function

--[[
if os_capture("ip -o address |mawk '!/ lo / {print \"inet\"}'") == "inet" then print("connected") else print("disconnected") end
]]--

function dropZero(wert) -- drop leading charcacter

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

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

return ausgabe

end -- of function


function draw_bar(db) -- draw simple bar
------------------------------------------------------------------------
local var,dev=nil,nil
local width,height=nil,nil
local across,down=nil,nil
local bgc,bga=nil,nil
local inc,ina=nil,nil
local lc,la=nil,nil
local lw,rotate,justify=nil,nil,nil
------------------------------------------------------------------------

m=db.max or 100
dev=db.dev or ""
width,height,lw=db.w,db.h,db.lw
across,down,var=db.x,db.y,db.var
bgc,inc,lc=db.bgc,db.indc,db.lc
------------------------------------------------------------------------
bga=db.bga or 1
ina=db.inda or 1
la=db.la or 1
------------------------------------------------------------------------
rotate=db.r or 0
justify=db.j or "l"
------------------------------------------------------------------------
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
------------------------------------------------------------------------
if updates>5 then -- starts the display

--indicator calculation
if not dev then dev=''; end

conum=conky_parse("${"..var..' '..dev.."}")
conum=tonumber(conum)

local inum=(((width-lw)/100)*(conum or 0))
local x =  100 * inum / m

-- justify bar
if justify=="r" then across=across-width elseif justify=="l" then across=across end

-- background bar ------------------------------------------------------
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, col(bgc, bga));
cairo_rectangle (cr, 0, 0, (width-lw), (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
--indicator bar --------------------------------------------------------
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_source_rgba (cr, col(inc,ina));
cairo_rectangle (cr, 0, 0, x, (height-lw))
cairo_fill (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
--boundary line --------------------------------------------------------
cairo_translate (cr, (across+(lw/2)), (down+(lw/2))) 
cairo_rotate (cr, rotate*math.pi/180)
cairo_set_line_width (cr, lw);
cairo_set_source_rgba (cr, col(lc,la));
cairo_rectangle (cr, -lw/2, -lw/2, width, height)
cairo_stroke (cr)
cairo_rotate (cr, (rotate*-1)*math.pi/180)
cairo_translate (cr, -1*(across+(lw/2)), -1*(down+(lw/2))) 
	end
end

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

function convert12(value,format) 

local stunden,minuten=nil,nil
local zeit,sekunden=nil,nil

local stunden=string.sub(value,1,2) 	-- hours
local stunden=tonumber(stunden) 		-- convert hours into numbers
local minuten=string.sub(value,4,5)	 	-- minutes
local sekunden=string.sub(value,7,8) 	-- seconds

-- still calculate if string doesn't exists
if not stunden then stunden=0; end

if stunden > 12 and stunden < 24 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' pm'
	else zeit=(stunden-12)..':'..minuten..' pm' end
elseif stunden < 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' am'
	else zeit=stunden..':'..minuten..' am' end
elseif stunden == 12 then
	if sekunden ~= '' then
	zeit=stunden..':'..minuten..':'..sekunden..' pm'
	else zeit=stunden..':'..minuten..' pm' end
elseif stunden == 24 or stunden == 0 then
	if sekunden ~= '' then
	zeit=(stunden-12)..':'..minuten..':'..sekunden..' am'
	else zeit=(stunden-12)..':'..minuten..' am' end
end

return zeit

end -- of function




function n2w(number) -- umwandeln von zahlen in wörter

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

function international(lang,geschnitten,wort)
local nummer,kurzezahl=nil,nil
local anzahl=tonumber(lang)
local kurzezahl=tonumber(geschnitten)

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 funktion


-- #####################################################################
-- ## end of functions to modify conky-output ##########################
-- #####################################################################


-- #####################################################################
-- ## gimmicks #########################################################
-- #####################################################################

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


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


function conky_battbar() -- display graphical battery bar

if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
------------------------------------------------------------------------

cairo_set_line_width (cr, 20); --set line thickness
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
cairo_rotate (cr, 50)

x_position,y_position=45,530
length=80 --set total length of line

cairo_set_source_rgba (cr,1,1,1,0.5) --set color and alpha for background
cairo_move_to (cr,x_position,y_position)--reference positions set above
cairo_rel_line_to (cr,length,0)--reference length set above
--cairo_rotate (cr, 50)
cairo_stroke (cr)-- draws the line

--draw indicator line, draw after background so it draws ontop
battperc=tonumber(conky_parse("${battery_percent BAT1}"))--tonumber makes sure battvalue is a number
battvalue=(length/100)*battperc
cairo_set_source_rgba (cr,1,1,0,0.8)
cairo_move_to (cr,x_position,y_position)--reference positions set above
cairo_rel_line_to (cr,battvalue,0)--reference battvalue calculated above
--cairo_rotate (cr, 50)
cairo_stroke (cr)-- draws the line
------------------------------------------------------------------------
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

-- #####################################################################
-- ## end of script ####################################################
-- #####################################################################

this is my .v9000_config.lua file

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

this is one of the template files I'm trying to use

--[[
 The latest script is a lua only weather script. aka: v9000
 http://crunchbang.org/forums/viewtopic.php?id=16100

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

 mrppeachys LUA Tutorial
 http://crunchbang.org/forums/viewtopic.php?id=17246
 This config originally made by Sector11, and then edited by myself (McLovin) on 3/1/2013
]]
_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="AR Techni"--font must be in quotes
default_font_size=12
default_color=0xffffff	--white
default_alpha=1		--fully opaque
default_image_width=50
default_image_height=50
-- ## New Options ###
default_face="normal"
-- "normal" for normal/normal
-- "bold" for normal/bold
-- "italic" for italic/normal
-- "bolditalic" for italic/bold
--END OF DEFAULTS #######################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE

-- =============================================================================
-- Moon Phase -----------------------------------------------
     image({x=270,y=348,w=60,h=60,file=moon_icon[1]})
   out({c=0xFAFAEC,fs=15,a=1,f="Bahamas",fs=14,x=185,y=370,txt="Moon Phase:"})
   out({c=0x48D1CC,fs=14,a=1,f="Bahamas",fs=14,x=170,y=385,txt=moon_phase[1]})
   image({x=110,y=380,w=140,h=140,file=weather_icon[1]})
   out({c=0x48D1CC,a=1,f="Bahamas",fs=20,x=95,y=530,txt=now["conditions"]})
   out({c=0xFAFAEC,a=1,f="Bahamas",fs=18,x=100,y=555,txt="Feels Like:"})
   out({c=0x48D1CC,a=1,f="AR Techni",fs=18,x=185,y=555,txt=now["feels_like"].."°"})
-- Sun & Moon Rise -------------------------------------------------------------
   out({c=0xFAFAEC,a=1,f="Bahamas",fs=12,x=10,y=350,txt="Sunrise"})
     out({c=0xFAFAEC,a=1,f="Bahamas",fs=12,x=65,y=350,txt=sun_rise[1]})
   out({c=0xC0C0C0,a=1,f="Bahamas",fs=12,x=245,y=350,txt="Moonrise"})
      out({c=0xC0C0C0,a=1,f="Bahamas",fs=12,x=310,y=350,txt=moon_rise[1]})
-- Sun & Moon Set --------------------------------------------------------------
      image({x=15,y=345,w=70,h=70,file='/home/mclovin/v9000/additional_files/weathericons/32.png'})
   out({c=0xFAFAEC,a=1,f="Bahamas",fs=12,x=10,y=415,txt="Sunset"})
      out({c=0xFAFAEC,a=1,f="Bahamas",fs=12,x=65,y=415,txt=sun_set[1]})
   out({c=0xC0C0C0,a=1,f="Bahamas",fs=12,x=245,y=415,txt="Moonset"})
     out({c=0xC0C0C0,a=1,f="Bahamas",fs=12,x=310,y=415,txt=moon_set[1]})
-- Forecast for Today -------------------------------------------------
   out({c=0xFAFAEC,f="Bahamas",fs=20,a=1,x=5,y=440,txt="Temps:"})
   out({c=0xFAFAEC,f="Bahamas",fs=18,a=1,x=0,y=465,txt="Hi:"})
   out({c=0xFF4800,f="AR Techni",fs=18,a=1,x=25,y=465,txt=high_temp[1].."°"})
   out({c=0xFAFAEC,f="Bahamas",fs=18,a=1,x=0,y=485,txt="Low:"})
   out({c=0x00BFFF,f="AR Techni",fs=18,a=1,x=40,y=485,txt=low_temp[1].."°"})
   out({c=0xFAFAEC,f="Bahamas",fs=18,a=1,x=0,y=505,txt="Current:"})
   out({c=0x48D1CC,f="AR Techni",fs=18,a=1,x=65,y=505,txt=now["temp"].."°"})
-- Wind Info ----------------------------------------------------------
   image({x=280,y=435,w=60,h=60,file=now["wind_icon"]})
   out({c=0x48D1CC,a=1,x=280,y=435,txt=now["wind_deg"]})
   out({c=0x48D1CC,a=1,f="Bahamas",fs=12,x=315,y=435,txt=now["wind_nesw"]})
   out({c=0xFAFAEC,a=1,x=285,y=505,txt="@ :"})
   out({c=0x48D1CC,a=1,x=315,y=505,txt=now["wind_mph"]})
   out({c=0xFAFAEC,a=1,x=270,y=525,txt="Gusts:"})
   out({c=0x48D1CC,a=1,x=315,y=525,txt=now["wind_gusts"]})
   out({c=0xFAFAEC,a=1,x=255,y=540,txt="Wind Chill:"})
   out({c=0x48D1CC,a=1,x=315,y=540,txt=now["wind_chill"].."°"})
-- Humidity --- left -----------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=005,y=525,txt="Hum:"})
      out({c=0x48D1CC,a=1,x=040,y=525,txt=now["humidity"].."%"})
-- Dew Point --- right ---------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=250,y=555,txt="Dew Point:"})
      out({c=0x48D1CC,a=1,x=315,y=555,txt=now["dew_point"].."°"})
-- Chance of Rain --- left -----------------------------------------------------
   out({c=0xFAFAEC,a=1,x=005,y=540,txt="Rain?:"})
      out({c=0x48D1CC,a=1,x=040,y=540,txt=precipitation[1].."%"})
      -- Ceiling --- right -----------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=245,y=570,txt="Ceiling:"})
      out({c=0x48D1CC,a=1,x=295,y=570,txt=now["ceiling"]})
-- Barometric Pressure --- left ------------------------------------------------
out({c=0xFAFAEC,a=1,x=005,y=555,txt="BP:"})
	out({c=0x48D1CC,a=1,x=030,y=555,txt=now["pressure"].." b"})
-- Cloud Cover --- right -------------------------------------------------------
   out({c=0xFAFAEC,a=1,x=230,y=585,txt="Cloud Cover:"})
      out({c=0x48D1CC,a=1,x=315,y=585,txt=cloud_cover[1].."%"})
-- something here --. left -----------------------------------------------------
   -- need something here
      -- need something here
-- UV --- left -----------------------------------------------------------------
out({c=0xFAFAEC,a=1,x=005,y=570,txt="UV:"})
   out({c=0x48D1CC,a=1,x=030,y=570,txt=uv_index_num[1]})
      out({c=0x48D1CC,a=1,x=050,y=570,txt=uv_index_txt[1]})
out({c=0xFAFAEC,a=1,x=005,y=585,txt="Heat Index:"})
out({c=0x48D1CC,a=1,x=65,y=585,txt=now["heat_index"].."°"})
out({c=0xFAFAEC,a=1,x=125,y=585,txt="Visibility:"})
out({c=0x48D1CC,a=1,x=175,y=585,txt=now["visibility"]})
-- =============================================================================
-- Forecast for NOW & the next 3 hours -----------------------------------------
      out({c=0xFAFAEC,fs=14,a=1,x=25,y=610,txt="Next 3 Hours"})

-- 1st hour
out({c=0x48D1CC,x=40,y=625,txt=now["fc_hour1_time"]..":00"})
out({c=0x48D1CC,x=70,y=625,txt=now["fc_hour1_ampm_lc"]})
   image({x=20,y=627,w=80,h=80,file=now["fc_hour1_wicon"]})
   out({c=0x00BFFF,fs=18,x=5,y=645,txt=now["fc_hour1_temp"] .."°"})
out({c=0x48D1CC,fs=15,x=15,y=715,txt=now["fc_hour1_cond"]})
-- 2nd hour
out({c=0x48D1CC,x=155,y=625,txt=now["fc_hour2_time"]..":00"})
out({c=0x48D1CC,x=185,y=625,txt=now["fc_hour2_ampm_lc"]})
   image({x=135,y=627,w=80,h=80,file=now["fc_hour2_wicon"]})
   out({c=0x00BFFF,fs=18,x=115,y=645,txt=now["fc_hour2_temp"] .."°"})
out({c=0x48D1CC,fs=15,x=125,y=715,txt=now["fc_hour2_cond"]})
-- 3rd hour
out({c=0x48D1CC,x=280,y=625,txt=now["fc_hour3_time"]..":00"})
out({c=0x48D1CC,x=310,y=625,txt=now["fc_hour3_ampm_lc"]})
   image({x=260,y=627,w=80,h=80,file=now["fc_hour3_wicon"]})
   out({c=0x00BFFF,fs=18,x=245,y=645,txt=now["fc_hour3_temp"] .."°"})
out({c=0x48D1CC,fs=15,x=255,y=715,txt=now["fc_hour3_cond"]})
-- line

-- =============================================================================
--ALERTS SECTION
--show alert icon
image({x=0,y=725,h=40,w=40,file=alert_icon})
--show number of alerts
--out({c=0x48D1CC,x=45,y=750,fs=20,txt=alert_number})
--display alert information
display_alerts=5--set number of alerts to show,set 0 to show all
top_left_alert_x=65--set top left coordinates for entire alerts section
top_left_alert_y=745--^alerts will display in a single column
alert_gap=40--sets the gap between the TOP of one alert and the Top of the next alert
--#######################################################################################################################################
if alert_number==0 then noal=1 elseif alert_number~=0 and display_alerts>alert_number then noal=alert_number else noal=display_alerts end
for i=1,noal do--start of alerts display section. do not edit ###########################################################################
local tlx=top_left_alert_x--write output relative to tlx #################################
local tly=top_left_alert_y+((i-1)*alert_gap)--write output relative to tlx ###############
--########################################################################################
out({c=0x00FF9E,a=1,fs=14,x=tlx,y=tly,   txt=alert_type[i]})
out({c=0xFF9FA0,a=1,fs=14,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 ##################
--#######################################################################

and this is the other one I'm trying to use

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

--sun_rise[n]
--sun_set[n]
--moon_rise[n]
--moon_set[n]
--now["time"]
--now["fc_hour1_time"]
--now["fc_hour2_time"]
--now["fc_hour3_time"]

]]
_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="AR Techni"--font must be in quotes
default_font_size=14
default_color=0xffffff	--white
default_alpha=1		--fully opaque
default_image_width=60
default_image_height=60
-- ## New Options ###
default_face="normal"
-- "normal" for normal/normal
-- "bold" for normal/bold
-- "italic" for italic/normal
-- "bolditalic" for italic/bold
--END OF DEFAULTS #######################################################
--[[ SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="AR Techni"--font must be in quotes
default_font_size=15
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
--start or weather forecast table section
--set start forecast day
start_day=2
--set total forecast days you want to display
number_of_days=10
topy=20
topyy=220 -- topy+(topyy*1)
topx=30
topxx=175
--set coordinates for top left 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            ,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]        =topx+(topxx*1)  ,topy
   top_left_x_coordinate[4],top_left_y_coordinate[4]     =topx+(topxx*2)  ,topy
top_left_x_coordinate[5],top_left_y_coordinate[5]        =topx+(topxx*3)  ,topy
   top_left_x_coordinate[6],top_left_y_coordinate[6]     =topx+(topxx*4)  ,topy
--########################################################################################
for i=start_day,number_of_days-(start_day-2) 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=0xF3F3F3,a=1,f="AR Techni",fs=20,x=tlx,y=tly-5,txt=forecast_day_short[i].."  "..forecast_date[i].."  "..forecast_month_short[i]})
image({x=tlx-2,y=tly-4,h=90,w=90,file=weather_icon[i]})
out({c=0xC94029,a=1,f="AR Techni",fs=25,x=tlx+105,y=tly+25,txt=high_temp[i].."°"})
out({c=0x40BFEA,a=1,f="AR Techni",fs=25,x=tlx+105,y=tly+50,txt=low_temp[i].."°"})
out({c=0xFFFFFF,a=1,x=tlx+10,y=tly+80,txt=conditions[i]})
out({c=0xCCCCCC,a=1,x=tlx,y=tly+95,txt="Chance of Rain:"})
out({c=0x00FFE5,a=1,x=tlx+100,y=tly+95,txt=precipitation[i].."%"})
out({c=0xCCCCCC,a=1,x=tlx,y=tly+110,txt="Humidity:"})
out({c=0xFFA263,a=1,x=tlx+100,y=tly+110,txt=humidity[i].."%"})
out({c=0xCCCCCC,a=1,x=tlx+0,y=tly+125,txt="UV Index:"})
out({c=0xFFC800,a=1,x=tlx+65,y=tly+125,txt=uv_index_num[i]})
out({c=0xFFA200,a=1,x=tlx+85,y=tly+125,txt=uv_index_txt[i]})
out({c=0xCCCCCC,a=1,x=tlx,y=tly+140,txt="SunRise:"})
out({c=0xFF9C00,a=1,x=tlx+85,y=tly+140,txt=sun_rise[i]})
out({c=0xCCCCCC,a=1,x=tlx,y=tly+155,txt="SunSet:"})
out({c=0x6254FF,a=1,x=tlx+85,y=tly+155,txt=sun_set[i]})
out({c=0xCCCCCC,a=1,x=tlx,y=tly+170,txt="Moon Phase:"})
out({c=0x1E90FF,a=1,x=tlx+10,y=tly+185,txt=moon_phase[i]})
image({x=tlx+5,y=tly+200,h=90,w=90,file=moon_icon[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 ##################
--#######################################################################

and these are the conky configs that call them

######################
# - Conky settings - #
######################
background yes
update_interval 1
cpu_avg_samples 2
total_run_times 0
 
double_buffer yes
no_buffers yes
 
text_buffer_size 10240
imlib_cache_size 10240

draw_shades no
draw_outline no
draw_borders no
stippled_borders 0
draw_graph_borders no

#####################
# - Text settings - #
#####################
override_utf8_locale yes
use_xft yes
xftfont AR Techni:size=10
xftalpha 1 
uppercase no

######################
# - Color settings - #
######################
color0 c3c3c3 #mid gray
color1 FF0000 #red
color2 09FF00 #bright green
color3 007EFF #bright blue
color4 E3E3E3 #very light gray
color5 FF8600 #an orange shade
color6 CA8718 #a dust like color
color7 FFE500 #a darker yellow color
color8 C3FF00 #lime green
color9 00FCFF #sky blue
default_color c3c3c3
default_shade_color gray
default_outline_color black
#############################
# - Window specifications - #
#############################
## - Alignment of conky, uncomment the location you wish to use - ##
#alignment middle_left
#alignment middle_middle
#alignment middle_right
#alignment top_middle
alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment bottom_middle

## - Size of conky - ##
minimum_size 350 1000    ##420 420     #### - Use size 420 if - ####
maximum_width 350     ##420         #### - you use a BG image - #

## - Gap from edge of screen - ##
gap_x 60
gap_y 60

## - Gap margins from edge of Conky - ##
border_inner_margin 0
border_outer_margin 0

###################################################################################################
# - Create own window instead of using desktop (required in all file-managers, other than caja) - #
###################################################################################################
#own_window yes
#own_window_type normal
#own_window_transparent yes
#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
#own_window_colour gray
#own_window_class Conky
#own_window_title Conky

#########################################################################################################
# - If using MATE Desktop and Caja file manager, uncomment the following and use it rather than above - #
#########################################################################################################
own_window yes
own_window_transparent yes
own_window_type override
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

####################
# - LUA Settings - #
####################
lua_load ~/conky-chrono-2/scripts/Chronograph.lua
lua_draw_hook_post main
lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
lua_load ~/conky-chrono-2/scripts/mclovin-forecast-1.lua
lua_load ~/conky-chrono-2/scripts/draw-bg.lua
TEXT
${lua conky_draw_bg 30 0 0 0 900 0x000000 0.3}${voffset 65}${goto 160}${font AR Techni:style=bold:size=16}${color 40BFEA}${time %b}
${goto 165}${font AR Techni:style=bold:size=16}${time %e}${color}
${voffset 140}${goto 150}${font AR Techni:style=bold:size=20}${if_match "${exec expr `date | cut -f3 -d":" | cut -f1 -d" "` % 2}"=="0"}${color 40BFEA}${time %I}${color 40BFEA}${goto 180}${time %M}${color 40BFEA}$else${color 40BFEA}${time %I:}${goto 180}${time %M}$endif
${voffset -8}${goto 160}${font AR Techni:style=bold:size=16}${color 40BFEA}${time %p}${color}

and this is for the 5-day one

######################
# - Conky settings - #
######################
background yes
update_interval 1
cpu_avg_samples 2
total_run_times 0
 
double_buffer yes
no_buffers yes
 
text_buffer_size 10240
#imlib_cache_size 0

draw_shades yes
draw_outline no
draw_borders no
stippled_borders 0
draw_graph_borders yes

#####################
# - Text settings - #
#####################
override_utf8_locale yes
use_xft yes
xftfont Antipasto:size=8
xftalpha 1 
uppercase no

######################
# - Color settings - #
######################
color0 c3c3c3 #mid gray
color1 FF0000 #red
color2 09FF00 #bright green
color3 007EFF #bright blue
color4 E3E3E3 #very light gray
color5 FF8600 #an orange shade
color6 CA8718 #a dust like color
color7 FFE500 #a darker yellow color
color8 C3FF00 #lime green
color9 00FCFF #sky blue
default_color c3c3c3
default_shade_color gray
default_outline_color black
#############################
# - Window specifications - #
#############################
## - Alignment of conky, uncomment the location you wish to use - ##
#alignment middle_left
#alignment middle_middle
#alignment middle_right
alignment top_middle
#alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment bottom_middle

## - Size of conky - ##
minimum_size 900 350
maximum_width 900

## - Gap from edge of screen - ##
gap_x 85
gap_y 60

## - Gap margins from edge of Conky - ##
border_inner_margin 0
border_outer_margin 0

###################################################################################################
# - Create own window instead of using desktop (required in all file-managers, other than caja) - #
###################################################################################################
#own_window yes
#own_window_type normal
#own_window_transparent yes
#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
#own_window_colour gray
#own_window_class Conky
#own_window_title Conky

#########################################################################################################
# - If using MATE Desktop and Caja file manager, uncomment the following and use it rather than above - #
#########################################################################################################
own_window yes
own_window_transparent yes
own_window_type override
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

####################
# - LUA Settings - #
####################
#lua_load ~/conky-chrono-2/scripts/draw-bg.lua  ###########################################################
#lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.3  #### - Uncoment these lines to have BG-Image -#
#lua_draw_hook_post draw-bg 125 0 0 0 0 0x000000 0.01  ############################################
lua_load ~/v9000/v9000.lua
lua_draw_hook_pre weather
lua_load ~/conky-chrono-2/scripts/v9000-5d-template.lua
lua_load ~/conky-chrono-2/scripts/draw-bg.lua
TEXT
${lua conky_draw_bg 15 0 0 0 0 0x000000 0.3}

anything anyone might be able to see here would be greatly appreciated


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

Offline

#896 2013-07-05 22:28:23

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

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

ok, I just tried with the one you said to try out lionhead, and this is what I got from that

┌─────⎧ mclovin♂  on  tweaked-b2 ⎫───────⎧ kernel: 3.9.0-mclovin ⎫
⎬─────⎨ tot system uptime 5 min,⎬───────⎩   load - average:2.54,⎭
⎬─────⎩ cur. working directory: ~/v9000-testing⎭$
└─> ./start
Conky: llua_load: /home/mclovin/v9000/v9000.lua:41: module '.v9000_config' not found:
	no field package.preload['.v9000_config']
	no file '/home/mclovin/.v9000_config.lua'
	no file '/usr/lib/conky/lib/v9000_config.so'
	no file './/v9000_config.so'
	no file '/usr/local/lib/lua/5.1//v9000_config.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1//v9000_config.so'
	no file '/usr/lib/lua/5.1//v9000_config.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/usr/lib/conky/lib.so'
	no file './.so'
	no file '/usr/local/lib/lua/5.1/.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1/.so'
	no file '/usr/lib/lua/5.1/.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
Conky: forked to background, pid is 6355
┌─────⎧ mclovin♂  on  tweaked-b2 ⎫───────⎧ kernel: 3.9.0-mclovin ⎫
⎬─────⎨ tot system uptime 5 min,⎬───────⎩   load - average:2.54,⎭
⎬─────⎩ cur. working directory: ~/v9000-testing⎭$
└─> 
Conky: desktop window (12000bc) is subwindow of root window (297)
Conky: window type - desktop
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
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

It looks like something is wrong with my lua installation ir something, though I'm not sure what


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

Offline

#897 2013-07-06 07:25:11

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

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

it seems that you have problems with your lua installation?! try to uninstall conky and reinstall conky smile

why don't you try a 'non v9000' lua script at first? then u can see if lua works smile

grab a script made by mrpeachy. grab it here: http://thepeachyblog.blogspot.de/p/inde … -page.html

Offline

#898 2013-07-07 02:14:59

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

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

I run multiple configs at once, with multiple lua scripts, and v9000 is the only one that's not working, all other scripts work perfectly.


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

Offline

#899 2013-07-07 06:06:25

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 starting to think it's something with intellicast, as it's recieving a "nill value" from them, is there another site that can be used with v9000?


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

Offline

Help fund CrunchBang, donate to the project!

#900 2013-07-07 08:47:22

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

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

intellicast worked good for me! and v9000 only uses this webpage.

but if u wanna try something else:

http://crunchbang.org/forums/viewtopic.php?id=19235&p=1


or try this: http://dl.dropbox.com/u/60081679/cyber- … ate.tar.gz

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

Debian Logo