SEARCH

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

You are not logged in.

#251 2012-01-14 17:54:33

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

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

v9000 how to update http://dl.dropbox.com/u/19008369/weathe … lua.tar.gz

PART 7 - how to use xout() function

the xout() function is much like the out() function but with a couple of additional uses

xout() can take the following settings
c = color eg 0xffffff, if not given then color is default
a = alpha eg 0.7, if not given then alpha will be set to default
f =font eg "mono", if not given then font will be set to default
fs = font size eg "12", if not given then font size will be set to default
x = x coordinate, eg 100
y = y coordinate eg 120
txt = the output to be shows, eg "hello world"
j = justify, this is new for xout and will be described below

USE 1 - justify text

the variable j is used to set the justify position for the output
j can be set to:

"l" - l in quotes sets left justification, this is the default if l is not given
when "l" is set, x and y are the coordinates of the bottom left of the text

"c" - c in quotes sets center justification
when "c" is set, x and y are the coordinates for the bottom middle of the text

"r" - r in quotes sets right justification
when "r" is set, x and y are the coordinates for the bottom right of the text

so these lines

xout({x=120,y=500,txt="left justified text",j="l"})
xout({x=120,y=515,txt="center justified text",j="c"})
xout({x=120,y=530,txt="right justified text",j="r"})

give this output (line has been drawn for comparison purposes)
screenshot-1307.png

USE 2 - calculate text width to allow continuous line formatting
you may remember the infamous line from sector11's setup where the brackets surrounding wind direction were a different color to the letters inside the brackets smile
it looked a little like this:
(SW)

this was a little tricky for the lua, as in order to recolor an output you then had to specify its x and y coordinates again, but as the wind direction will change, getting smaller and larger, "hard coding" the position of the closing bracket was not going to work.  The second bracket needs to move in accordance to what is inside the brackets.

xout() can overcome this limitation by measuring the length in pixels of the output and then returning the x position for the following text.

so for example we saw this line above

xout({x=120,y=500,txt="left justified text",j="l"})

to get the measurement we need to set the measurement to a string, for example lets call the string for next position nx

nx=xout({x=120,y=500,txt="left justified text",j="l"})

this line does 2 things, it displays our text as before AND it sets nx to the length of the text
we can then use this measurement to set the x position for the following text

nx=xout({x=20,y=500,txt="left justified text",j="l"})
out({x=nx,y=500,txt=" some more text"})

i just want one extra piece of text to follow, so im using out() and i get

left justified text some more text

but you could have a string of commands using xout() to put together a continuous line like so

nx=xout({x=0,y=500,txt="text1",j="l"})
nx=xout({x=nx,y=500,txt=" text2"})
nx=xout({x=nx,y=500,txt=" text3"})
nx=xout({x=nx,y=500,txt=" text4"})
nx=xout({x=nx,y=500,txt=" text5"})
out({x=nx,y=500,txt=" text6"})

screenshot-2171.png

so, the different colored brackets:

nx=xout({c=0xff0000,x=20,y=500,txt="(",j="l"})
nx=xout({c=0x00ff00,x=nx,y=500,txt=now["wind_nesw"]})
out({c=0xff0000,x=nx,y=500,txt="))"})

screenshot-3134.png

NOTE, any subsequent pieces of text need to be set to "l" (left justify) in order for the positions to be calculated (remember that left justify is the default, so will be set if you dont give a setting for j)
however, the xout() function can calculate positions when the FIRST piece of text is set to "c" or "r"

Last edited by mrpeachy (2012-01-14 18:02:57)

Offline

Help fund CrunchBang, donate to the project!

#252 2012-01-14 19:38:33

ackernan
#! Junkie
Registered: 2011-01-10
Posts: 403

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

mrpeachy wrote:

v9000 how to update http://dl.dropbox.com/u/19008369/weathe … lua.tar.gz

SECTION 7 - using the xout() function

the xout() function is much like the out() function but with a couple of additional uses

xout() can take the following settings
c = color eg 0xffffff, if not given then color is default
a = alpha eg 0.7, if not given then alpha will be set to default
f =font eg "mono", if not given then font will be set to default
fs = font size eg "12", if not given then font size will be set to default
x = x coordinate, eg 100
y = y coordinate eg 120
txt = the output to be shows, eg "hello world"
j = justify, this is new for xout and will be described below

