Bonjour à tous !
Je ne parviens pas à faire tourner le script .lua, je n'arrive pas à comprendre pourquoi car le chemin dans le conkyrc me parait juste.
Voici mon image et mes erreurs reçues:
Merci pour vos lumières
conkyrc:
# -- Conky settings -- #
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
# -- Window specifications -- #
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
minimum_size 280 100
maximum_width 310
alignment tm
gap_x 0
gap_y 20
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
# -- Text settings -- #
use_xft yes
xftfont MaiandraGD:size=24
xftalpha 0.4
uppercase no
default_color 8b8b8b
# -- Declaration template -- #
template0 ${image ~/conky/script/images/\1 -p \2 -s \3} # -- images fond -- #
template1 ${lua Meteo_\1 \2 \3 \4 \5} # -- gestion météo --#
template2 ${lua_parse Meteo_\1 \2 \3 \4 60 \5} # -- icones météo -- \2=repertoir icones \3=position \4=taille \5=jour (pour les prévisions) #
template3 ${lua Lune_\1}
lua_load ~/conky/script/meteo.lua
TEXT
#### Lancement du script récupérant les données météo ####
${template1 Maj http://www.accuweather.com/fr/ch/horgen/316407/weather-forecast/316407 5 1800 /tmp}
#### Premier cadre ####
##### Heure #####
${voffset -16}${font LED_mono :style=Medium:size=60}${color 434343}${goto 30}${time %H}${goto 140}${time %M}${font LED_mono :size=25:style=Medium}${color 808080}${goto 235}${time %S}
##### Date #####
${voffset 8}${color yellow}${font URW Chancery L:style=Bold:size=18}${alignc}${exec date "+%A %d %B %Y"|sed 's/^.\| [a-z]/\U&/g'}
##### ville #####
${voffset -10}${goto 5}${color ffe595}${template1 Ville}
##### température actuelle #####
${voffset -10}${goto 15}${font URW Chancery L:style=Bold:size=30}${if_match ${template1 TempAct}<5}${color lightblue}${blink ${template1 TempAct}°}${else}${color white}${template1 TempAct}°${endif}
##### Affichage conditions météo #####
${voffset -25}${font URW Chancery L:style=Bold:size=12}${color white}${alignc}${template1 CondMeteo}
##### Affichage infos vent ######
${voffset -60}${color ffe595}${font Helvetica LT Std:style=Bold:size=10}${alignr}${template1 VentDirP}
${color ffe595}${font Helvetica LT Std:style=Bold:size=10}${goto 200}${template1 VentForce} km/h
#### Second cadre ####
##### Affichage Probabilité de précipitations Jour/Nuit #####
${voffset 47}${color lightwhite}${font Helvetica LT Std:style=Bold:size=10}${goto 40}${template1 Jour_ProbOrage 1}${goto 220}${template1 Nuit_ProbOrage 1}
##### Affichage temperature #####
${voffset 7}${goto 75}${template1 Jour_Temp 1}°${goto 250}${template1 Nuit_Temp 1}°
##### Affichage conditions météo #####
${voffset -8}${font Bitstream Vera Sans Mono:style=condensed:size=6}${color grey} ${template1 Jour_CondMeteo1 1}${goto 170} ${template1 Nuit_CondMeteo1 1}
${template1 Jour_CondMeteo2 1}${goto 170} ${template1 Nuit_CondMeteo2 1}
##### Affichage lunaison #####
${voffset -65}${font URW Chancery L:style=Bold:size=10}${color FEEFEF}${alignc}${template3 ephemerides1}
${voffset -5}${alignc}${template3 ephemerides2}
#### troisieme cadre ####
${voffset 52}${font Ubuntu :size=10:style=bold}${color lightwhite}${goto 35}${template1 Jour_ProbOrage 2}${goto 105}${template1 Jour_ProbOrage 3}${goto 170}${template1 Jour_ProbOrage 4}${goto 235}${template1 Jour_ProbOrage 5}
##### Affichage temperature #####
${voffset 14}${goto 27}${font Ubuntu :size=10:style=bold}${color red}${template1 Jour_Temp 2}°${color white}/${color lightblue}${template1 Nuit_Temp 2}°${goto 97}${color red}${template1 Jour_Temp 3}°${color white}/${color lightblue}${template1 Nuit_Temp 3}°${goto 167}${color red}${template1 Jour_Temp 4}°${color white}/${color lightblue}${template1 Nuit_Temp 4}°${goto 237}${color red}${template1 Jour_Temp 5}°${color white}/${color lightblue}${template1 Nuit_Temp 5}°
##### Affichage vitesse du vent #####
${voffset 8}${font Ubuntu :size=9:style=bold}${color ffe595}${goto 27}${template1 Jour_VentForce 2}${font Ubuntu :size=6:style=bold} km/h${goto 97}${voffset -4}${font Ubuntu :size=9:style=bold}${template1 Jour_VentForce 3}${font Ubuntu :size=6:style=bold} km/h${goto 167}${voffset -4}${font Ubuntu :size=9:style=bold}${template1 Jour_VentForce 4}${font Ubuntu :size=6:style=bold} km/h${goto 237}${voffset -4}${font Ubuntu :size=9:style=bold}${template1 Jour_VentForce 5}${font Ubuntu :size=6:style=bold} km/h
#### quatrième cadre ####
##### Heure mise à jour #####
${voffset 40}${font URW Chancery L:style=Bold:size=16}${alignc}Dernière mise à jour : ${template1 Heure}h${template1 Minute}
#### Affichage des cadres utilisés dans le conky ####
${voffset -935}
#### premier cadre ####
${template0 base.png 0,40 280x170}
${template0 flip_bg.png 24,10 100x100}
${template0 flip_bg.png 134,10 100x100}
#### Second cadre ####
${template0 base.png 0,245 280x50}
#### troisieme cadre ####
${template0 base.png 0,320 280x40}
${template0 base180.png 0,358 280x40}
#### quatrieme cadre ####
${template0 base1.png 0,420 280x30}
#### icones premier cadre ####
${template2 IconeM ~/conky/meteo+lune/icones/base 74,120 132x79}
${template2 IconeV ~/conky/meteo+lune/icones/base/vent 235,130 44x44}
#### icones Second cadre ####
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base -15,205 132x79 1}
${template2 Nuit_IconeM ~/conky/meteo+lune/icones/base 160,205 132x79 1}
${image /tmp/lune.png -p 111,210 -s 63x63 -f 60}
#### icones troisieme cadre ####
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 0,295 86x52 2}
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 68,295 86x52 3}
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 133,295 86x52 4}
${template2 Jour_IconeM ~/conky/meteo+lune/icones/base 200,295 86x52 5}
${template2 Jour_IconeV ~/conky/meteo+lune/icones/base/vent 0,344 30x30 2}
${template2 Jour_IconeV ~/conky/meteo+lune/icones/base/vent 70,344 30x30 3}
${template2 Jour_IconeV ~/conky/meteo+lune/icones/base/vent 140,344 30x30 4}
${template2 Jour_IconeV ~/conky/meteo+lune/icones/base/vent 210,344 30x30 5}
${template2 Nuit_IconeM ~/conky/meteo+lune/icones/base 0,375 86x52 2}
${template2 Nuit_IconeM ~/conky/meteo+lune/icones/base 68,375 86x52 3}
${template2 Nuit_IconeM ~/conky/meteo+lune/icones/base 133,375 86x52 4}
${template2 Nuit_IconeM ~/conky/meteo+lune/icones/base 200,375 86x52 5}
meteo.cfg:
#Repertoire de travail
DirShell="$HOME/conky/script"
#Copier votre adresse Accuweather ici
address="http://www.accuweather.com/fr/ch/horgen/316407/weather-forecast/316407"
#Prévision sur n jour (de 1 à 15)
periode=5
script meteo.lua de Didier-
T:
-- Créé par Didier-T (forum.ubuntu-fr.org)
-- Nécessite imagemagique
require "io"
--Formatage des accents
function accent(ligne)
ligne = string.gsub(ligne, "ô", "ô")
ligne = string.gsub(ligne, "é", "é")
ligne = string.gsub(ligne, "è", "è")
ligne = string.gsub(ligne, "à", "à")
ligne = string.gsub(ligne, "ç", "ç")
ligne = string.gsub(ligne, "ê", "ê")
ligne = string.gsub(ligne, "ö", "ö")
ligne = string.gsub(ligne, "î", "î")
ligne = string.gsub(ligne, "ï", "ï")
ligne = string.gsub(ligne, "û", "û")
ligne = string.gsub(ligne, "ü", "ü")
ligne = string.gsub(ligne, "'", "'")
return ligne
end
--Prévision
function prevision(fichier)
local iconej, iconen, Tmax, Tmin, Tmaxr, Tminr, ProbPrecj, ProbPrecn, Vdirj, Vdirn, Vforcej, Vforcen, Vrafalesj, Vrafalesn, Descriptifj, Descriptifn, UV, ProbOragesj, ProbOragesn, Precj, Precn, Pluiej, Pluien, Neigej, Neigen, Verglasj, Verglasn, Datej, LeverSoleil, CoucherSoleil, parse, pos1, pos2, LeverSoleilH, LeverSoleilM, CoucherSoleilH, CoucherSoleilM
local file = assert(io.open(fichier, "rb") )
local line = file:read()
for line in file:lines() do
if string.find(line, '"details"') ~= nil then
parse = 1
end
if parse == 1 then
if string.find(line, 'class="icon i-') ~= nil then
pos1 = string.find(line, '-')+1
pos2 = string.find(line, '"', pos1)-1
if iconej == nil then
iconej = string.sub(line, pos1, pos2)
else
iconen = string.sub(line, pos1, pos2)
end
elseif string.find(line, '"temp"') ~= nil then
pos1 = string.find(line, '"temp"')+7
pos2 = string.find(line, '<', pos1)-1
if Tmax == nil then
Tmax = string.sub(line, pos1, pos2)
else
Tmin = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'RealFeel®') ~= nil then
pos1 = string.find(line, ';')+2
pos2 = string.find(line, '&', pos1)-1
if Tmaxr == nil then
Tmaxr = string.sub(line, pos1, pos2)
else
Tminr = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'cipitations ') ~= nil then
pos1 = string.find(line, 's ')+2
pos2 = string.find(line, '<', pos1)-1
if ProbPrecj == nil then
ProbPrecj = string.sub(line, pos1, pos2)
ProbPrecj = ProbPrecj:match("(%d+)")
else
ProbPrecn = string.sub(line, pos1, pos2)
ProbPrecn = ProbPrecn:match("(%d+)")
end
elseif string.find(line, 'var d') ~= nil then
pos1 = string.find(line, "'")+1
pos2 = string.find(line, "'", pos1)-1
if Vdirj == nil then
Vdirj = string.gsub(string.sub(line, pos1, pos2), "W", "O")
else
Vdirn = string.gsub(string.sub(line, pos1, pos2), "W", "O")
end
elseif string.find(line, 'var s') ~= nil then
pos1 = string.find(line, "'")+1
pos2 = string.find(line, "'", pos1)-1
if Vforcej == nil then
Vforcej = string.sub(line, pos1, pos2)
Vforcej = Vforcej:match("(%d+)")
else
Vforcen = string.sub(line, pos1, pos2)
Vforcen = Vforcen:match("(%d+)")
end
elseif string.find(line, 'Rafales') ~= nil then
pos1 = string.find(line, ">")+2
pos2 = string.find(line, " ", pos1)-1
if Vrafalesj == nil then
Vrafalesj = string.sub(line, pos1, pos2)
Vrafalesj = Vrafalesj:match("(%d+)")
else
Vrafalesn = string.sub(line, pos1, pos2)
Vrafalesn = Vrafalesn:match("(%d+)")
end
elseif Descriptifn == nil and string.find(line, '<p>') ~= nil then
pos1 = string.find(line, ">")+1
pos2 = string.find(line, "<", pos1)-1
if Descriptifj == nil then
Descriptifj = string.sub(line, pos1, pos2)
Descriptifj = accent(Descriptifj)
else
Descriptifn = string.sub(line, pos1, pos2)
Descriptifn = accent(Descriptifn)
end
elseif string.find(line, 'UV') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, "<", pos1)-1
if UV == nil then
UV = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'Orages') ~= nil then
pos1 = string.find(line, '">')+2
pos2 = string.find(line, "<", pos1)-1
if ProbOragesj == nil then
ProbOragesj = string.sub(line, pos1, pos2)
ProbOragesj = ProbOragesj:match("(%d+)")
else
ProbOragesn = string.sub(line, pos1, pos2)
ProbOragesn = ProbOragesn:match("(%d+)")
end
elseif string.find(line, 'cipitations:') ~= nil then
pos1 = string.find(line, 'g>')+2
pos2 = string.find(line, " ", pos1)-1
if Precj == nil then
Precj = string.sub(line, pos1, pos2)
else
Precn = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'Pluie:') ~= nil then
pos1 = string.find(line, '">')+2
pos2 = string.find(line, " ", pos1)-1
if Pluiej == nil then
Pluiej = string.sub(line, pos1, pos2)
else
Pluien = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'Neige:') ~= nil then
pos1 = string.find(line, '">')+2
pos2 = string.find(line, " ", pos1)-1
if Neigej == nil then
Neigej = string.sub(line, pos1, pos2)
else
Neigen = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'Verglas:') ~= nil then
pos1 = string.find(line, '">')+2
pos2 = string.find(line, " ", pos1)-1
if Verglasj == nil then
Verglasj = string.sub(line, pos1, pos2)
else
Verglasn = string.sub(line, pos1, pos2)
end
elseif string.find(line, 'Historique ') ~= nil then
pos1 = string.find(line, '- ')+2
pos2 = string.find(line, "<", pos1)-1
Datej = string.sub(line, pos1, pos2)
local j, m, a = Datej:match("(%d+)/(%d+)/(%d+)")
Datej = os.time{year=a, month=m, day=j, hour=0}
elseif string.find(line, 'start"') ~= nil then
pos1 = string.find(line, '>')+1
pos2 = string.find(line, "<", pos1)-1
if LeverSoleil == nil then
LeverSoleil = string.sub(line, pos1, pos2)
LeverSoleilH, LeverSoleilM = LeverSoleil:match("(%d+):(%d+)")
end
elseif string.find(line, 'finish"') ~= nil then
pos1 = string.find(line, '>')+1
pos2 = string.find(line, "<", pos1)-1
if CoucherSoleil == nil then
CoucherSoleil = string.sub(line, pos1, pos2)
CoucherSoleilH, CoucherSoleilM = CoucherSoleil:match("(%d+):(%d+)")
CoucherSoleilH = CoucherSoleilH+12
end
end
end
end
io.close(file)
-- Retour condition jour, condition nuit, infos journée
return { Icone=iconej, CondMeteo=Descriptifj, Temp=Tmax, TempRes=Tmaxr, VentDir=Vdirj, VentForce=Vforcej, VentRafales=Vrafalesj, Uv=Uv, ProbOrage=ProbOragesj, NivPrec=Precj, QPluie=Pluiej, QNeige=Neigej }, { Icone=iconen, CondMeteo=Descriptifn, Temp=Tmin, TempRes=Tminr, VentDir=Vdirn, VentForce=Vforcen, VentRafales=Vrafalesn, ProbOrage=ProbOragesn, NivPrec=Precn, QPluie=Pluien, QNeige=Neigen }, { Jour=Datej, LeverSoleil=LeverSoleil, LeverSoleilH=LeverSoleilH, LeverSoleilM=LeverSoleilM, CoucherSoleil=CoucherSoleil, CoucherSoleilH=CoucherSoleilH, CoucherSoleilM=CoucherSoleilM }
end
--Infos condition courante
function current(fichier)
local pos1, pos2, icone, Descriptif, Temp, Tempr, Vdir, Vforce, Humidite, Pression, Couverture, UV, Rosee, Prec, Visibilite, Date, Ville, latitude, longitude, geo, parse
local file = assert(io.open(fichier, "rb") )
local line = file:read()
geo = nil
parse = nil
for line in file:lines() do
if string.find(line, '"details"') ~= nil then
parse = 1
end
if parse == 1 then
if string.find(line, 'class="icon i-') ~= nil then
pos1 = string.find(line, '-')+1
pos2 = string.find(line, '"', pos1)-1
icone = string.sub(line, pos1, pos2)
elseif string.find(line, '"cond"') ~= nil then
pos1 = string.find(line, '"cond"')+7
pos2 = string.find(line, '<', pos1)-1
Descriptif = string.sub(line, pos1, pos2)
Descriptif = accent(Descriptif)
pos1 = string.find(line, '"temp"')+7
pos2 = string.find(line, '<', pos1)-1
Temp = string.sub(line, pos1, pos2)
pos1 = string.find(line, '; ')+2
pos2 = string.find(line, '<', pos1)-1
Tempr = string.sub(line, pos1, pos2)
elseif string.find(line, 'var d') ~= nil then
pos1 = string.find(line, "'")+1
pos2 = string.find(line, "'", pos1)-1
Vdir = string.gsub(string.sub(line, pos1, pos2), "W", "O")
elseif string.find(line, 'var s') ~= nil then
pos1 = string.find(line, "'")+1
pos2 = string.find(line, "'", pos1)-1
Vforce = string.sub(line, pos1, pos2)
Vforce = Vforce:match("(%d+)")
elseif string.find(line, 'Humidit') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, "<", pos1)-1
Humidite = string.sub(line, pos1, pos2)
Humidite = Humidite:match("(%d+)")
elseif string.find(line, 'Pression') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, "k", pos1)-1
Pression = string.sub(line, pos1, pos2)*10
elseif string.find(line, 'Couverture') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, "<", pos1)-1
Couverture = string.sub(line, pos1, pos2)
Couverture = Couverture:match("(%d+)")
elseif string.find(line, 'UV') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, "<", pos1)-1
UV = string.sub(line, pos1, pos2)
elseif string.find(line, 'Point') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, "&", pos1)-1
Rosee = string.sub(line, pos1, pos2)
elseif string.find(line, 'cipitations') ~= nil then
pos1 = string.find(line, "g>")+2
pos2 = string.find(line, " ", pos1)-1
Prec = string.sub(line, pos1, pos2)
elseif string.find(line, 'Visibilit') ~= nil then
pos1 = string.find(line, 'g>')+2
pos2 = string.find(line, " ", pos1)-1
Visibilite = string.sub(line, pos1, pos2)
elseif string.find(line, 'Historique ') ~= nil then
pos1 = string.find(line, '- ')+2
pos2 = string.find(line, "<", pos1)-1
Date = string.sub(line, pos1, pos2)
local j, m, a = Date:match("(%d+)/(%d+)/(%d+)")
Date = os.time{year=a, month=m, day=j, hour=0}
elseif string.find(line, 'latitude') ~= nil then
geo = 1
elseif string.find(line, 'title" ') ~= nil then
pos1 = string.find(line, 'e="')+3
pos2 = string.find(line, '"', pos1)-1
if Ville == nil then
Ville = string.sub(line, pos1, pos2)
end
if geo ~= nil then
if latitude == nil then
latitude = string.sub(line, pos1, pos2)
end
if longitude == nil then
longitude = string.sub(line, pos1, pos2)
end
end
end
end
end
io.close(file)
--Retour condition courante
return {Icone=icone, Cond=Descriptif, Temp=Temp, Tempr=Tempr, VentDir=Vdir, VentForce=Vforce, Humidite=Humidite, Pression=Pression, CouvNuage=Couverture, Uv=UV, PointRosee=Rosee, QPrec=Prec, Visibilite=Visibilite, Date=Date, Ville=Ville, latitude=latitude, longitude=longitude}
end
--Infos lunaison
function lune(r)
s = "${exec wget -q -O "..r.."/cal_lunaire http://www.calendrier-lunaire.net/}"
conky_parse( s )
local file = assert(io.open(r..'/cal_lunaire', "rb") )
local line = file:read()
for line in file:lines() do
local pos1 = string.find(line, '">')
local pos2 = string.find(line, "</", pos1)
if string.find(line, "ephemerides_1") ~= nil then
pos1 = string.find(line, 'src="')
pos2 = string.find(line, '" /')
s = "${exec wget -q -O "..r.."/lune.png http://www.calendrier-lunaire.net/"..string.sub(line, pos1+5, pos2-1).."}"
conky_parse( s )
conky_parse( "${exec convert "..r.."/lune.png -transparent '#091a2a' "..r.."/lune.png}" )
elseif string.find(line, "<h2>") ~= nil then
ephemerides1 = string.sub(line, pos1+2, pos2-1)
local pos3 = string.find(line, 'n>', pos2)
local pos4 = string.find(line, "</", pos2+3)
ephemerides2 = string.sub(line, pos3+3, pos4-1)
ephemerides = ephemerides1.." "..ephemerides2
elseif string.find(line, "Visibilit") ~= nil then
Visibilite = string.sub(line, pos1+2, pos2-3)
elseif string.find(line, "Phases") ~= nil then
Phases = string.gsub(string.sub(line, pos1+2, pos2-1), "é", "é")
local pos3 = string.find(Phases, ',')
Phases1 = string.sub(Phases, 0, pos3-1)
Phases2 = string.sub(Phases, pos3+2)
elseif string.find(line, "Noeud lunaire") ~= nil then
local a = string.gsub(string.sub(line, pos1+2, pos2-1), "Dans ", "")
Noeud_lunaire = string.gsub(a, " Jours", "")
elseif string.find(line, "Apog") ~= nil then
local a = string.gsub(string.sub(line, pos1+2, pos2-1), "Dans ", "")
Apogee = string.gsub(a, " Jours", "")
elseif string.find(line, "Perig") ~= nil then
local a = string.gsub(string.sub(line, pos1+2, pos2-1), "Dans ", "")
Perigee = string.gsub(a, " Jours", "")
elseif string.find(line, "Distance") ~= nil then
Distance = string.sub(line, pos1+2, pos2-4)
elseif string.find(line, "Age de la Lune") ~= nil then
Age = string.sub(line, pos1+2, pos2-1)
elseif string.find(line, "La Lune se") ~= nil then
local a = string.sub(line, pos1+2, pos2-1)
pos3 = string.find(a, ":")
Lever_LuneHeure = string.sub(a, 0, pos3-1)
Lever_LuneMinute = string.sub(a, pos3+1)
local pos3 = string.find(line, '">', pos2)
local pos4 = string.find(line, "</", pos3+3)
a = string.sub(line, pos3+2, pos4-1)
local pos5 = string.find(a, ":")
Coucher_LuneHeure = string.sub(a, 0, pos5-1)
Coucher_LuneMinute = string.sub(a, pos5+1)
elseif string.find(line, "eclipse_partielle") ~= nil then
local pos3 = string.find(line, '">', pos1+3)
local a = string.gsub(string.sub(line, pos3+2, pos2-1), "<br />", "à")
Eclipse_partielle = a
elseif string.find(line, "eclipse_totale") ~= nil then
local pos3 = string.find(line, '">', pos1+3)
local a = string.gsub(string.sub(line, pos3+2, pos2-1), "<br />", "à")
Eclipse_total = a
end
end
io.close(file)
end
--Détermine icône vent
function direction_vent(i)
if i == "Calme" then
return 0
elseif i == "N" then
return 10
elseif i == "NNE" then
return 11
elseif i == "NE" then
return 12
elseif i == "ENE" then
return 13
elseif i == "E" then
return 14
elseif i == "ESE" then
return 15
elseif i == "SE" then
return 16
elseif i == "SSE" then
return 17
elseif i == "S" then
return 2
elseif i == "SSO" then
return 3
elseif i == "SO" then
return 4
elseif i == "OSO" then
return 5
elseif i == "O" then
return 6
elseif i == "ONO" then
return 7
elseif i == "NO" then
return 8
elseif i == "NNO" then
return 9
else
return 1
end
end
--Renvoi vent direction pleine en toute lettre
function vent_plein(d)
local b
if string.len(d) == 1 then
if string.find(d, "N") ~= nil then
b = string.gsub(d, "N", "Nord")
elseif string.find(d, "S") ~= nil then
b = string.gsub(d, "S", "Sud")
elseif string.find(d, "E") ~= nil then
b = string.gsub(d, "E", "Est")
elseif string.find(d, "O") ~= nil then
b = string.gsub(d, "O", "Ouest")
end
else
b = d
end
return b
end
--Détermine l'icône vent en tenant conte de la force du vent
function icone_vent(d, fo)
local f = tonumber(fo)
local n
if f <= 25 then
n = d
elseif f <= 50 then
n = d + 17
elseif f <= 75 then
n = d + 34
elseif f >= 76 then
n = d + 51
end
if n <= 9 then
n = "0"..n
end
return n..".png"
end
--Découpage descriptions sur deux lignes
function decoupage(d)
local l1, l2, n, p1, p2, n1, n2, l1b, l2b
if string.len(d) >= 22 then
n = math.ceil(string.len(d)/2)
p1 = string.find(d, " ", n)
p2 = string.find(d, " ", -n)
if p1 >= p2 then
l1b = string.sub(d, 1, p2-1)
l2b = string.sub(d, p2+1)
else
l1b = string.sub(d, 1, p1-1)
l2b = string.sub(d, p1+1)
end
else
l1b = d
l2b = " "
end
n1 = math.ceil((22 - string.len(l1b))/2)
l1 = string.rep(" ", n1)..l1b
n2 = math.ceil((22 - string.len(l2b))/2)
l2 = string.rep(" ", n2)..l2b
--Retour information avec espaces ligne 1 & 2 et sans espaces ligne 1 & 2
return l1, l2, l1b, l2b
end
--Traitement infos prévisions (15 jours max) jour 1 = aujourd'hui
function jour_n(a, j, x)
local i = j+x
local s = '${exec wget -q --load-cookies '..Rep..'/cookie -O '..Rep..'/details'..j..' '..a..'?day='..i..'}'
conky_parse( s )
conditionJour[j], conditionNuit[j], InfoJour[j] = prevision(Rep..'/details'..j)
if conditionJour[j].VentDir == "CLM" then
conditionJour[j].VentDir = "Calme"
conditionJour[j].VentForce = "0"
end
conditionJour[j].VentIcone = icone_vent(direction_vent(conditionJour[j].VentDir), conditionJour[j].VentForce)
conditionJour[j].VentPlein = vent_plein(conditionJour[j].VentDir)
conditionJour[j].CondMeteo1, conditionJour[j].CondMeteo2, conditionJour[j].CondMeteo1se, conditionJour[j].CondMeteo2se = decoupage(conditionJour[j].CondMeteo)
if conditionNuit[j].VentDir == "Calme" then
conditionNuit[j].VentForce = "0"
end
conditionNuit[j].VentIcone = icone_vent(direction_vent(conditionNuit[j].VentDir), conditionNuit[j].VentForce)
conditionNuit[j].VentPlein = vent_plein(conditionNuit[j].VentDir)
conditionNuit[j].CondMeteo1, conditionNuit[j].CondMeteo2, conditionNuit[j].CondMeteo1se, conditionNuit[j].CondMeteo2se = decoupage(conditionNuit[j].CondMeteo)
end
--Mise à jour condition courante et initialisation météo
function conky_Meteo_Maj(cmd, jours, delais, r)
local l = cmd:match("(%d+)")
if t == nil then
local bar, bar1
local l1 = string.gsub(cmd, '/'..l, "" )
local b = 1
while bar1 == nil do
b = b+1
bar1 = string.find(l1, '/', -b)
end
l1 = string.sub(l1, bar1+1)
Rep = r.."/"..l1.."/"..l
if os.execute("cd "..Rep) ~= 0 then
os.execute("mkdir "..r.."/"..l1)
os.execute("mkdir "..Rep)
-- debug
-- os.execute("mkdir "..Rep.."/hold")
-- os.execute("> "..Rep.."/hold/resultat")
-- fin degug
end
t = os.time()-delais
start = 1
conditionJour = {}
conditionNuit = {}
InfoJour = {}
conditioncourante = {}
end
if tonumber(delais) <= os.difftime(os.time(), t) then
if os.execute("ping -c 1 www.google.com") == 0 then
conditioncourante.Date = nil
while conditioncourante.Date == nil do
local s = '${exec wget -q --save-cookies '..Rep..'/cookie -O '..Rep..'/curr_cond_raw '..cmd..'/current-weather/'..l..'}'
conky_parse( s )
conditioncourante = current(Rep.."/curr_cond_raw")
if conditioncourante.VentDir == "CLM" then
conditioncourante.VentDir = "Calme"
conditioncourante.VentForce = "0"
end
conditioncourante.VentIcone = icone_vent(direction_vent(conditioncourante.VentDir), conditioncourante.VentForce)
conditioncourante.VentPlein = vent_plein(conditioncourante.VentDir)
conditioncourante.CondMeteo1, conditioncourante.CondMeteo2, conditioncourante.CondMeteo1se, conditioncourante.CondMeteo2se = decoupage(conditioncourante.Cond)
t = os.time()
if 14400 <= os.difftime(os.time(), t) or start == 1 then
start = 2
local addr_week = cmd..'/daily-weather-forecast/'..l
jour_n(addr_week, 1, 0)
if conditioncourante.Date == InfoJour[1].Jour then
for i = 2,jours do jour_n(addr_week, i, 0) end
else
for i = 1,jours do jour_n(addr_week, i, 1) end
end
end
end
lune(r)
end
collectgarbage()
-- lancement debug
-- debug(jours)
end
return " "
end
--Retour d'information météo
--Condition courrante
function conky_Meteo_IconeM(r, p, s, f)
if os.date("%H%M", os.time()) >= InfoJour[1].CoucherSoleilH..InfoJour[1].CoucherSoleilM and os.date("%H%M", os.time()) <= InfoJour[1].LeverSoleilH..InfoJour[1].LeverSoleilM then
return "${image "..r.."/nuit/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
else
return "${image "..r.."/jour/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
end
function conky_Meteo_TempRes()
return conditioncourante.Tempr
end
function conky_Meteo_TempAct()
return conditioncourante.Temp
end
function conky_Meteo_CondMeteo()
return conditioncourante.Cond
end
function conky_Meteo_CondMeteo1()
return conditioncourante.CondMeteo1
end
function conky_Meteo_CondMeteo2()
return conditioncourante.CondMeteo2
end
function conky_Meteo_CondMeteo1se()
return conditioncourante.CondMeteo1se
end
function conky_Meteo_CondMeteo2se()
return conditioncourante.CondMeteo2se
end
function conky_Meteo_VentDir()
return conditioncourante.VentDir
end
function conky_Meteo_VentDirP()
return conditioncourante.VentPlein
end
function conky_Meteo_VentForce()
return conditioncourante.VentForce
end
function conky_Meteo_IconeV(r, p, s, f)
return "${image "..r.."/"..conditioncourante.VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_Humidite()
return tonumber(conditioncourante.Humidite)
end
function conky_Meteo_Rose()
return tonumber(conditioncourante.PointRosee)
end
function conky_Meteo_Pression()
return tonumber(conditioncourante.Pression)
end
function conky_Meteo_Visibilite()
return tonumber(conditioncourante.Visibilite)
end
function conky_Meteo_Date(format)
return os.date(format, conditioncourante.Date)
end
function conky_Meteo_Ville()
return conditioncourante.Ville
end
function conky_Meteo_CouvNuage()
return conditioncourante.CouvNuage
end
function conky_Meteo_Uv()
return conditioncourante.Uv
end
function conky_Meteo_QPrec()
return conditioncourante.QPrec
end
function conky_Meteo_latitude()
return conditioncourante.latitude
end
function conky_Meteo_longitude()
return conditioncourante.longitude
end
function conky_Meteo_Heure()
return os.date("%H", t)
end
function conky_Meteo_Minute()
return os.date("%M", t)
end
--Prévision Météo
--Jour
function conky_Meteo_Jour_CondMeteo(j)
return conditionJour[tonumber(j)].CondMeteo
end
function conky_Meteo_Jour_CondMeteo1(j)
return conditionJour[tonumber(j)].CondMeteo1
end
function conky_Meteo_Jour_CondMeteo2(j)
return conditionJour[tonumber(j)].CondMeteo2
end
function conky_Meteo_Jour_CondMeteo1se(j)
return conditionJour[tonumber(j)].CondMeteo1se
end
function conky_Meteo_Jour_CondMeteo2se(j)
return conditionJour[tonumber(j)].CondMeteo2se
end
function conky_Meteo_Jour_Temp(j)
return tonumber(conditionJour[tonumber(j)].Temp)
end
function conky_Meteo_Jour_TempRes(j)
return tonumber(conditionJour[tonumber(j)].TempRes)
end
function conky_Meteo_Jour_VentDir(j)
return conditionJour[tonumber(j)].VentDir
end
function conky_Meteo_Jour_VentDirP(j)
return conditionJour[tonumber(j)].VentP
end
function conky_Meteo_Jour_VentForce(j)
return tonumber(conditionJour[tonumber(j)].VentForce)
end
function conky_Meteo_Jour_VentRafales(j)
return tonumber(conditionJour[tonumber(j)].VentRafales)
end
function conky_Meteo_Jour_Uv(j)
return tonumber(conditionJour[tonumber(j)].Uv)
end
function conky_Meteo_Jour_ProbOrage(j)
return tonumber(conditionJour[tonumber(j)].ProbOrage)
end
function conky_Meteo_Jour_NivPrec(j)
return tonumber(conditionJour[tonumber(j)].NivPrec)
end
function conky_Meteo_Jour_QPluie(j)
return tonumber(conditionJour[tonumber(j)].QPluie)
end
function conky_Meteo_Jour_QNeige(j)
return tonumber(conditionJour[tonumber(j)].QNeige)
end
function conky_Meteo_Jour_IconeM(r, p, s, f, j)
return "${image "..r.."/jour/"..conditionJour[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_Jour_IconeV(r, p, s, f, j)
return "${image "..r.."/"..conditionJour[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Nuit
function conky_Meteo_Nuit_CondMeteo(j)
return conditionNuit[tonumber(j)].CondMeteo
end
function conky_Meteo_Nuit_CondMeteo1(j)
return conditionNuit[tonumber(j)].CondMeteo1
end
function conky_Meteo_Nuit_CondMeteo2(j)
return conditionNuit[tonumber(j)].CondMeteo2
end
function conky_Meteo_Nuit_CondMeteo1se(j)
return conditionNuit[tonumber(j)].CondMeteo1se
end
function conky_Meteo_Nuit_CondMeteo2se(j)
return conditionNuit[tonumber(j)].CondMeteo2se
end
function conky_Meteo_Nuit_Temp(j)
return tonumber(conditionNuit[tonumber(j)].Temp)
end
function conky_Meteo_Nuit_TempRes(j)
return tonumber(conditionNuit[tonumber(j)].TempRes)
end
function conky_Meteo_Nuit_VentDir(j)
return conditionNuit[tonumber(j)].VentDir
end
function conky_Meteo_Nuit_VentDirP(j)
return conditionNuit[tonumber(j)].VentP
end
function conky_Meteo_Nuit_VentForce(j)
return tonumber(conditionNuit[tonumber(j)].VentForce)
end
function conky_Meteo_Nuit_VentRafales(j)
return tonumber(conditionNuit[tonumber(j)].VentRafales)
end
function conky_Meteo_Nuit_ProbOrage(j)
return tonumber(conditionNuit[tonumber(j)].ProbOrage)
end
function conky_Meteo_Nuit_NivPrec(j)
return tonumber(conditionNuit[tonumber(j)].NivPrec)
end
function conky_Meteo_Nuit_QPluie(j)
return tonumber(conditionNuit[tonumber(j)].QPluie)
end
function conky_Meteo_Nuit_QNeige(j)
return tonumber(conditionNuit[tonumber(j)].QNeige)
end
function conky_Meteo_Nuit_IconeM(r, p, s, f, j)
return "${image "..r.."/nuit/"..conditionNuit[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_Nuit_IconeV(r, p, s, f, j)
return "${image "..r.."/"..conditionNuit[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Infos sur la journée
function conky_Meteo_Jour(format, j)
return os.date(format, InfoJour[tonumber(j)].Jour)
end
function conky_Meteo_HLeverSoleil(j)
return InfoJour[tonumber(j)].LeverSoleilH
end
function conky_Meteo_MLeverSoleil(j)
return InfoJour[tonumber(j)].LeverSoleilM
end
function conky_Meteo_HCoucherSoleil(j)
return InfoJour[tonumber(j)].CoucherSoleilH
end
function conky_Meteo_MCoucherSoleil(j)
return InfoJour[tonumber(j)].CoucherSoleilM
end
--Lunaison
function conky_Lune_ephemerides()
return ephemerides
end
function conky_Lune_ephemerides1()
return ephemerides1
end
function conky_Lune_ephemerides2()
return ephemerides2
end
function conky_Lune_Visibilite()
return Visibilite
end
function conky_Lune_Phases()
return Phases
end
function conky_Lune_Phases1()
return Phases1
end
function conky_Lune_Phases2()
return Phases2
end
function conky_Lune_Noeudlunaire()
return Noeud_lunaire
end
function conky_Lune_Apogee()
return Apogee
end
function conky_Lune_Perigee()
return Perigee
end
function conky_Lune_Distance()
return Distance
end
function conky_Lune_Age()
return Age
end
function conky_Lune_HLeverLune()
return Lever_LuneHeure
end
function conky_Lune_MLeverLune()
return Lever_LuneMinute
end
function conky_Lune_HCoucherLune()
return Coucher_LuneHeure
end
function conky_Lune_MCoucherLune()
return Coucher_LuneMinute
end
function conky_Lune_EclipsePartielle()
return Eclipse_partielle
end
function conky_Lune_EclipseTotal()
return Eclipse_total
end
--fonction debug
function debug(jours)
os.execute("mkdir "..Rep.."/hold/"..Heure..Minute)
local file = assert(io.open(Rep.."/hold/resultat", "a+") )
file:write ("\nHeure condition = ", conky_Meteo_Heure(), ":", conky_Meteo_Minute())
file:write ("\nTempérature ressentie = ", conky_Meteo_TempRes())
file:write ("\nTempérature actuelle = ", conky_Meteo_TempAct())
file:write ("\nCondition météo = ", conky_Meteo_CondMeteo())
file:write ("\nDirection du vent = ", conky_Meteo_VentDir())
file:write ("\nForce du vent = ", conky_Meteo_VentForce())
file:write ("\nHumidité = ", conky_Meteo_Humidite())
file:write ("\nPoint de rosé = ", conky_Meteo_Rose())
file:write ("\nPression = ", conky_Meteo_Pression())
file:write ("\nEvolution pression = ", conky_Meteo_EvoPression())
file:write ("\nVisibilité = ", conky_Meteo_Visibilite())
file:write ("\nHeure lever soleil = ", conky_Meteo_HLeverSoleilC())
file:write ("\nHeure coucher soleil = ", conky_Meteo_HCoucherSoleilC())
file:write ("\nDate = ", conky_Meteo_Date())
file:write ("\nVille = ", conky_Meteo_Ville())
for j = 1,jours do
file:write ("\n\nPrévision pour le ", conky_Meteo_Jour(j))
file:write ("\nPrévision jour ", j, "\nCondition météo = ", conky_Meteo_Jour_CondMeteo(j))
file:write ("\nTempérature = ", conky_Meteo_Jour_Temp(j))
file:write ("\nTempérature ressentie = ", conky_Meteo_Jour_TempRes(j))
file:write ("\nDirection du vent = ", conky_Meteo_Jour_VentDir(j))
file:write ("\nForce du vent = ", conky_Meteo_Jour_VentForce(j))
file:write ("\nIndice UV = ", conky_Meteo_Jour_Uv(j))
file:write ("\nProbabilité orage = ", conky_Meteo_Jour_ProbOrage(j))
file:write ("\nNiveau de précipitation = ", conky_Meteo_Jour_NivPrec(j))
file:write ("\nQuantitée de pluie = ", conky_Meteo_Jour_QPluie(j))
file:write ("\nQuantitée de neige = ", conky_Meteo_Jour_QNeige(j))
file:write ("\nDurée précipitation = ", conky_Meteo_Jour_MDureePrec(j))
file:write ("\nDurée pluie = ", conky_Meteo_Jour_MDureePluie(j))
file:write ("\n\nPrévision Nuit\nCondition météo = ", conky_Meteo_Nuit_CondMeteo(j))
file:write ("\nTempérature = ", conky_Meteo_Nuit_Temp(j))
file:write ("\nTempérature ressentie = ", conky_Meteo_Nuit_TempRes(j))
file:write ("\nDirection du vent = ", conky_Meteo_Nuit_VentDir(j))
file:write ("\nForce du vent = ", conky_Meteo_Nuit_VentForce(j))
file:write ("\nProbabilité orage = ", conky_Meteo_Nuit_ProbOrage(j))
file:write ("\nNiveau de précipitation = ", conky_Meteo_Nuit_NivPrec(j))
file:write ("\nQuantitée de pluie = ", conky_Meteo_Nuit_QPluie(j))
file:write ("\nQuantitée de neige = ", conky_Meteo_Nuit_QNeige(j))
file:write ("\nDurée précipitation = ", conky_Meteo_Nuit_MDureePrec(j))
file:write ("\nDurée pluie = ", conky_Meteo_Nuit_MDureePluie(j))
os.execute("cp "..Rep..'/details'..j.." "..Rep.."/hold/"..Heure..Minute.."/details"..j)
end
file:write ("\n \n", gcinfo(), "\n\n")
io.close(file)
os.execute("cp "..Rep.."/curr_cond_raw "..Rep.."/hold/"..Heure..Minute.."/curr_cond_raw")
end
bonne journée