You are not logged in.
sheesh... you would think dropbox has the ability to handle the degree symbol!!
those are all ° in the file on my computer
stoopid dropbox
Sure, blame it on dropbox! Never the programmers fault.
Last edited by ackernan (2012-01-08 21:06:02)
Offline
Here is the screenshot MrPeachy
The script has been running 5 hours and have had no errors in terminal.
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
sheesh... you would think dropbox has the ability to handle the degree symbol!!
those are all ° in the file on my computer
stoopid dropbox
Did they all land on the floor? How hard are they to sweep up?
Offline
sheesh... you would think dropbox has the ability to handle the degree symbol!!
those are all ° in the file on my computer
stoopid dropbox
Nooooooo weather.tar.gz the file!
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
@falldown - that is what i like to hear
@sector11 - that sounds like another good idea
but i still say dropbox dropped the ball!
here are the most current versions, i think ive fixed all the bugs ive come across and those which im able to anticipate as tar.gz (no more dropped ° )
regular
http://dl.dropbox.com/u/19008369/weathe … lua.tar.gz
circle
http://dl.dropbox.com/u/19008369/weathe … lua.tar.gz
@dodge ram
ive had real world stuff keeping me busy so far today
but i will get around to looking into the bugs you have
are you still using the setup sector11 posted earlier? or are you trying the lua only version (aka v9000 )
do you get errors in the terminal?
Offline
so i think ive made some good progress on getting the lua only version of weather working reliable
im pretty confident ive solved the curl crap out problem, each curl attempt gets 60 seconds to work, and if it doesnt it will keep retrying till it does
ive also identified a number of bugs (things that the intellicast site does that i hadnt anticipated)
and fixed them
so if there is any interest in using the script, ill write a tutorial on how to write the lua code to start making your own displays
Offline
Please do, Im very interested in it
Intel Pentium4-2.40GHZ RAM-1008.3MiB CrunchBang Sid Linux-3.2-6.slh.3-aptosid-686
Offline
=@dodge ram
ive had real world stuff keeping me busy so far today
but i will get around to looking into the bugs you have
are you still using the setup sector11 posted earlier? or are you trying the lua only version (aka v9000)
do you get errors in the terminal?
I am still hanging on to the one that Sector11 gave me. If I remember right I posted the code in a .tar. Post #153
Last edited by Dodge ram (2012-01-09 00:03:21)
Offline
so if there is any interest in using the script, ill write a tutorial on how to write the lua code to start making your own displays
+1 on that.
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
The screan shot of my terminal is in post 172. When I close the terminal the weather conky disappears and I get only the template. After @ 3 minutes the jumbled conky returns.
Offline
mrpeachy wrote:so if there is any interest in using the script, ill write a tutorial on how to write the lua code to start making your own displays
+1 on that.
+1
Offline
so if there is any interest in using the script, ill write a tutorial on how to write the lua code to start making your own displays
I admit to be as lost at Lua and welcome a howto. It is one thing to identify line 343 is the problem. It is another to code lines 344-475 to enhance the problem correction. I am still amazed you do all this on eee space restrictions!
Congratulations, you've figured out the sound of one hand clapping...
Offline
then i shall start typing ... well not right now, but expect the first instalment tomorrow (alog with a solution for dodge ram i hope)
just as a note, ive been running the current+8 day forecast display for 5 hours without incident and ive been recording conky memory usage (%) for that period (one reading per half hour)
0.6
0.6
0.8
0.8
0.8
0.8
0.8
0.8
0.8
0.8
0.8
so thats looking good
if anyone wants to look into theoir own conky memory usage im using this line in the conkyrc below text to do it
${execi 1800 top -b -n1 | grep 'conky' | awk '{print$10}' >>/home/benjamin/Desktop/memory.txt }
i have also had a number of curl crap outs, which the script has compensated for as i hoped
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
16 68241 16 11174 0 0 186 0 0:06:06 0:01:00 0:05:06 0
curl: (28) Operation timed out after 60000 milliseconds with 11174 out of 68241 bytes received
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
42 68241 42 28694 0 0 478 0 0:02:22 0:01:00 0:01:22 346
curl: (28) Operation timed out after 60001 milliseconds with 28694 out of 68241 bytes received
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 68241 100 68241 0 0 11769 0 0:00:05 0:00:05 --:--:-- 112k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
76 68241 76 52054 0 0 867 0 0:01:18 0:01:00 0:00:18 0
curl: (28) Operation timed out after 60000 milliseconds with 52054 out of 68241 bytes received
processing complete
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
4 68246 4 2920 0 0 48 0 0:23:41 0:01:00 0:22:41 0
curl: (28) Operation timed out after 60000 milliseconds with 2920 out of 68246 bytes received
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 68246 100 68246 0 0 98k 0 --:--:-- --:--:-- --:--:-- 134k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
3 68246 3 2276 0 0 37 0 0:30:44 0:01:00 0:29:44 0
curl: (28) Operation timed out after 60001 milliseconds with 2276 out of 68246 bytes received
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 68246 100 68246 0 0 4267 0 0:00:15 0:00:15 --:--:-- 5261
processing complete
so thats good to
Last edited by mrpeachy (2012-01-09 04:17:14)
Offline
just as a note, ive been running the current+8 day forecast display for 5 hours without incident and ive been recording conky memory usage (%) for that period (one reading per half hour)
0.6 0.6 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8
so thats looking good
if anyone wants to look into theoir own conky memory usage im using this line in the conkyrc below text to do it${execi 1800 top -b -n1 | grep 'conky' | awk '{print$10}' >>/home/benjamin/Desktop/memory.txt }
I'm using the above code with your weather lua script and another conky and I get 0.1 & 0.2, with an occasional 0.3. Is this good?
Offline
I'm using the above code with your weather lua script and another conky and I get 0.1 & 0.2, with an occasional 0.3. Is this good?
as long as it isnt increasing steadily with time its fine
one concern that has come up with using lua scripts is memory leaks, ie the lua script causes memory usage to increase over time... and if you have you computer running for days on end, can result in significant amounts of memory being used up just by conky and the lua scripts
i *think* im right in saying that the memory increase should be seen by recording conky memory use
if anyone knows differently let me know
Offline
@ dodge ram
ive been running the setup sector11 posted and so far i havnt had any problems
ive resaved the conkyrc and closed the terminal i started it with but it comes back the same
make sure the settings at the top of the lua script are good
--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP
secs=1800--set update interval
web="http://www.intellicast.com/Local/Forecast.aspx?&location=USOH1015"--insert unit=C& after? for C
--get web address by going to the intellicast site and entering your location in the box
--for version 3 you must get click on "Extended Forecast" to get the necessary address
units="F"
--set location where weather data txt will be saved
location="/home/benjamin/Desktop/weather.txt"
--set location of weather images
weathericons="/home/benjamin/Desktop/scripts/weathericons/"
in particular is location isnt set correctly then the script cant run after saving the conky or closing the terminal and you will get not weather data as i saw in your first post
as for the scrambled conky in your other post, im having trouble thinking wha might have caused that
ill keep an eye on it
Offline
So here goes with my tutorial - Lua weather tutorial for lua only weather script aka v9000
PART 1 - Editing settings. Set up conkyrc and available data option
open up readme file in the v9000 folder and follow the instructions for setup.
edit the hidden file .v9000_config.lua to enter your settings
some of the settings you will find
update_interval controls the weather data update interval, it is based on "conky cycles" and the update_interval that you set in your conkyrc
if your update interval in the conkyrc is 1, then conky runs onece per second
so if the update_interval in .v9000_config.lua is 1800 (as set by in the archive) the weather script will update every 1800 seconds (every half an hour)
but if your conkyrc is set to an update interval of 10 and update_interval in .v9000_config.lua remains at 1800 then the script wont update for 18000 seconds which is 5 hours!
location must be set to the intellicast location (obtained from website) for YOUR area
go to the intellicast site and entering your location in the box
the location is at the end of the web address. Like this, location is in bold:
http://www.intellicast.com/Local/Weather.aspx?location=USMO0787
weathericons is the location of the weather icons folder containing the images
if for any reason you move your weather cons folder then make sure this points to where you moved it
.v9000_config.lua has this line in it when you get the files
local weathericons="/home/benjamin/v9000/additional_files/weathericons/"
change "benjamin" to your username
also there is an alternative set of icons available, made by falldown.
to access the alternative icons change:
additional_files/weathericons/
to
additional_files/weathericons_falldown/
con_short table
this table is used when you want to set your own custom versions of the conditions types that intellicast uses
Using this table you could shorten some of the terms to make conditions better into some setups.
It can also be used to translate incoming weather types into other languages
other things to edit are "decimal_places", "units settings" and "translate"
These settings are commented in the config file and the "translate" option is discussed in its own section of this how-to
recent additions
"alert_check"
you can turn weather alert checking off or on
NEXT
set up your conkyrc to run the script
in addition to all your regular conky settings you need these
lua_load /path_to_he_main_script/v9000.lua
lua_draw_hook_pre conky_weather
lua_load ./path_to_the_display_script/weather_display.lua
## Blank line after TEXT
TEXT
NOTE
lua_load ./path_to_the_display_script/weather_display.lua
is the call to the weather template where the display is set up
there is an alternate template in the archive, created by Sector11, which gives you this display
you need a minimum 400 by 400 conky
to get this display change weather_display.lua to s11template.lua
SECTION 1 - DATA OPTIONS
first of all these are the available weather data
there are 2 sets of options, options for current conditions and options for forecast data
the current and forecast data are called in slightly different ways
GENERAL OPTIONS
weather_location --> can be used with the out() function to automate location
alert_icon --> used with the image() function to indicate if there are weather alerts
alert_number --> displays the number of alerts or 0 if none
weather alerts have their own options (where n is the number of the alert to show)
alert_type[n]
alert_issued[n]
NOTE as there is no way to know before, how many alerts you may or may not have,
displaying alerts should be done as described in section 10 of the how-to
CURRENT CONDITIONS DATA OPTIONS with example output
now["day"] --> Monday
now["day_caps"] --> MONDAY
now["day_lc"] --> monday
now["day_short"] --> Mon
now["day_short_caps"] --> MON
now["day_short_lc"] --> mon
now["month"] --> January
now["month_caps"] --> JANUARY
now["month_lc"] --> january
now["month_short"] --> Jan
now["month_short_caps"] --> JAN
now["month_short_lc"] --> jan
now["date"] --> 8 (number only)
now["year"] --> 2012 (4 digit)
now["time"] --> 7:45 PM (time weather was updated)
now["time_lc"] --> 7:45 pm
now["temp"] --> 35 (current temp number only)
now["feels_like"] -->35 (feels like temp number only)
now["conditions"] --> Mostly Cloudy
now["conditions_lc"] --> mostly cloudy
now["conditions_caps"] --> MOSTLY CLOUDY
now["conditions_short"] -->according to settings
now["conditions_short_caps"] --> according to settings
now["conditions_short_lc"] --> according to settings
now["weather_icon"] --> returns full path to weather weather icon, as set in settings at top
now["wind_chill"] --> 35 (temp number only)
now["heat_index"] --> 35 (temp number only)
now["dew_point"] --> 20 (temp number only)
now["humidity"] --> 63 (number only)
now["ceiling"] --> 7000 Ft (if a number) or Unl
now["ceiling_lc"] --> unl (if not a number) or 7000 ft
now["ceiling_caps"] --> UNL (if not a number) or 7000 FT
now["pressure"] --> 30.28 (number only)
now["visibility"] --> 10 mi
now["visibility_caps"] --> 10 MI
now["weather_font"] --> returns matching character for the weather font (ConkyWeather)
now["wind_deg"] --> 135 (degrees number only)
now["wind_nesw"] --> SE (uppercase letters only)
now["wind_font"] --> returns matching character for wind font (ConkyWindNESW)
now["time_num"] --> weather update time only
now["time_ampm"] --> weather update AM or PM
now["time_ampm_lc"] --> weather update am or pm
now["pressure_mb"] --> pressure in millibars/hectoPascals, number only
--NOW WIND OPTIONS-----------------------------------------------------
--miles per hour
now["wind_mph"] --> 5 mph
now["wind_mph_caps"] --> 5 MPH
now["wind_gusts"] --> 15 mph
now["wind_gusts_caps"] --> 15 MPH
--kilmometers per hour
now["wind_km"] --> number followed by wind_km_unit eg 5 kmh
now["wind_km_caps"] --> number followed by wind_km_unit eg 5 KMH
now["wind_gusts_km"] --> number followed by wind_km_unit eg 5 kmh
now["wind_gusts_km_caps"] --> number followed by wind_kn_unit eg 5 KMH
--knots
now["wind_kts"] --> number followed by wind_kts_unit eg 5 kts
now["wind_kts_caps"] --> number followed by wind_kts_unit eg 5 KTS
now["wind_gusts_kts"] --> number followed by wind_kts_unit eg 5 kts
now["wind_gusts_kts_caps"] --> number followed by wind_kts_unit eg 5 KTS
--icon
now["wind_icon"] --> used in conjunction with the image() function to display a color coded wind direction icon
--options for the next 3 hours forecast------------------------------------------------------------------------------
now["fc_hour1_time"] --> 8 (hour only, number only)
now["fc_hour1_ampm"] --> PM (either AM or PM in caps)
now["fc_hour1_ampm_lc"] --> pm (am or pm in lower case)
now["fc_hour1_cond"] --> P Cloudy (the shortened version of weather direct from intellicast)
now["fc_hour1_cond_lc"] --> p cloudy
now["fc_hour1_cond_caps"] --> P CLOUDY
now["fc_hour1_wicon"] --> outputs the full path to the weather icon for use with the image() function
now["fc_hour1_wfont"] --> outputs the character for the weather font
now["fc_hour1_temp"] --> outputs forecast temp (number only)
--recent additions--------------------------------------------------------------------------------
now["time_24"] --> update time in 24 hour format 18:36
now["fc_hour1_time_24"] --> time in 24 hour format, 18 (only hours shown)
now["fc_hour2_time_24"]
now["fc_hour3_time_24"]
--the next 3 hour conditions can now be processed through the con_short table (set in .v9000_config.lua) in order to translate for example ----------------------------------------------------------------
now["fc_hour1_cond_short"]
now["fc_hour1_cond_short_caps"]
now["fc_hour1_cond_short_lc"]
there are 3 hours in the forecast, simply replace "hour1" with "hour2" or "hour3" depends on which hour you want
FORECAST DATA OPTIONS with examples (n represents a number from 1 to 10 designating forecast day)
forecast_day[n] --> Sunday
forecast_day_caps[n] --> SUNDAY
forecast_day_lc[n] --> sunday
forecast_day_short[n] --> Sun
forecast_day_short_caps[n] --> SUN
forecast_day_short_lc[n] -->sun
forecast_month[n] --> January
forecast_month_caps[n] --> JANUARY
forecast_month_lc[n] --> january
forecast_month_short[n] --> Jan
forecast_month_short_caps[n] --> JAN
forecast_month_short_lc[n] --> jan
forecast_date[n] --> 8 (number only)
weather_icon[n] --> returns full path to weather icon
weather_font[n] --> returns character for weather font
high_temp[n] --> 35 (temp number only)
low_temp[n] --> 20 (temp number only)
conditions[n] --> Overcast
conditions_caps[n] --> OVERCAST
conditions_lc[n] --> overcast
conditions_short[n] -->according to settings
conditions_short_caps[n] --> according to settings
conditions_short_lc[n] --> according to settings
sun_rise[n] --> 6:15 AM
sun_rise_lc[n] --> 6:15 am
sun_rise_time[n] --> 6:15
moon_rise[n] --> 11.44 PM
moon_rise_lc[n] --> 11:44 pm
moon_rise_time[n] --> 11:44
moon_rise_ampm[n] --> PM
moon_rise_ampm_lc[n] --> pm
sun_set[n] --> 5:28 PM
sun_set_lc[n] --> 5:28 pm
sun_set_time[n] --> 5:28
moon_set[n] --> 3:18 AM
moon_set_lc[n] --> 3:18 am
moon_set_time[n] --> 3:18
moon_set_ampm[n] --> AM
moon_set_ampm_lc[n] --> am
humidity[n] --> 44 (percentage, number only)
precipitation[n] --> 25 (percentage, number only)
snow[n] --> 10 (percentage, number only)
cloud_cover[n] --> 68 (percentage, number only)
moon_phase[n] --> Waxing Gibbous
moon_phase_caps[n] --> WAXING GIBBOUS
moon_phase_lc[n] --> waxing gibbous
moon_font[n] --> returns character for moon font (Moon Phases)
moon_icon[n] --> used in conjunction with the image() function to display a corresponding moon icon
--WIND FORECAST OPTIONS
wind_mph[n] --> 4 (number only)
wind_km[n] --> 6 (number only)
wind_kts[n] --> 3 (number only)
wind_font[n] --> returns charcter for wind direction font (ConkyWindNESW)
wind_deg[n] --> 135 (degrees, number only)
wind_nesw[n] --> SE (uppercase only)
wind_icon[n] --> used in conjunction with the image() function to display a color coded wind direction icon
-------------------------------------------------
uv_index_num[n] --> 2 (number only)
uv_index_txt[n] --> Low (text only)
uv_index_txt_caps[n] --> LOW
uv_index_txt_lc[n] --> low
--recent additions----------------------------------------------------------------------------------------
sun_rise_24[n] --> below give times in 24 hour format 18:36 or 03:24
sun_set_24[n]
moon_rise_24[n]
moon_set_24[n]
if anyone has any other variations on the current data options let me know and ill see what i can do
Last edited by mrpeachy (2013-12-26 23:17:03)
Offline
PART 2 - how to use the out() function
using the out function is like putting together a jigsaw, rather than the conkyrc analogy of writing a letter
the function "out" is how you get the lua script to display text and weather data
it takes the form out({options})
to break it down:
out - names the function to use
what is inside the curved brackets () is the information we are sending to the out function
curly brackets deignate a table in lua
they are inside the curved brackets ({})
in the table are the options, these are:
c=color (eg 0xffffff for white)
a=alpha (eg 1 for full opaque)
f=font (eg "Mono" font name has to be in quotes)
fs=font size (eg 12)
x=x position (eg 100 sets output 100 pixels in from left edge)
y=y position (eg 100 sets output 100 pixels down from top)
txt=text or data to show (more about txt later)
so we want to show the text
Hello World
in Mono font at size 12, fully opaque white at coordinates 100 across,100 down
we need this
out({c=0xffffff,a=1,f="mono",fs=12,x=100,y=100,txt="Hello World"})
in a lua table entries must be seperated by a comma ,
a missing comma will give an error!
NOTE in the settings at the top you set these values:
default_font="mono"--font must be in quotes
default_font_size=10
default_color=0xffffff--white
default_alpha=1--fully opaque
because of these settings, if you want your output in the default, you dont need to set the values each time for the out function
using the above settings
out({x=100,y=100,txt="Hello World"})
will use the default settings for color,alpha,font and font size
if you want something other than the defualt sending the value to the out function overwrites the default
NOTE about txt
txt can be one of 2 things or a combination of both
1. plain text eg
Weather Forecast
plain text must be in quotes, so:
txt="Weather Forecast"
2. weather data, eg you want to show current conditions
Mostly Sunny
this is generated from a lua data option, in this case now["conditions"]
data options are called without quotes, so:
txt=now["conditions"]
3. Plain text and weather data, eg you want the following
Feels like temp: 35 °F
the text
Feels like temp:
is plain text
the number
35
is generated from a data option
and the
°F
is plain text
the code for this is
txt="Feels like temp: "..now["feels_like"].." °F"
here we use a double period .. to stitch the different parts of the line together
if we wanted to put together 2 different data options seperated by a space
for example wind direction in degrees and wind direction in NESW
txt=now["wind_deg"].." "..now[wind_nesw]
the space is required to be input as plain text in quotes and returns
135 SW
without the space we still need the .. to put the eperate data options together
txt=now["wind_deg"]..now[wind_nesw]
but it would look like this
135SW
using x and y to set output position
this is perhaps the greatest inconvenience to showing text via a lua script
but while it may take more effort to get text on the screen this way, I have always found lua to be much more efficient at displaying text
especially when you are using lots of gotos and voffsets in the conkyrc
and with some tricks text positioning can be made much easier
say you want a table like so, lets say that we want everything to be in our default font, font size and alpha
to make that table there are 9 elements to call and place
1 main title
4 sub titles
4 data outputs with following °F
we want the text Temperatures to start at 20 across 20 down
out({x=20,y=20,c=0xffff00,txt="Temperatures"})
note x=20,y=20 are the coordinates of the bottom left corner of the text
we could do the rest like this, i like to use comments to help me remember what im doing
a comment in lua is started with --
we want the sub title text to line up on the left at x=20 (across)
and the weather data to line up at x=160 (across)
then we will need to set y (down) values for each line, and match the y values from the sub titles to the data
--titles column
out({x=20,y=45,c=0xff0000,txt="Feels Like: "})
out({x=20,y=60,c=0xff0000,txt="Wind Chill: "})
out({x=20,y=75,c=0xff0000,txt="Heat Index: "})
out({x=20,y=90,c=0xff0000,txt="Dew Point: "})
--weather data column
out({x=160,y=45,c=0x0000ff,txt=now["feels_like"].."°F"})
out({x=160,y=60,c=0x0000ff,txt=now["wind_chill"].."°F"})
out({x=160,y=75,c=0x0000ff,txt=now["heat_index"].."°F"})
out({x=160,y=90,c=0x0000ff,txt=now["dew_point"].."°F"})
but say we didnt like the spacing, we would have to go back and recalculate and input each y value
but to make things easier we can use calculations like this,
--titles column
lgap=15--set how much gap, in pixels, between lines
gap=20+lgap--the first line, Temperatures, was set at x=20, so the next line is at 20+lgap, gap=45
out({x=20,y=gap,c=0xff0000,txt="Feels Like: "})
gap=gap+lgap--calculate new gap by adding lgap to the previous gap value of 45, gap=60
out({x=20,y=gap,c=0xff0000,txt="Wind Chill: "})
gap=gap+lgap--calculate new gap by adding lgap to the previous gap value of 60, gap=75
out({x=20,y=gap,c=0xff0000,txt="Heat Index: "})
gap=gap+lgap--calculate new gap by adding lgap to the previous gap value of 75, gap=90
out({x=20,y=gap,c=0xff0000,txt="Dew Point: "})
--weather data column
gap=20+lgap--reset gap value to 45
out({x=160,y=gap,c=0x0000ff,txt=now["feels_like"].."°F"})
gap=gap+lgap
out({x=160,y=gap,c=0x0000ff,txt=now["wind_chill"].."°F"})
gap=gap+lgap
out({x=160,y=gap,c=0x0000ff,txt=now["heat_index"].."°F"})
gap=gap+lgap
out({x=160,y=gap,c=0x0000ff,txt=now["dew_point"].."°F"})
now if we dont like the spacing, we only need adjust lgap and everything else will adjust accordingly
for both the titles column and the data column
it also means you can rearrange the order of lines quite easily without having to reset the y value for each
NOTE setting gap= sets a variable in lua which should ideally be preceeded by local like so
local gap=gap+gap
this helps with such things as minimizing the potential for memory leaks
but isnt absolutely necessary
another method would be to preset your variables then use them lower down in the code
--set x values, need 2 for 2 columns
x1=20
x2=160
--set y values, need 4 for the 4 lines
y1=45
y2=60
y3=75
y4=90
--titles column
out({x=x1,y=y1,c=0xff0000,txt="Feels Like: "})
out({x=x1,y=y2,c=0xff0000,txt="Wind Chill: "})
out({x=x1,y=y3,c=0xff0000,txt="Heat Index: "})
out({x=x1,y=y4,c=0xff0000,txt="Dew Point: "})
--weather data column
out({x=x2,y=y1,c=0x0000ff,txt=now["feels_like"].."°F"})
out({x=x2,y=y2,c=0x0000ff,txt=now["wind_chill"].."°F"})
out({x=x2,y=y3,c=0x0000ff,txt=now["heat_index"].."°F"})
out({x=x2,y=y4,c=0x0000ff,txt=now["dew_point"].."°F"})
now you can adjust the preset x and y values in one place and have the text reposition accordingly
the use of calculations and the ability to set variables adds a lot of flexibility to the code
Last edited by mrpeachy (2012-01-15 21:34:50)
Offline
PART 3 - how to use the image function
the image function is relatively simple to use in comparison
it uses the same structure as the out function
image({options})
the options are
x=top left x position,
y=top left y position,
w=width of image(0=full size image),
h=height(0=full size image),
file=file location
so if we want to display the wether image for forecast day 6 at coordinates 100,100
with the image resized to 50x50 pixels you would type the following
image({x=100,y=100,h=50,w=50,file=weather_icon[6]})
but since we set
default_image_width=50
default_image_height=50
at the top of the script, we need not set h or w if we want the default 50x50 so
image({x=100,y=100,file=weather_icon[6]})
and thats pretty much it. Remember the commas to seperate the settings
and make sure you have correctly set your path to the icons at the top of the script
weathericons="/home/benjamin/Desktop/scripts/images/weathericons/"
Last edited by mrpeachy (2012-01-09 21:17:23)
Offline
PART 4 - using the forecast day repeat
one useful feature of v9000 is that you only need set up the format for a single forecast day
once set you can simply repeat the same format for each successive forecast day (up to 10 days)
without having to type any extra code
this is the repeat section from the current script
--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=4
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,105
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,105
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,180
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,180
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do--start of day repeat, do not edit ########
tlx=top_left_x_coordinate[i]--sets top left x position for each repeat ###################
tly=top_left_y_coordinate[i]--sets top left y position for each repeat ###################
--########################################################################################
out({c=0xffffff,a=1,f="mono",fs=12,x=tlx,y=tly,txt=forecast_day[i].." "..forecast_date[i]})
image({x=tlx,y=tly+5,h=30,w=30,file=weather_icon[i]})
out({c=0xffffff,a=1,f="mono",fs=12,x=tlx+35,y=tly+15,txt=high_temp[i].."°/"..low_temp[i].."°"})
--########################################################################################
end--of forecast repeat section ##########################################################
--########################################################################################
first you need to set which day to start from
start_day=1
then you set how many days you want to display in total
number_of_days=4
then you set the coordinates for the top left corner for each day you are displaying
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,105
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,105
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,180
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,180
in the above example i am setting x and y on the same line, separated by commas
In lua
a,b=x,y
is the same as
a=x
b=y
what you are actually doing with the code:
top_left_x_coordinate[1]=270
is making an entry, at position 1 in this case, in a table called "top_left_x_coordinate"
the next thing to set is the repeating loop
a blank loop would look like this:
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do--start of day repeat, do not edit ########
tlx=top_left_x_coordinate[i]--sets top left x position for each repeat ###################
tly=top_left_y_coordinate[i]--sets top left y position for each repeat ###################
--########################################################################################
--write day format below----------------------------------------------
--end of day format---------------------------------------------------
--####################################################################
end--of day repeat, do not edit this line ############################
--####################################################################
the first line
for i=start_day,number_of_days-(start_day-1) do
takes the variable i and sets the value of i to every number from the value of start_day to the value of number_of_days-(start_day-1)
so in our example
start_day=1
number_of_days=4
so the loop sets i to every number from 1 to 4 (inclusive)
so in the above for loop, we get the following
start loop
1st pass, i=1
2nd pass, i=2
3rd pass, i=3
4th pass, i=4
end of loop,repeat loop next cycle
this is an extremely useful piece of code and when used correctly can really cut down on the amount of typing you need to do!
data options for forecast days are all in the format:
option[n], where n is a number from 1 to 10 (the forecast day number)
so this code
print (forecast_day_short[1])
print (forecast_day_short[2])
print (forecast_day_short[3])
print (forecast_day_short[4])
and this code
for i=1,4 do
forecast_day_short[ i ]--i had to add spaces between [ and i and ] in order to post
end
would both result in, for example
Mon
Tue
Wed
Thu
the next lines
tlx=top_left_x_coordinate[i]
tly=top_left_y_coordinate[i]
are reading the entries that we put into the tables called
"top_left_x_coordinate" and "top_left_y_coordinate" and setting them to the variables "tlx" and "tly"
so on the first pass of the for loop:
i=1 so tlx=270 and tly=15
becasue we set our coordinates earlier here:
top_left_x_coordinate[1],top_left_y_coordinate[1]=270,15
so once we understand what is going on within the for loop, we can see how the following line would work inside the loop
out({x=tlx+0,y=tly+20,txt=forecast_day_short[i]})
on the 1st pass
i=1
tlx=270
tly=15
so in effect we have written
out({x=270+0,y=15+20,txt=forecast_day_short[1]})
and we get the short day name for forecast day 1 at coordinates 270,35
on the 2nd pass of the loop
i=2
tlx=top_left_x_coordinate[2] -- so tlx=540
tly=top_left_y_coordinate[2] -- so tly=15
(remember we set top_left_x_coordinate[2],top_left_y_coordinate[2]=540,15)
so we now have
out({x=540+0,y=15+20,txt=forecast_day_short[2]})
and we get the short day name for forecast day 2 at coordinates 540,35
and so on and so forth until we get all our short day names shown at their positions relative to the coordinates we set earlier.
NOTE
in order for the repetition to work x,y coordinates are set relative to tlx and tly inside the loop
this will be for both the out() and image() functions
and instead of calling forecast day number directly we use i inside the square brackets
out({x=[b]tlx+0[/b],y=[b]tly+20[/b],txt=forecast_day_short[[b] i[/b] ]})
otherwise we can use the out and image functions as described earlier.
The repeat function will, perhaps, be the trickiest to get to grips with if you are unfamiliar with writing code
Last edited by mrpeachy (2012-01-13 02:16:03)
Offline
mrpeachy; I turn my back for 3 or 4 days & look what you do!!!
Busy, busy, busy.
I expect you are going to add the great lessons above to your blog?
I'll let my brain recover from my days in the big city for as long as it needs before I go head down bum up into this new world of Lua - weather.
Again, an enormous thank you for your contribution to the community mrpeachy.
Offline
thanks handy
ok, i set myself a challenge of recreating sector11's display
using the lua only method
and i ran into some limitations i will mention here
first, recreating the "wind" line
Wind: 9 mph @ 220° (SW)
the last part, with the brackets a different color from the text inside... that is tricky for the lua, not out of the question, but it would require some more advanced code
this is because you would have to place the closing bracket separately from the wind direction letters but then as those letters change, you would have to calculate the width to position the bracket correctly
ill post a pic when im as close as i think i can get
the other thing that wasnt as much tricky as it is a little unintuitive
sector11 has the lower section which has a set format repeated for 8 additional forecast days
but the forecast days start at day 2 and go to day 9
using the repeat method you need to set
number_of_day=9
(even though you are only doing 8 repeats)
then you have to set
for i=2,number_of_days
so that the loop starts at i=2 and goes to i=9
i think an update to the repeat section to make e ability to repeat days starting from other than 1, more intuitive
anyway, here is my lookalike of sector11's lookalike
doesnt quite fit on my 600 pixels
oops just noticed that i missed a couple of things! --goes to fix
Last edited by mrpeachy (2012-01-10 01:12:22)
Offline
this is what i ended up with
if you want to use this
i have posted the entire weather_display function found at the bottom of the script in the latest update
just overwrite the existing weather_display function with this code
--###########################################################################################
--###########################################################################################
--###########################################################################################
function weather_display()--#################################################################
--these tables hold the top left coordinates for each repeat as set lower, do not edit ######
local top_left_x_coordinate={}--###################################################################
local top_left_y_coordinate={}--###################################################################
--###########################################################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE --
--set column xs
local lcx=15
local rcx=130
--current weather line ys
local l1=15
local l2=45
local l3=60
local l4=75
local l5=90
local l6=105
local l7=120
local l8=135
local l9=150
local l10=165
local l11=195
--set colors
local c1=0x48d1cc--light blue
local c2=0x7fffd4--lightest blue
local c3=0xf08080--pink
local c4=0xff0000--red
local c5=0xffffff--white
local c6=0xdcdcdc--grey
local c7=0xffdead--orangish
local c8=0x78899a--purplish
local c9=0x00bfff--;ighter blue
--set fonts and sizes
local f1,fs1="mono",14
local f2,fs2="sans",28
local f3,fs3="sans",14
--first line, first column
out ({f=f1,fs=fs1,c=c9,x=lcx,y=l1,txt=now["day"].." "..now["date"].." "..now["month_short"]})
--first line second column,part 1
out ({f=f1,fs=fs1,c=c2,x=rcx,y=l1,txt=low_temp[1].."°"})
--first line second column,part 2
out ({f=f1,fs=fs1,c=c2,x=rcx+30,y=l1,txt="<--"})
--first line second column,part 3
out ({f=f1,fs=fs1,c=c3,x=rcx+60,y=l1,txt="-->"})
--first line second column,part 4
out ({f=f1,fs=fs1,c=c3,x=rcx+90,y=l1,txt=high_temp[1].."°"})
--second line part 1
out ({f=f2,fs=fs2,c=c9,x=rcx,y=l2,txt=now["temp"].."° / "..now["feels_like"].."°"})
--rest of right column next to image titles
out ({c=c1,x=rcx,y=l3,txt="Humidity:"})
out ({c=c1,x=rcx,y=l4,txt="Dew Point:"})
out ({c=c1,x=rcx,y=l5,txt="Wind Chill:"})
out ({c=c1,x=rcx,y=l6,txt="Heat Index:"})
out ({c=c1,x=rcx,y=l7,txt="Visibility:"})
out ({c=c1,x=rcx,y=l9,txt="Gusts:"})
--rest of right column next to image data
local addx=78
out ({c=c5,x=rcx+addx,y=l3,txt=now["humidity"].." %"})
out ({c=c5,x=rcx+addx,y=l4,txt=now["dew_point"].."°F"})
out ({c=c5,x=rcx+addx,y=l5,txt=now["wind_chill"].."°F"})
out ({c=c5,x=rcx+addx,y=l6,txt=now["heat_index"].."°F"})
out ({c=c5,x=rcx+addx,y=l7,txt=now["visibility"]})
out ({c=c5,x=rcx+addx,y=l9,txt=now["wind_gusts"]})
--left column
out ({c=c1,x=lcx,y=l7,txt="Ceil:"})
out ({c=c1,x=lcx,y=l8,txt="Wind:"})
out ({c=c1,x=lcx,y=l9,txt="Barometer:"})
out ({c=c1,x=lcx,y=l10,txt="Phase:"})
local addx=70
out ({c=c5,x=lcx+addx,y=l7,txt=now["ceiling"]})
out ({c=c5,x=lcx+addx,y=l8,txt=now["wind_mph"].." @ "..now["wind_deg"].."° ("..now["wind_nesw"].."]"})
out ({c=c5,x=lcx+addx,y=l9,txt=now["pressure"].."\""})
out ({c=c5,x=lcx+addx,y=l10,txt=moon_phase[1]})
--conditions
out ({f=f2,fs=fs2,c=c6,x=lcx,y=l11,txt=now["conditions"]})
--image
image({x=10,y=15,file=now["weather_icon"]})
--end of current
--forecast 1
local l1=210
local l2=225
local l3=240
local l4=255
local l5=270
local l6=285
local l7=295
out({c=c7,x=lcx,y=l1,txt="Today's Forecast........................."})
mcx=80
out({c=c1,x=mcx,y=l2,txt="Rain:"})
out({c=c1,x=mcx,y=l3,txt="UVI:"})
out({c=c1,x=mcx,y=l4,txt="Sun:"})
out({c=c1,x=mcx,y=l5,txt="Moon:"})
addx=45
out({c=c5,x=mcx+addx,y=l2,txt=precipitation[1].." %"})
out({c=c5,x=mcx+addx,y=l3,txt=uv_index_num[1].."("..uv_index_txt[1]..")"})
out({c=c7,x=mcx+addx,y=l4,txt=sun_rise[1]})
out({c=c7,x=mcx+addx,y=l5,txt=moon_rise[1]})
--cloud
out({c=c1,x=mcx+addx+30,y=l2,txt="Cloud:"})
out({c=c5,x=mcx+addx+80,y=l2,txt=cloud_cover[1].." %"})
--sets
out({c=c8,x=mcx+addx+60,y=l4,txt=sun_set[1]})
out({c=c8,x=mcx+addx+60,y=l5,txt=moon_set[1]})
--moon phase
out({c=c5,x=mcx,y=l6,txt=moon_phase[1]})
--forecast icon
image({x=15,y=205,w=30,h=30,file=weather_icon[1]})
--forecast moon font
out({f="Moon Phases",fs=22,c=c5,x=34,y=280,txt=moon_font[1]})
--dotty line
out({c=c5,x=15,y=l7,txt="............................................"})
out({c=c5,x=15,y=550,txt="............................................"})
--end of forecast 1
--repeat forecast days
number_of_days=9
--enter coordinates of top left corner for each day
topx1,topx2,topy=15,175,315
gap=80
top_left_x_coordinate[2],top_left_y_coordinate[2]=topx1,topy
top_left_x_coordinate[3],top_left_y_coordinate[3]=topx2,topy
top_left_x_coordinate[4],top_left_y_coordinate[4]=topx1+80,topy+(gap/2)
top_left_x_coordinate[5],top_left_y_coordinate[5]=topx1,topy+gap
top_left_x_coordinate[6],top_left_y_coordinate[6]=topx2,topy+gap
top_left_x_coordinate[7],top_left_y_coordinate[7]=topx1+80,topy+(gap/2)+gap
top_left_x_coordinate[8],top_left_y_coordinate[8]=topx1,topy+gap+gap
top_left_x_coordinate[9],top_left_y_coordinate[9]=topx2,topy+gap+gap
--########################################################################################
for i=2,number_of_days do--start of day repeat, do not edit these lines ##################
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 ###################
--########################################################################################
--write day format below----------------------------------------------
out({c=c9,x=tlx+0,y=tly+0,txt=forecast_day[i]})
out({c=c2,x=tlx+0,y=tly+15,txt=low_temp[i].."°"})
out({c=c3,x=tlx+60,y=tly+15,txt=high_temp[i].."°"})
out({c=c2,x=tlx+30,y=tly+15,txt="<"})
out({c=c3,x=tlx+45,y=tly+15,txt=">"})
image({x=tlx-10,y=tly-10,file=weather_icon[i]})
--end of day format---------------------------------------------------
--####################################################################
end--of day repeat, do not edit this line ############################
--####################################################################
--END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE ----END OF WEATHER CODE --
--####################################################################
end--of weather_display function do not edit this line ###############
--####################################################################
Offline
This is going no make me sound like a complete NooB, but..
Your "circle" weather script has ran just fine all evening until about an hour ago when the forecast changed from "cloudy" to "light rain"
here is terminal
Conky: llua_do_call: function conky_weather execution failed: /home/falldown/.conky/weathercircle.lua:402: attempt to concatenate field '?' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: /home/falldown/.conky/weathercircle.lua:506: attempt to concatenate field '?' (a nil value)
and corresponding script
402: now["weather_icon"]=weathericons..wimage[t]..".png"
506: cwt={text="TMP: "..now["temp"].."F / FL: "..now["feels_like"].."F ",font="mono",fsize=14,radius=trad,xpos=midx,ypos=midy,position=2,start=astr+5,finish=aend-5,justify=1,letterdeg=5.5,};cw(cwt)
Is it possible that the script isn't finding a configuration for "light rain" ??
Peachy's Wun Lua / Peachy's v9000 / Conky PitStop / My DA Page
........
Offline
Your tutorial should reflect in Section 1
lua_load ~/path_to/the_script/weatheragain9000.lua
lua_draw_hook_pre conky_weather
## Blank line after TEXT
TEXT
Just a thought
Now ....
Something amiss ... these four lines show-up outside of the setup area:
local f=io.popen("curl --max-time 60 '"..web.."' | grep -A565 '10 Day Forecast' | sed 's/%//g'")-- > /home/benjamin/Desktop/weather.txt")
local f=io.popen("curl --max-time 60 '"..web.."' | grep -A120 '>Current Conditions ' | sed 's/%//g'")-- > /home/benjamin/Desktop/weather.txt")
local f=io.popen("curl --max-time 60 '"..web.."' | grep -A565 '10 Day Forecast' | sed 's/%//g'")-- > /home/benjamin/Desktop/weather.txt")
local f=io.popen("curl --max-time 60 '"..web.."' | grep -A120 '>Current Conditions ' | sed 's/%//g'")-- > /home/benjamin/Desktop/weather.txt")
The endings are commented out ( -- )
Nothing in the setup area talks about where the "weather.txt" goes...
--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP
secs=1800--set update interval
web="http://www.intellicast.com/Local/Forecast.aspx?unit=C&location=ARBA0009"--insert unit=C& after? for C
-- get web address by going to the intellicast site and entering your location in the box
-- for version 3 you must get click on "Extended Forecast" to get the necessary address
-- set location of weather images
weathericons="/home/sector11/Conky/images/weathericons/"
-- set defaults
default_font="Anonymous Pro"--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
--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP
So where do we set this "weather.txt" up?
terminal:
09:54:49 ~
$ killall conky && conky -c ~/Conky/w9000/S11_Weather9000 &
[1] 21491
09:55:00 ~
$ Conky: desktop window (1ff) is root window
Conky: window type - normal
Conky: drawing to created window (0x1600002)
Conky: drawing to double buffer
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 68231 100 68231 0 0 58482 0 0:00:01 0:00:01 --:--:-- 82704
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 68231 100 68231 0 0 80831 0 --:--:-- --:--:-- --:--:-- 102k
processing complete
Conky: llua_do_call: function conky_weather execution failed: /home/sector11/Conky/LUA/weather9000.lua:658: attempt to concatenate field '?' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: /home/sector11/Conky/LUA/weather9000.lua:658: attempt to concatenate field '?' (a nil value)
Conky: llua_do_call: function conky_weather execution failed: /home/sector11/Conky/LUA/weather9000.lua:658: attempt to concatenate field '?' (a nil value)
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
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