USE 1 - justify text

the variable j is used to set the justify position for the output
j can be set to:

"l" - l in quotes sets left justification, this is the default if l is not given
when "l" is set, x and y are the coordinates of the bottom left of the text

"c" - c in quotes sets center justification
when "c" is set, x and y are the coordinates for the bottom middle of the text

"r" - r in quotes sets right justification
when "r" is set, x and y are the coordinates for the bottom right of the text

so these lines

xout({x=120,y=500,txt="left justified text",j="l"})
xout({x=120,y=515,txt="center justified text",j="c"})
xout({x=120,y=530,txt="right justified text",j="r"})

...

It works as advertised.  I had no doubt it would.  Here's xout() using center justified in my setup.

Screenshot_3.jpg

Using these these lines.

xout({c=0xffffff,a=1,f="santana-black",fs=11,x=280,y=500,txt=now["conditions"],j="c"})
xout({c=0xffffff,a=1,f="santana-black",fs=11,x=245,y=580,txt=moon_phase[1],j="c"})

Offline

#253 2012-01-19 17:57:42

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

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

i was asked a question about whether it was possible to get the output of the v9000 script in a different language

this interesting question... as when you go to the intellicast website i assume no matter where you are that everything is in english?

it would be quite easy to make a setting like now["moon_phase_german"] which would call upon a conversion table because there are only a short list of moon phase outputs you get from intellicast
the same goes for day names and month names

it would also be pretty easy to allow the user to set the units used for some of the data options that come with units (ie setting something else than mph for wind speed)

the tricky part is the words used to describe the conditions which can be quite varied

BUT there is already a mechanism in place that could be used for translating conditions conditions_short
5.  setting up and using the short conditions option
http://crunchbanglinux.org/forums/post/178119/#p178119

it would just be a question of writing in your translations into the table like so

["Light Rain"]="Licht Regen",
["Heavy Rain"]="Schwere Regen"

this might be a bit of an undertaking given the variety of condition types i have seen, but there can only be so many weather types the site has to give!

ill see if i can put an update together that allows you to set all your units and outputs translated

Last edited by mrpeachy (2012-01-21 04:32:44)

Offline

#254 2012-01-21 04:06:23

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

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

PART 8 - how to use the translate functions

v9000.lua can be set up to translate the text coming from the intellicast website

there are several points to address for translations.

1. use the short conditions setup table to enter translations for weather conditions
for example:

--ALSO USE THIS TABLE TO ENTER CONDITIONS TRANSLATIONS
con_short={--start of table, put entries below in form eg: ["Thunderstorm"]="T.Strm",
["Light Rain"]="Licht Regen",
["Heavy Rain"]="Schwere Regen",
}--this bracket closes the table

2.  setting units in the settings section

--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 preceeding spaces if any for formatting
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="°"

3. setting up translation tables

there is a setting to turn on or off the use of translation tables

--do you want the script to use translation tables?
--set 1 if you want to translate, 0 if not.
--the translation tables are located at the bottom of the script in  function called "translate_tables"
--these tables are in addition to the con_short table which can be used to translate weather conditions and data options units settings 
local translate=1

the translation tables are located at the bottom of the script.  The various tables contain everything else that would possibly need translation.
eg
day names
month names
moon phases

just work your way through the translation tables, make sure you only edit the second part of each entry, the part after the =

function translate_tables()
--TRANSLATION TABLES - only edit the second, the one after the =
--translate NESW text
neswtext={
S="testS",
SSW="tsetSSW",
SW="testSW",
WSW="testWSW",
W="testW",
WNW="testWNW",
NW="testNW",
NNW="testNNW",
N="testN",
NNE="testNNE",
NE="testNE",
ENE="testENE",
E="testE",
ESE="testESE",
SE="testSE",
SSE="testSSE",
}--end of  N E S W text table
--translate time suffix
tsuffix={
AM="testAM",
PM="testPM",
}--end of time suffix table
--enter translations for uv index text
uvindextext={
["Low"]="testLow",
["Moderate"]="testModerate",
["High"]="testHigh",
["Very High"]="testVery High",--format is different because of the space in the text
["Extreme"]="testExtreme",
}--end of uv text table
--enter translations for moonpahse
moonphases={
["New"]="testNew",
["Full"]="testFull",
["First Quarter"]="testFirst Quarter",
["Last Quarter"]="testLast Quarter",
["Waning Gibbous"]="testWaning Gibbous",
["Waning Crescent"]="testWaning Crescent",
["Waxing Crescent"]="testWaxing Crescent",
["Waxing Gibbous"]="testWaxing Gibbous",
}--end of moon phase table
--enter translations for day names
daynames={
Monday="testMonday",
Tuesday="testTuesday",
Wednesday="testWednesday",
Thursday="testThursday",
Friday="testFriday",
Saturday="testSaturday",
Sunday="testSunday",
}--end day names table
--enter translations for short day names
dayshort={
Monday="testMon",
Tuesday="testTue",
Wednesday="testWed",
Thursday="testThu",
Friday="testFri",
Saturday="testSat",
Sunday="testSun"
}--end short day names table
--enter translation for month names
monthnames={
January="testJanuary",
February="testFebruary",
March="testMarch",
April="testApril",
May="testMay",
June="testJune",
July="testJuly",
August="testAugust",
September="testSeptember",
October="testOctober",
November="testNovember",
December="testDecember"
}--end of month name translations
monthshort={
January="testJan",
February="testFeb",
March="testMar",
April="testApr",
May="testMay",
June="testJun",
July="testJul",
August="testAug",
September="testSep",
October="testOct",
November="testNov",
December="testDec"
}--end of short month name translations
--END OF TRANSLATIONS
end--of translate tables function ####################################################

NOTE
currently the 3 hour forecast conditions types are not fed through the con_short tables
i can envision some problems as the 3 hour conditions are already shortened
ill test this out and see

Last edited by mrpeachy (2012-01-28 02:07:37)

Offline

#255 2012-01-21 07:22:23

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

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

so with a bit of editing and translation here are all the possible outputs from the script , german version
screenshotcbbee1912b2482ef47f59539e8ec110c.png
you can see english weather conditions and the translated conditions called with conditions_short

i apologise for the quality of my german translations in advance big_smile

Last edited by mrpeachy (2012-01-21 07:24:21)

Offline

#256 2012-01-21 18:51:45

handy
Member
Registered: 2011-12-31
Posts: 34

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

You do love playing with languages mrpeachy. smile  (& mathematics I suspect...)

Last edited by handy (2012-01-21 18:52:30)

Offline

#257 2012-01-22 02:10:41

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

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

http://dl.dropbox.com/u/19008369/v9000.tar.gz
this link contains the v9000 script set up to read a separate weather script
there is also an example weather script to use with v9000
and the icons and fonts

Offline

#258 2012-01-22 02:31:16

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!

mrpeachy wrote:

http://dl.dropbox.com/u/19008369/v9000.tar.gz
this link contains the v9000 script set up to read a separate weather script
there is also an example weather script to use with v9000
and the icons and fonts


Ooooooooooooooo  gonna play ... tomorrow!!!!!!

Night all!


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

Offline

#259 2012-01-22 15:41:11

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!

I think mrpeachy knew something when he gave the version number to his latest weather LUA script: "v9000"

f165f9171122092.jpg

OK I have the t9000 package (template) {my naming structure} and I'm of to play with LUA "t9000", bang my head on the keyboard, shout obscenities at the universe, chew my fingernails to the bone, play hop-scotch in a mine field.

OK world - wish me luck! LUA and I have never been friends.


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

Offline

#260 2012-01-22 17:55:17

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!

The latest version (with the template) [t9000]

Is this normal when I close the terminal:

  14:53:00 ~
         $ Conky: desktop window (15d) is root window
Conky: window type - normal
Conky: drawing to created window (0x1c00002)
Conky: drawing to double buffer
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 68171  100 68171    0     0  85616      0 --:--:-- --:--:-- --:--:--  105k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 68171  100 68171    0     0  80700      0 --:--:-- --:--:-- --:--:--   99k
processing complete
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 1254 requests (1252 known processed) with 0 events remaining.

[1]+  Exit 1                  conky -c ~/Conky/t9000/t_9001.conky

  14:53:14 ~
         $ 

EDIT: Does it do more than 4 days? I get an error, probably need to read more - never mind ... more reading got it

Last edited by Sector11 (2012-01-22 18:00:27)


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

Offline

#261 2012-01-22 18:27:38

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!

Nope ... what I see here:

4. how to use the forecast repeat
http://crunchbanglinux.org/forums/post/177787/#p177787

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

does not match this:

--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=4
topy=280
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
ady=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,ady

and when I try 6 days:

--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=6
topy=280
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
ady=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,ady
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,ady
top_left_x_coordinate[6],top_left_y_coordinate[6]=120,ady

I get this:
b65f47171150654.jpg
{sigh}As you see days 4 & 5 overlap days 3 & 4.

BUT, and this is a boggie for me, I did manage some simple edits.


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

Offline

#262 2012-01-22 21:48:59

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!

HEY!!!!  Nobody else home?  I don't wanna play alone.

All mrpeachy ...
c41511171174473.jpg
... the template version of v9000 (t9000 here, on the left) is a LOT easier for me to play with  ... why?  Simple: As soon as I make a change, I see it, easier to plan and move things little by little.

When I started this around noon, NOW showed what it has right now, a Few Clouds. the next three hours showed Thunderstorms as well as for Monday, Tuesday and Wednesday, Thursday showed just "Rain" - look at it now!

As akernan says: "I can flip a coin as well as any weatherman!"  That's about how accurate they are.  I regress... the template ...

I have managed to make some changes, now to get a "full" weather conky going ... I hope.

v9000 was the death of me ... t9000 got me going.
{I can hear mrpeachy now, "But they are the same thing."} - naaa not quite.

t_9001.conky

## To use #! in a conky use: ${exec echo '#!'}
## killall conky && conky -c ~/Conky/t9000/t_9001.conky &

##
## mrppeachys LUA Tutorial
## http://crunchbanglinux.org/forums/post/177782/#p177782
## the file:
## http://dl.dropbox.com/u/19008369/weatheragain9000.lua.tar.gz
##
###  Begin Window Settings  ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent no
#own_window_hints undecorated,below,skip_taskbar,skip_pager
own_window_hints below,sticky,skip_taskbar,skip_pager
#own_window_colour black
own_window_class t 9001
own_window_title t 9001

# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes

### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### 'own_window_type override'
own_window_argb_visual yes

### When ARGB visuals are enabled, this use this to modify the alpha value
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
## own_window_argb_value 0

minimum_size 200 650     ## width, height
maximum_width 200       ## width, usually a good idea to equal minimum width

gap_x 15        ### left &right
gap_y 15        ### up & down

alignment top_left
####################################################  End Window Settings  ###
###  Font Settings  ##########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont Anonymous Pro:size=9


# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 0
# Force UTF8? requires XFT ###
override_utf8_locale yes

draw_shades no
default_shade_color black

draw_outline no # amplifies text if yes
default_outline_color black

uppercase no
######################################################  End Font Settings  ###
###  Color Settings  #########################################################
default_shade_color grey
default_outline_color black

default_color DCDCDC #Gainsboro
color0 DAA520 #Goldenrod  FFFFF0 #Ivory
color1 778899 #LightSlateGrey
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 FFA07A #LightSalmon
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 00FFFF #Cyan 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red
#####################################################  End Color Settings  ###
###  Borders Section  ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 10
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders no
#####################################################  End Borders Secton  ###
###  Miscellaneous Section  ##################################################

# Boolean value, if true, Conky will be forked to background when started.
background no

# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none

# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 6000

# Subtract (file system) buffers from used memory?
no_buffers yes

# change GiB to G and MiB to M
short_units yes

# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2

##############################################  End Miscellaneous Section  ###
###  LUA Settings  ###########################################################
## Above and After TEXT - requires a composite manager or it blinks.
##
## lua_load ~/wea_conky/draw_bg.lua
## TEXT
## ${lua conky_draw_bg 10 0 0 0 0 0x000000 0.4}
## ${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
##
##
## OR Both above TEXT (No composite manager required - no blinking!)
##
## lua_load ~/wea_conky/draw_bg.lua
## lua_draw_hook_pre draw_bg 10 0 0 0 0 0x000000 0.5
## TEXT
##
#######################################################  End LUA Settings  ###

# The all important - How often conky refreshes.
# If you have a "Crey" try: 0.2 - smokin' - but watch the CPU useage go UP!
update_interval 1

#lua_load ~/Conky/LUA/weather9001.lua
#lua_draw_hook_pre conky_weather 
#starts the lua weather data gathering function, call once at top of conkyrc

lua_load ~/Conky/t9000/t9000.lua
lua_draw_hook_pre weather
lua_load ~/Conky/t9000/t9001_template.lua

TEXT

CAUTION: Blank line after TEXT

t9001.template.lua

_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={}--###############################################
--#######################################################################
--START OF WEATHER CODE -- START OF WEATHER CODE -- START OF WEATHER CODE
out({c=0x00BFFF,a=1,f="Anonymous Pro:bold",fs=11,x=15,y=15,txt="Buenos Aires @ "..now["time"]})
image({x=20,y=20,h=40,w=40,file=now["weather_icon"]})
--data titles
--out({c=0xFAFAEC,a=1,f="Anonymous Pro:bold",fs=11,x=15,y=30,txt="Conditions:"})
out({c=0xFAFAEC,a=1,f="Anonymous Pro:bold",fs=11,x=70,y=30,txt="Temperature:"})
out({c=0xFAFAEC,a=1,f="Anonymous Pro:bold",fs=11,x=70,y=45,txt="      Feels Like:"})
out({c=0xFAFAEC,a=1,f="Anonymous Pro:bold",fs=11,x=70,y=60,txt="               Wind:"})
--output of data options
out({c=0x48D1CC,a=1,f="Anonymous Pro:bold",fs=11,x=170,y=30,txt=now["temp"].."°"})
out({c=0x48D1CC,a=1,f="Anonymous Pro:bold",fs=11,x=170,y=45,txt=now["feels_like"].."°"})
out({c=0x48D1CC,a=1,f="Anonymous Pro:bold",fs=11,x=170,y=60,txt=now["wind_mph"]})
out({c=0x48D1CC,a=1,f="Zekton",fs=18,x=15,y=84,txt=now["conditions"]})

out({c=0xFAFAEC,a=1,f="Anonymous Pro:bold",fs=12,x=15,y=105,txt="Next 3 Hours"})
image({w=30,h=30,x=20,y=115,file=now["fc_hour1_wicon"]}) -- good
-- out({x=80,y=125,txt=now["fc_hour1_time"].." "..now["fc_hour1_ampm"].."  "..now["fc_hour1_temp"].."°"})
out({x=70,y=125,txt=now["fc_hour1_temp"].."° by "..now["fc_hour1_time"].."  "..now["fc_hour1_ampm"]})
out({x=70,y=140,txt=now["fc_hour1_cond"]})

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

image({w=30,h=30,x=20,y=205,file=now["fc_hour3_wicon"]}) -- good
out({x=70,y=215,txt=now["fc_hour3_temp"].."° by "..now["fc_hour3_time"].."  "..now["fc_hour3_ampm"]})
out({x=70,y=230,txt=now["fc_hour3_cond"]})

--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=10
topy=280
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,280 --topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,280 --topy
ady=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,360 --ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,360 --ady
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,440 --ady
top_left_x_coordinate[6],top_left_y_coordinate[6]=120,440 --ady
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,520 --ady
top_left_x_coordinate[8],top_left_y_coordinate[8]=120,520 --ady
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,600 --ady
top_left_x_coordinate[10],top_left_y_coordinate[10]=120,600 --ady
--########################################################################################
for i=start_day,number_of_days-(start_day-1) do--start of day repeat, do not edit ########
tlx=top_left_x_coordinate[i]--sets top left x position for each repeat ###################
tly=top_left_y_coordinate[i]--sets top left y position for each repeat ###################
--########################################################################################
out({c=0xA4FFA4,a=1,f="Anonymous Pro:bold",fs=11,x=tlx,y=tly,txt=forecast_day_short[i].."  "..forecast_date[i].."  "..forecast_month_short[i]})
image({x=tlx,y=tly+5,h=30,w=30,file=weather_icon[i]})
out({c=0xFF8C00,a=1,f="Anonymous Pro:bold",fs=11,x=tlx+35,y=tly+15,txt=high_temp[i].."°"})
out({c=0x48D1CC,a=1,f="Anonymous Pro:bold",fs=11,x=tlx+35,y=tly+30,txt=low_temp[i].."°"})
out({c=0xFAFAEC,a=1,f="Anonymous Pro:bold",fs=11,x=tlx,y=tly+50,txt=conditions_short[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 ##################
--#######################################################################

Could not figure out the "ady=topy+ygap" stuff so I commented those out and did it manually.

If you want the LUA and sample template they are found in this post.

The readme says, among other things:

only edit weather_script.lua

that's the template lua ... but that's not really true - unless you are mrpeachy and want to use his data.  big_smile

You still need to edit this part:

--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP
local secs=1800--set update interval
local 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
local weathericons="/home/sector11/Conky/images/weathericons/"
--set defaults do not localise these defaults if you use a seperate display script
default_font="Anonymous Pro:bold"--font must be in quotes
default_font_size=11
default_color=0xffffff--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
---------------------------------
--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]
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
--set up use of seperate display script or data entry at bottom of this script
local display_script=1 -- set 1 for seperate display script, 0 to enter at bottom
--some curent weather data options come with their own units attached
--visibility (mi), wind_mph (mph), wind_gusts (mph), ceiling (ft)
--enter here how the units should follow the numbers, ie spaces or no spaces
local units_gap=" "-- in this example i will have 1 space between number and units, eg 5 mph
--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP

First time I ran it the weather looked really weird ... I followed the readme to the "T".  lol

Now to get a complete list of weather commands this sucker can do an really go to town.

THANK YOU MRPEACHY!


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

Offline

#263 2012-01-22 23:21:27

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

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

lol:lol::lol::lol: sheesh, im busy for a few hours and Secto11 goes lua weather crazy!
ill look through carefully everything you've posted!

Offline

#264 2012-01-22 23:37:24

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

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

Sector11 wrote:

and when I try 6 days:

--start or weather forecast repeat section
--set start forecast day
start_day=1
--set total forecast days you want to display
number_of_days=6
topy=280
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
ady=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,ady
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,ady
top_left_x_coordinate[6],top_left_y_coordinate[6]=120,ady

the reason why they are overlapping is because you have set the same y values for 5 and 6 as you have for 3 and 4

what i was doing here

topy=280
ygap=80

is setting the topmost y coordinate and then how much space vertically im giving each day

im then using these strings lower down to set values

top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy

so the topmost 2 days will both be 280 pixels down from the top of the conky window
because top_left_y_coordinate is set to topy (which has the value of 280)

now when i edit just the one value, say change topy=300 everything will move down accordingly without having to edit each position

then i have this line

ady=topy+ygap

this line resets the y vale to 280+80 making the value of ady has a value of 360
(i am guilty of making some of the string names here too vague, perhaps ady could have been called second_row_y )

so i set the y values for the next 2 days to 360 by using the ady string

top_left_x_coordinate[3],top_left_y_coordinate[3]=15,ady
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,ady

what you could have done is to again define the next y value
to use some more helpful string names

third_row_y=ady+ygap

so
third_row_y=360+80
third_row_y=440

then i could have used this string for the y coordinate of days 5 and 6

top_left_x_coordinate[5],top_left_y_coordinate[5]=15,third_row_y
top_left_x_coordinate[6],top_left_y_coordinate[6]=120,third_row_y

the benefit of doing things via math and strings is that i can edit topy and ygap and changes will be automatic throughout the display

but at the same time this is a tricky concept to get to grips with

Offline

#265 2012-01-22 23:39:46

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

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

Sector11 wrote:

The readme says, among other things:

only edit weather_script.lua

that's the template lua ... but that's not really true - unless you are mrpeachy and want to use his data.  big_smile

well you've got me there big_smile
ill edit the readme

Offline

#266 2012-01-23 00:41:44

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!

mrpeachy wrote:
Sector11 wrote:

The readme says, among other things:

only edit weather_script.lua

that's the template lua ... but that's not really true - unless you are mrpeachy and want to use his data.  big_smile

well you've got me there big_smile
ill edit the readme

Actually you have me.

As to the

third_row_y=ady+ygap

that's easy - if you know to do that.  smile

I understand your idea behind that and why you'd use it, makes sense if you are going to edit it later.

Would this work I wonder (doing it here, not in a conky - that I will test as well)

topy=280
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
add34=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,add34
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,add34
add56=topy+ygap+ygap -- or add56=topy+(ygap*2)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,add56
top_left_x_coordinate[6],top_left_y_coordinate[6]=120,add56
add78=topy+ygap+ygap+ygap -- or add78=topy+(ygap*3)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,add78
top_left_x_coordinate[8],top_left_y_coordinate[8]=120,add78
add910=topy+ygap+ygap+ygap+ygap -- or add910=topy+(ygap*4)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,add910
top_left_x_coordinate[10],top_left_y_coordinate[10]=120,add910

add(day)1(&)10 = add910

grasping at straws and thinking "logic" out loud ... OK typing  big_smile

Also somethere, I think, (I will go looking but since you are here) you mentioned that is a way for LUA to treat an outnut as a number.  Intellcast used barometric pressure in inches, I want to convert that to hPa

1 inch of mercury
  = 25.4 mm of mercury
  = 33.86 millibars
  = 33.86 hectoPascals

so Barometric Pressure 29.77" = 1008.0122 hPa

If so can it also round of to one decimal place or the nearest whole number??


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

Offline

#267 2012-01-23 00:47:39

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!

OK, both ways of my first idea worked, my template now looks like this:

number_of_days=10
topy=280
ygap=80
--set coordinates for top lef corners for each repeat
top_left_x_coordinate[1],top_left_y_coordinate[1]=15,topy
top_left_x_coordinate[2],top_left_y_coordinate[2]=120,topy
add34=topy+ygap
top_left_x_coordinate[3],top_left_y_coordinate[3]=15,add34
top_left_x_coordinate[4],top_left_y_coordinate[4]=120,add34
add56=topy+(ygap*2)
top_left_x_coordinate[5],top_left_y_coordinate[5]=15,add56
top_left_x_coordinate[6],top_left_y_coordinate[6]=120,add56
add78=topy+(ygap*3)
top_left_x_coordinate[7],top_left_y_coordinate[7]=15,add78
top_left_x_coordinate[8],top_left_y_coordinate[8]=120,add78
add910=topy+(ygap*4)
top_left_x_coordinate[9],top_left_y_coordinate[9]=15,add910
top_left_x_coordinate[10],top_left_y_coordinate[10]=120,add910

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

Offline

#268 2012-01-23 01:18:44

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

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

re conversions
yes, certainly possible

inches of hg to pascals

--convert inches of hg to pascals
pa=tonumber(now["pressure"])*3,386.389
--convert to hpa, 1hpa=100pa
hpa=pa/100

rounding is a little more complicated

here is a rounding function
http://lua-users.org/wiki/SimpleRound

i often end up at the lua_users.org/wiki site when i google for lua help smile

you could take that function put it into either the main (at the bottom) or the template (again at the bottom)

then

--convert inches of hg to pascals
pa=tonumber(now["pressure"])*3386.389
--convert to hpa, 1hpa=100pa
hpa=pa/100
--round hpa to 2 decimal places
hpa2d=round(hpa,2)

would be easier to make a function that does the whole conversion

function hg_to_hpa(hg_pressure)
--convert inches of hg to pascals
local pa=tonumber(hg_pressure)*3386.389
--convert to hpa, 1hpa=100pa
local hpa=pa/100
--round hpa to 2 decimal places
local mult = 10^2
return math.floor(hpa * mult + 0.5) / mult
end

then use it in the template

hpa=hg_to_hpa(tonumber(now["pressure"]))

your probably sorry you asked big_smile

EDIT
i was using this line to convert inhg to pa

pa=tonumber(now["pressure"])*3,386.389

i had copies the 3,386.389 directly from a conversion website BUT i forgot that lua uses commas as dividers between information, so the equation wasnt working properly

Last edited by mrpeachy (2012-01-23 01:53:51)

Offline

#269 2012-01-23 01:37:22

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

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

ive made a small change to the main and display scripts in the v9000 archive
http://dl.dropbox.com/u/19008369/v9000.tar.gz

i cut out the lines where you set defaults from the main script and pasted them into the display script

the display script (or template) now looks like this at the top

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

just means you have to open up the main script even less

the only thing you might want to open the main script for is to update any short conditions settings

it would require a bit more work to move those than just cut and paste

Offline

#270 2012-01-23 02:39:49

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

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

it would be pretty easy to expand the range of data options to include all kinds of conversions

including an option to convert between F and C and so have the ability to show both in the same display

Offline

#271 2012-01-23 02:52:30

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!

mrpeachy wrote:

re conversions
yes, certainly possible

your probably sorry you asked big_smile

Nope, glad actually ... it means mt wife will be able to understand the weather instead of me converting for her.  big_smile

mrpeachy wrote:

ive made a small change to the main and display scripts in the v9000 archive
http://dl.dropbox.com/u/19008369/v9000.tar.gz

i cut out the lines where you set defaults from the main script and pasted them into the display script

the display script (or template) now looks like this at the top

just means you have to open up the main script even less

the only thing you might want to open the main script for is to update any short conditions settings

it would require a bit more work to move those than just cut and paste

Can I just cut and paste out of mine and into the template?  Seems easier than dnloading and setting everything up again ... or are there other changes in place?

I'm working on t9002 mow:
9eb95b171202082.jpg
For the first time since I have met LUA it's actually making "some sense" I'm a million miles away from writing one, but this venture with the template has cleared some of the dense fog.


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

Offline

#272 2012-01-23 03:05:12

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

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

yes, you can just cut and paste, nothing else has changed

you dont even have to download the update, just cut the defaults out of the main script and paste them in the top of the template, in the same place in the weather_script function that i showed above and you have the same as the update smile

actually thats not quite true
i added a few additional settings to complete

--set here what you want to have for units, or set "" for nothing
local visibility_unit="mi"
local wind_speed_unit="mph"
local wind_gust_unit="mph"
local ceiling_unit="ft"

if you want the ability to define those built in units then you will need the updated main script (v9000.lua) but these changes dont affect the template in any way

Last edited by mrpeachy (2012-01-23 03:09:29)

Offline

#273 2012-01-23 03:11:05

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

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

what other unit options would people want?

HPa for pressure

anything else?

i could make kmh and knots available for current weather wind speed
(dont understand why why they give the 3 types for forecast days but only mph for current)

Last edited by mrpeachy (2012-01-23 04:14:50)

Offline

#274 2012-01-23 13:39:03

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!

mrpeachy wrote:

here are a couple of v9000 displays
nowplus8.jpg

Do you still have this layout available?


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

Offline

Be excellent to each other!

#275 2012-01-23 13:57:08

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!

mrpeachy wrote:

what other unit options would people want?

HPa for pressure

anything else?

i could make kmh and knots available for current weather wind speed
(dont understand why why they give the 3 types for forecast days but only mph for current)

baromerter: inches to hPa or mb (they are the same)
wind: mph, kmh, beaufort, metrespersecond (mps) (yes, it's used)
visibility: m (miles), k (kilometre)

Did not realize that about wind, it is strange that kmh and knots are avail for forecast days.

BTW you can go directly from inches to hPa without the pass through pascals.

How do I convert from mph to knots (or m/s)?

     1 mile per hour = 0.869 international nautical mile per hour (knot)
     1 mile per hour = 1.609 kilometers per hour
     1 mile per hour = 0.4470 meter per second
     1 knot = 1.852 kilometers per hour
     1 knot = 0.5144 meter per second
     1 meter per second = 3.6 kilometers per hour


How do I convert from inches of mercury to mb (or hPa)?
     1 inch of mercury = 25.4 mm of mercury = 33.86 millibars
     = 33.86 hectoPascals

     1 foot = 0.3048 meter
     1 international nautical mile = 1.1508 statute miles
     = 1.852 kilometers = .99933 U.S nautical mile (obsolete)
     1° latitude = 69.047 statute miles = 60 nautical miles
     = 111.12 kilometers

     For longitude the conversion is the same as latitude except the value is multiplied by the cosine of the latitude.

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

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