#1526 Le 13/11/2012, à 21:05
- Didier-T
Re : [Conky] Alternative à weather.com (2)
Super ça fonctionne très bien cette manip pour renvoyer les retours dans un fichier txt.
J'ai pu corriger certains éléments, voici le résultat l'exécution :
Conky: can't parse X color 'lightwhite' Conky: can't parse X color 'lightwhite' Conky: forked to background, pid is 2411 Conky: desktop window (1400003) is subwindow of root window (14e) Conky: window type - desktop Conky: drawing to created window (0x3a00001) Conky: drawing to double buffer Conky: llua_do_call: function conky_init execution failed: ...uOne/Portable/conky/Meteo_lua/conky/script/meteo.lua:937: bad argument #1 to 'match' (string expected, got nil) date: /home/portable/conky/meteo/CondCour: Aucun fichier ou dossier de ce type Conky: llua_do_call: function conky_Meteo_horsligne execution failed: ...uOne/Portable/conky/Meteo_lua/conky/script/meteo.lua:1013: /home/portable/conky/meteo/CondCour: No such file or directory Conky: llua_getstring: function conky_Meteo_Ville didn't return a string, result discarded Conky: llua_getstring: function conky_Meteo_TempAct didn't return a string, result discarded Conky: failed to parse compare string '<5' Conky: compare failed for expression '<5' Conky: llua_getstring: function conky_Meteo_TempAct didn't return a string, result discarded Conky: llua_getstring: function conky_Meteo_CondMeteo didn't return a string, result discarded Conky: llua_getstring: function conky_Meteo_VentDirP didn't return a string, result discarded Conky: llua_getstring: function conky_Meteo_VentForce didn't return a string, result discarded
Tu peut me montrer le meteo.cfg
Edit : le conkyrc aussi, merci
Dernière modification par Didier-T (Le 13/11/2012, à 21:08)
Hors ligne
#1527 Le 13/11/2012, à 22:05
- sunkart
Re : [Conky] Alternative à weather.com (2)
Le conky est celui fournit dans ton pack conky_rc_lua
# -- 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 desktop
own_window_transparent yes
# own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 50
border_outer_margin 50
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
# -- Déclaration template -- #
template0 ${image ~/conky/script/images/\1 -p \2 -s \3} # -- images fond -- #
template1 ${lua Meteo_\1 \2 \3 \4 \5 \6} # -- gestion météo --#
template2 ${lua_parse Meteo_\1 \2 \3 \4 60 \5} # -- icônes météo -- \2=répertoire icônes \3=position \4=taille \5=jour (pour les prévisions) #
template3 ${lua Lune_\1}
template4 ${lua_parse Images_\1 \2 \3 60 \4} # -- Appelle image -- \2=position \3=taille \4=jour (pour les prévisions) #
lua_load /home/portable/UbuntuOne/Portable/conky/Meteo_lua/conky/script/meteo.lua
lua_startup_hook init /home/portable/UbuntuOne/Portable/conky/Meteo_lua/conky/script/meteo.cfg
TEXT
#### Lancement du script récupérant les données météo ####
${template1 Maj}
#### 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 AM_CondMeteo1 1}${goto 170} ${template1 Noct_CondMeteo1 1}
${template1 AM_CondMeteo2 1}${goto 170} ${template1 Noct_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
##### Affichage Date #####
${voffset 9}${font Ubuntu :size=10:style=bold}${color 522BAF}${goto 20}${template1 Jour %a_%d 2}${goto 90}${template1 Jour %a_%d 3}${goto 155}${template1 Jour %a_%d 4}${goto 220}${template1 Jour %a_%d 5}
#### quatrième cadre ####
##### Heure mise à jour #####
${voffset 15}${color ffe595}${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}
#### troisième cadre ####
${template0 base.png 0,320 280x40}
${template0 base180.png 0,358 280x40}
#### quatrieme cadre ####
${template0 base1.png 0,420 280x30}
#### icônes premier cadre ####
${template2 IconeM ~/conky/meteo/icones 74,120 132x79}
${template2 IconeV ~/conky/meteo/icones/vent 235,130 44x44}
#### icônes Second cadre ####
${template2 AM_IconeM ~/conky/meteo/icones -15,205 132x79 1}
${template2 Noct_IconeM ~/conky/meteo/icones 160,205 132x79 1}
${image /tmp/lune.png -p 111,210 -s 63x63 -f 60}
#### icônes troisième cadre ####
${template2 AM_IconeM ~/conky/meteo/icones 0,295 86x52 2}
${template2 AM_IconeM ~/conky/meteo/icones 68,295 86x52 3}
${template2 AM_IconeM ~/conky/meteo/icones 133,295 86x52 4}
${template2 AM_IconeM ~/conky/meteo/icones 200,295 86x52 5}
${template2 Jour_IconeR ~/conky/meteo/icones/vent 0,344 30x30 2}
${template2 Jour_IconeR ~/conky/meteo/icones/vent 70,344 30x30 3}
${template2 Jour_IconeR ~/conky/meteo/icones/vent 140,344 30x30 4}
${template2 Jour_IconeR ~/conky/meteo/icones/vent 210,344 30x30 5}
${template2 Noct_IconeM ~/conky/meteo/icones 0,375 86x52 2}
${template2 Noct_IconeM ~/conky/meteo/icones 68,375 86x52 3}
${template2 Noct_IconeM ~/conky/meteo/icones 133,375 86x52 4}
${template2 Noct_IconeM ~/conky/meteo/icones 200,375 86x52 5}
Et le meteo.cfg
# Créé par jpdipsy (forum.ubuntu-fr.org)
#Répertoire de sauvegarde
repsauv=~/conky/meteo
#Répertoire temporaire
TempShell=/tmp
#Copier votre adresse Accuweather ici
http://www.accuweather.com/fr/fr/argenteuil/133593/weather-forecast/133593
#Prévision sur n jour (de 1 à 15) moyenne pour la journée
periode=5
#Prévision infos sur la matinée (oui, non)
matinée=oui
#Prévision infos sur la Après Midi (oui, non)
am=oui
#Prévision infos sur la Soirée (oui, non)
soiree=oui
#Prévision infos sur la Nuit (oui, non)
nuit=oui
#Prévision à 8 Heures
Prev8heures=oui
#Palier changement de couleur rose des vents (Km/h)
Palier=20
#Temps entre les mises à jour prévision (secondes)
update=300
Cyril
Hors ligne
#1528 Le 14/11/2012, à 06:34
- Didier-T
Re : [Conky] Alternative à weather.com (2)
@ sunkart,
Tu nous a trouvé une nouvelle panne
dans le meteo.cfg tu a eut la main un peut lourde quand tu a voulu modifier l'adresse web.
voici meteo.cfg corrigé.
# Créé par jpdipsy (forum.ubuntu-fr.org)
#Répertoire de sauvegarde
repsauv=~/conky/meteo
#Répertoire temporaire
TempShell=/tmp
#Copier votre adresse Accuweather ici
web=http://www.accuweather.com/fr/fr/argenteuil/133593/weather-forecast/133593
#Prévision sur n jour (de 1 à 15) moyenne pour la journée
periode=5
#Prévision infos sur la matinée (oui, non)
matinée=oui
#Prévision infos sur la Après Midi (oui, non)
am=oui
#Prévision infos sur la Soirée (oui, non)
soiree=oui
#Prévision infos sur la Nuit (oui, non)
nuit=oui
#Prévision à 8 Heures
Prev8heures=oui
#Palier changement de couleur rose des vents (Km/h)
Palier=20
#Temps entre les mises à jour prévision (secondes)
update=300
en fait tu avais écrasé la balise web
Hors ligne
#1529 Le 14/11/2012, à 13:55
- Phyllinux
Re : [Conky] Alternative à weather.com (2)
@ ragamatrix (et les autres assidus du forum) :
C'est bon pour le conky Chronos de Sector11.
Voici le résultat :
J'ai francisé un maximum, sauf les données appelées par les scripts Lua, car là, il faut rentrer complètement dans le code pour tout remettre en français.
2 petites choses :
Impossible pour moi d'utiliser la police Digital-7. Je n'arrive pas à m'expliquer pourquoi, lorsque je l'installe sur ma machine, les 'barres' du haut des caractères sont tronquées. En utilisant la visionneuse de police, j'ai droit à un 'H' au lieu du 'A' car la barre du haut du A (en police digital) n'est pas traitée. J'abandonne donc l'idée de cette police, et je suis repassée sous une police Ubuntu de base, qui fait l'affaire.
Je trouve dommage que pour la nouvelle lune, l'icône appelée soit un 'blanc' (en fait le fichier png affiché est un fichier transparent). J'ai bien essayé de lui faire afficher une autre image, en prenant celle de la lune qui est traitée par meteo.lua, mais cela ne fonctionne pas. J'ai bien cependant renommé le fichier new_moon.png et placé dans le bon répertoire, mais cela n'a aucun effet. Si quelqu'un connait une astuce pour faire afficher une image de la nouvelle lune dans le chrono, je suis preneur, car dans l'état actuel, je trouve qu'il manque quelque chose.
Je me suis amusé à comparer les données fournies par les 2 sites météo, avec un conky de meteo.lua. Si pour les conditions du moment, c'est pratiquement la même chose, en revanche en ce qui concerne les prévisions, il y a de grosses différences sur les 3 jours à venir. Ex: Vendredi m'est annoncé comme brumeux par Intellicast, alors qu'Accuweather m'annonce 'Nuages et soleil, quelques averses (20% de probabilité de précipitations)'. Et pour Samedi, Intellicast m’annonce une journée pluvieuse, quand Accuweather me donne un magnifique 0% de probabilité de pluie !
Bon, je vais maintenant me mettre à la réalisation de ce conky sur ma session Voyager. Pour le moment, les chronos ne s'affichent pas du tout, seule la météo tourne correctement. Et en terminal, pas de message d'erreur. Il faut que je reprenne tout à la base.
@ jpdipsy : J'attends avec impatience ta super production hollywoodienne pour pouvoir enfin restaurer mon fond d'écran XPlanetFX avec météo intégrée. Pour le moment, j'ai arrêté de me creuser les méninges, et cela ne fonctionne pas correctement. Et si je lance juste l'affichage de la couche 'conky', le processeur prend feu !!!
The ship is sinking normally...
Hors ligne
#1530 Le 14/11/2012, à 14:09
- Didier-T
Re : [Conky] Alternative à weather.com (2)
Bonjour a tous,
pour ma part j'ai fait le contraire de Phyllinux, a savoir simplifié au maximum les infos affiché par le conky, pour ne récupérer que le chronograph, que je trouve tout a fait splendide tel qu'il est, après si l'on souhaite y mettre des infos météo, il suffit d'ajouter meteo.lua et de placé les affichage ou ont le souhaite.
Quand je serai entièrement satisfait des modification apporté au script le mettrais a disposition sur le forum.
Hors ligne
#1531 Le 14/11/2012, à 14:39
- Sector11
Re : [Conky] Alternative à weather.com (2)
@ ragamatrix (et les autres assidus du forum) :
C'est bon pour le conky Chronos de Sector11.
Voici le résultat :
plus français :
~/v9000/v9000.lua
lines: 124-128
else--neswtext,tsuffix,uvindextext,moonphases,daynames,dayshort,monthnames,monthshort
dayshort={Monday="Mon",Tuesday="Tue",Wednesday="Wed",Thursday="Thu",Friday="Fri",Saturday="Sat",Sunday="Sun"}
monthshort={January="Jan",February="Feb",March="Mar",April="Apr",May="May",June="Jun",July="Jul",August="Aug",September="Sep",October="Oct",November="Nov",December="Dec"}
end--end if translate =1
--#########################################################################
Lines 602-603
now={}
monthlong={Jan="January",Feb="February",Mar="March",Apr="April",May="May",Jun="June",Jul="July",Aug="August",Sep="September",Oct="October",Nov="November",Dec="December"}
local s,f,tnow=string.find(nowweather,"<div style=\"float:right;color:#666;\"> As of ([%d%p%a%s]*) %(Local Time%)")
Use:
xftfont Digital\-7:size=16
TEXT
${font Digital\-7:size=12}
Conky Conky PitStop | #! Conky | Music x18 Apps | Interactive Conky
Conky Weather: v9000 LUA | Teo's x4 Sites | Arclance
Hors ligne
#1532 Le 14/11/2012, à 17:20
- jpdipsy
Re : [Conky] Alternative à weather.com (2)
Toutes, tous
Comme promis voici une petite vidéo "sans grande valeur artistique" mais moi j'aime bien
La vidéo
A pluche
Hors ligne
#1533 Le 14/11/2012, à 17:55
- Phyllinux
Re : [Conky] Alternative à weather.com (2)
@ jpdipsy :
Excellente la vidéo.
Un peu rapide peut-être comme tutoriel si ce n'est pas accompagné d'un lisez-moi, mais c'est de la graine de Lucas que nous avons là. Prêt pour un épisode inédit de la Guerre des Etoiles (ou des Planètes).
@ Didier-T et ragamatrix :
Pour m'éviter de chercher pendant 1 H, qui pourrait me dire dans quel fichier et à quelle ligne est déclarée l'aiguille qui indique le jour de la semaine dans le chrono, car je veux en changer la couleur qui ne ressort pas actuellement sur mon projet en cours ?
Merci
The ship is sinking normally...
Hors ligne
#1534 Le 14/11/2012, à 18:13
- ragamatrix
Re : [Conky] Alternative à weather.com (2)
@Phyllinux
Hand peut aussi vouloir dire Aiguille en Anglais.Et week tu connais je pense que c'est là.
Ligne101
-- DRAW HAND -- snaps to current day of week
local hand_length=30
local day_number=tonumber(os.date("%w"))
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
local hand_width=2
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
-- ### END DIAL B #########################################
BRAVO jpdipsy !
Jolie démo
Dernière modification par ragamatrix (Le 14/11/2012, à 18:16)
Hors ligne
#1535 Le 14/11/2012, à 18:19
- ragamatrix
Re : [Conky] Alternative à weather.com (2)
Meteo-Lua+v9000; deux tendances+"xplanet old school"
Meteo-Lua+v9000
Hors ligne
#1536 Le 15/11/2012, à 04:59
- Sector11
Re : [Conky] Alternative à weather.com (2)
sa c'est une très bonne nouvelle, plus de fuite sur le script Chronograph_full.lua, merci pour l'info Sector11, et merci à mrpeachy.
You are welcome. I will pass your thanks to mrpeachy.
Conky Conky PitStop | #! Conky | Music x18 Apps | Interactive Conky
Conky Weather: v9000 LUA | Teo's x4 Sites | Arclance
Hors ligne
#1537 Le 15/11/2012, à 10:44
- Phyllinux
Re : [Conky] Alternative à weather.com (2)
Bonjour a tous,
pour ma part j'ai fait le contraire de Phyllinux, a savoir simplifié au maximum les infos affiché par le conky, pour ne récupérer que le chronograph, que je trouve tout a fait splendide tel qu'il est, après si l'on souhaite y mettre des infos météo, il suffit d'ajouter meteo.lua et de placé les affichage ou ont le souhaite.
http://pix.tdct.org/upload/thumb/1352898465.png
Quand je serai entièrement satisfait des modification apporté au script le mettrais a disposition sur le forum.
Rebondissant sur ton idée, j'ai fait une insertion de meteo lua sur le chrono de Sector 11.
Il n'y a plus qu'une chose sur laquelle je galère : Sector 11 aime bien réaliser ses conkys sur un fond sombre semi transparent.
Perso, je préfère avoir un conky transparent. Or, je vois que tu as justement isolé le chrono sans le fond rectangulaire sur lequel était plaqué le conky, avec juste le cercle du chrono en légèrement sombre, mais toujours semi transparent.
Pourrais tu me donner ton 'Avant TEXT' pour que je vois ce que tu as utilisé comme paramètres, pour finaliser mon conky.
Merci
The ship is sinking normally...
Hors ligne
#1538 Le 15/11/2012, à 11:28
- sunkart
Re : [Conky] Alternative à weather.com (2)
@ sunkart,
Tu nous a trouvé une nouvelle panne
Le boulet que je suis ...
Je teste ça ce soir.
Cyril
Hors ligne
#1539 Le 15/11/2012, à 12:17
- Didier-T
Re : [Conky] Alternative à weather.com (2)
@ Phyllinux,
je te donne sa ce soir.
Hors ligne
#1540 Le 15/11/2012, à 12:27
#1541 Le 15/11/2012, à 13:57
- ragamatrix
Re : [Conky] Alternative à weather.com (2)
@Phyllinux
${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4}
${lua conky_draw_bg 175 0 60 353 353 0x000000 0.4}
${lua conky_draw_bg 60 115 90 120 120 0x000000 0.4}
${lua conky_draw_bg 55 40 180 110 110 0x000000 0.4}
${lua conky_draw_bg 55 205 180 110 110 0x000000 0.4}
${lua conky_draw_bg 60 115 260 120 120 0x000000 0.4}
Commente ça et tu n'auras plus le rectangle de fond semi-transparent:
#${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4}
Très jolie mise en place du météo-lua, tu as le sens de l’esthétique.
Aussi full meteo-lua : full_meteo_lua
Sinon j'ai aussi un peu modifié le Chronograph en mettant le vent au milieu pour avoir un meilleure lisibilité :
windcenter
Dernière modification par ragamatrix (Le 15/11/2012, à 14:10)
Hors ligne
#1542 Le 15/11/2012, à 14:28
- Phyllinux
Re : [Conky] Alternative à weather.com (2)
@Phyllinux
${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4} ${lua conky_draw_bg 175 0 60 353 353 0x000000 0.4} ${lua conky_draw_bg 60 115 90 120 120 0x000000 0.4} ${lua conky_draw_bg 55 40 180 110 110 0x000000 0.4} ${lua conky_draw_bg 55 205 180 110 110 0x000000 0.4} ${lua conky_draw_bg 60 115 260 120 120 0x000000 0.4}
Commente ça et tu n'auras plus le rectangle de fond semi-transparent:
#${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4}
Très jolie mise en place du météo-lua, tu as le sens de l’esthétique.
@ Ragamatrix
Merci pour le compliment sur le conky, mais il est vrai que je me débrouille mieux en mise en forme qu'en codage. Et c'est pour cela que je fais régulièrement des montages sur l'effet à obtenir, et que je demande à Didier-T de m'écrire le code pour y arriver. Et c'est vrai aussi que je suis assez content de voir que le conky de base de Météo Lua (avec la montre digitale et l’agencement des données météo) était aussi mon premier conky réalisé avec ce script.
Merci aussi pour l'info sur la manière de supprimer le fond.
J'avais déjà essayé en mettant cette ligne en commentaire, car j'avais compris à quoi correspondaientt ces différentes lignes, mais cela n'a pas l'effet escompté.
Alors, j'ai continué mes recherches, et je suis arrivé à la solution, en jouant sur 2 paramètres, et non pas un seul.
Tout d'abord, la ligne Avant TEXT dans les LUA settings :
lua_load ~/conky/multi/LUA/draw-bg.lua
lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.2
J'ai ramené le pourcentage d'alpha du dernier chiffre à 0 au lieu de 0.2 (soit 20%)
Et dans un deuxième temps, j'ai effectivement joué de la même manière sur la valeur de la ligne que tu m'indiques dans la partie Après TEXT :
${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4} #Fond conky
En ramenant le dernier chiffre d'alpha à 0% au lieu de 40% (soit 0 au lieu de 0.4)
Le fait de jouer sur un seul de ces paramètres ne m'avait pas permis d'avoir l'effet voulu.
Et cela fonctionne ! La preuve par l'image :
@ Didier-T :
Je suis toujours preneur de ta solution, si tu es arrivé à ce même résultat en utilisant un autre procédé.
Si cela intéresse quelqu'un je posterai une archive avec les différents fichiers, et un petit lisez-moi (non encore rédigé) pour guider pas à pas les néophytes découvrant pour la première fois Meteo Lua.
The ship is sinking normally...
Hors ligne
#1543 Le 15/11/2012, à 18:45
- Phyllinux
Re : [Conky] Alternative à weather.com (2)
@ Didier-T :
Je viens de relever un bug dans la V4.7 de meteo.lua.
Ayant un conky lancé actuellement, j'ai des conditions qui me disent que le 'ciel (est) très nuageux'.
Or la commande CouvNuage fait afficher 1%
En me rendant sur le site de Accuweather, je constate qu'il est indiqué une couverture nuageuse de 75%.
Et je n'arrive pas à voir sur le site à quoi peut correspondre ce chiffre de 1.
Comme il n'y a plus de sortie fichier des données remontées, je ne suis pas en mesure d'aller plus loin dans le diagnostic.
Peux tu regarder cela ?
The ship is sinking normally...
Hors ligne
#1544 Le 15/11/2012, à 19:02
- Didier-T
Re : [Conky] Alternative à weather.com (2)
Si si il y a toujours une sortie fichier, sinon en hors ligne sa ne fonctionne pas.
je regarderai sa un peut plus tard (enfin peut être pas aujourd'hui).
le conky que tu me demandai plus tôt.
# To use #! in a conky use: ${exec echo '#!'}
# ${font DS\-Digital:bold:size=24}
# OS: ${pre_exec lsb_release -d | cut -c14-50}
# killall conky && conky -c ~/Conky/S11_Chronograph.conky &
# Thank you - mrpeachy
### Begin Window Settings ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager,sticky
#own_window_colour gray
own_window_class Conky
own_window_title Chronograph
# 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 normal
# own_window_argb_visual yes
### When ARGB visuals are enabled, this use this to modify the alpha value
### Use: own_window_type normal
### Use: own_window_transparent no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
# own_window_argb_value 0
minimum_size 350 350 #Taille minimum (px) ; largeur / hauteur
maximum_width 350 350 #Largeur maximum (px)
gap_x 0 #15 ### left &right
gap_y 100 ### up & down
alignment tm #ml
#################################################### End Window Settings ###
### Font Settings ##########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont CorporateMonoExtraBold:size=9
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# 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 gray
default_outline_color black
default_color DCDCDC #220 220 220 Gainsboro
color0 8FBC8F #143 188 143 DarkSeaGreen
color1 778899 #119 136 153 LightSlateGray
color2 FF8C00 #255 140 0 DarkOrange
color3 7FFF00 #127 255 0 Chartreuse
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 00FFFF # 0 255 255 Cyan
color8 FFFF00 #255 255 0 Yellow
color9 B22222 #178 34 34 FireBrick
##################################################### End Color Settings ###
### Borders Section ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background none
# 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 256
# 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
# Maximum size of user text buffer, i.e. layout below TEXT line in config file
# (default is 16384 bytes)
# max_user_text 16384
# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
# temperature_unit Fahrenheit
lua_load ~/chronos_dossier/conky35-Chrono-comp/LUA/draw-bg.lua
lua_load ~/chronos_dossier/conky35-Chrono-comp/LUA/Chronograph_full.lua
lua_draw_hook_post main
update_interval 1
TEXT
${voffset 200}${color red}${font caviar dreams:style=Bold:size=5}${alignc}TOP CPU
${font Consolas:size=5}${color green2}${alignc}${top name 1}${top cpu 1} %
${alignc}${color lightgrey}${top name 2}${top cpu 2} %
${alignc}${color lightgrey}${top name 3}${top cpu 3} %
${alignc}${color lightgrey}${top name 4}${top cpu 4} %
${voffset 3}${color red}${font caviar dreams:style=Bold:size=5}${alignc}TOP RAM
${font Consolas:size=5}${color red}${alignc}${top_mem name 1}${top_mem mem 1} %
${alignc}${color lightgrey}${top_mem name 2}${top_mem mem 2} %
${alignc}${color lightgrey}${top_mem name 3}${top_mem mem 3} %
${alignc}${color lightgrey}${top_mem name 4}${top_mem mem 4} %
#${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4}
${lua conky_draw_bg 175 0 0 350 350 0x000000 0.3}
${lua conky_draw_bg 60 115 30 120 120 0x000000 0.2}
${lua conky_draw_bg 59 31 116 118 118 0x000000 0.2}
${lua conky_draw_bg 59 201 116 118 118 0x000000 0.2}
${lua conky_draw_bg 59 116 201 118 118 0x000000 0.2}
Comme tu peut le voir j'ai fais un peut de ménage.
Hors ligne
#1545 Le 15/11/2012, à 19:51
- Phyllinux
Re : [Conky] Alternative à weather.com (2)
Si si il y a toujours une sortie fichier, sinon en hors ligne sa ne fonctionne pas.
je regarderai sa un peut plus tard (enfin peut être pas aujourd'hui).le conky que tu me demandai plus tôt.
.../... ### Miscellaneous Section ################################################## # Boolean value, if true, Conky will be forked to background when started. background none .../... TEXT .../... #${lua conky_draw_bg 20 0 55 0 590 0x000000 0.4} .../...
Comme tu peut le voir j'ai fais un peut de ménage.
J'ai également bien 'éclairci' le conky.
Je n'ai gardé ci dessus que les points qui m'intéressent :
Le fait de passer à NONE l'arrière plan, cela me semble effectivement logique, et de mettre en commentaire la ligne qui traite de la transparence du fond dans la partie après TEXT.
Ma solution a également fonctionné, sans prendre exactement la même logique de cheminement.
Pour la sortie fichier, effectivement, elle existe, mais plus sous la forme de document TXT, mais de document HTML, et le fait de l'éditer ouvre une page web, moins explicite, et je n'y ai pas trouvé la valeur qui posait problème, en l’occurrence ce fameux '1'.
The ship is sinking normally...
Hors ligne
#1546 Le 15/11/2012, à 20:35
- Didier-T
Re : [Conky] Alternative à weather.com (2)
@ Phyllinux,
regarde dans le chemin de sauvegarde de ton meteo.cfg (balise repsauv) tu y retrouveras tous les fichiers textes avec les données qui vont bien.
Hors ligne
#1547 Le 15/11/2012, à 21:21
- Didier-T
Re : [Conky] Alternative à weather.com (2)
Bonsoir,
Je viens de finir avec le chronographe, voici le résultat
comme vous pouvez le constaté, j'ai supprimé quelques aiguilles (pour y coller d'autre choses)
Voici le script modifié de chronograph_full.lua
--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
21 Jun 2012 - Chronograph modifications by Sector11
22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
12 Nov 2012 - memory leak plugged - mrpeachy
14 Nov 2012 - Personnalisation - Didier-T (forum Ubuntu.fr)
use in conkyrc
lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT
]]
require 'cairo'
--Position et taille horloge
local init={
center_x=175,
center_y=175,
radius=170, -- do not touch
lang="French", --English or Spanish or French
hour=12, --12 or 24
second=true, --true or false
line=false, --hand secondes true or false
handday=false, --hand day true or false
handdaynum=false, --hand day number true or false
handmonth=false, --hand month true or false
color=0xFF0000, --color for day, day number and month if none hand
alpha=1 --alpha for day, day number and month if none hand
}
local colr, colg, colb, cola=rgb_to_r_g_b(init.color,init.alpha)
function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
-- ########################################################
-- SETTINGS AREA
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")
local clock_type_A=init.hour -- Large Main 24 HR Clock
-- ###### CLOCK SETTINGS ##################################
-- SET BORDER OPTIONS FOR "CLOCKS" ########################
local clock_border_width=0
-- set color and alpha for clock border
local cbr,cbg,cbb,cba=1,1,1,1 -- full opaque white
-- gap from clock border to minute marks
local b_to_m=1
-- ########################################################
-- ### START DIAL B ### Top - Week Day Names Dial #########
-- DIAL POSITION FOR TEXT
local center_x=init.center_x
local center_y=init.center_y-85
local radius=50
-- FONT
cairo_select_font_face (cr, "freeserif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 11)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",} end -- English
if init.lang == "Spanish" then text_days={"Dom","Lun","Mar","Mie","Jue","Vie","Sab",} end -- Spanish
if init.lang == "French" then text_days={"Dim","Lun","Mar","Mer","Jeu","Ven","Sam",} end -- French
local day_number=tonumber(os.date("%w"))
if init.handday == true then
for i=1,7 do
-- work out points
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=35
for i=1,7 do
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current day of week
local hand_length=30
local point=(math.pi/180)*((360/7)*(day_number))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
local hand_width=2
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
else
for i=1,7 do
-- work out points
if day_number == i-1 then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,1)
end
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=35
for i=1,7 do
if day_number == i-1 then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,1)
end
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
-- ### END DIAL B #########################################
-- ########################################################
-- ### START DIAL C ### Right - Month Names Dial ##########
-- DIAL POSITION FOR TEXT
local center_x=init.center_x+85
local center_y=init.center_y
local radius=45
-- FONT
cairo_select_font_face (cr, "freeserif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 11)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",} end -- English
if init.lang == "Spanish" then text_days={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic",} end -- Spanish
if init.lang == "French" then text_days={"Jan","Fév","Mar","Avr","Mai","Jui","Jul","Aôu","Sep","Oct","Nov","Déc",} end -- French
local this_month=tonumber(os.date("%m"))
if init.handmonth == true then
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=32
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current month
local hand_length=28 --radius for this calculation
local point=(math.pi/180)*((360/12)*(this_month-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
else
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,1)
end
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=32
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,1)
end
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
-- ### END CLOCK C ########################################
-- ########################################################
-- ### START DIAL D ### Left - Day Numbers Dial ###########
-- GET NUMBER OF DAYS IN CURRENT MONTH
-- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
if init.hour == 12 then
febdaynum=tonumber((os.difftime(t1,t2))/(12*60*60))
else
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
end
-- MONTH TABLE
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
-- TEXT positioning
local center_x=init.center_x-85
local center_y=init.center_y
local radius=50
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 10)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
local this_day=tonumber(os.date("%d"))
if init.handdaynum == true then
for i=1,number_days do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
--only print even numbers
if math.mod(i, 2) == 0 then
--set text when even
text=string.format("%02d",i) --formats numbers to double digits
else
--set text when odd
text=""
end--odd even matching
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=40
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- DRAW HAND -- snaps to current DAY
local hand_length=35--radius for this calculation
local point=(math.pi/180)*((360/number_days)*(this_day-1))
local x=0+hand_length*(math.sin(point))
local y=0-hand_length*(math.cos(point))
cairo_move_to (cr,center_x,center_y)
cairo_line_to (cr,center_x+x,center_y+y)
cairo_stroke (cr)
else
for i=1,number_days do
if this_day == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,1)
end
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
--only print even numbers
if math.mod(i, 2) == 0 then
--set text when even
text=string.format("%02d",i) --formats numbers to double digits
else
--set text when odd
text=""
end--odd even matching
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=40
for i=1,number_days do
if this_day == i then
cairo_set_source_rgba (cr,colr, colg, colb, cola)
else
cairo_set_source_rgba (cr,1,1,1,1)
end
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
-- ### END CLOCK D ########################################
-- ########################################################
-- ### START CLOCK E ######################################
-- MARKS AROUND CLOCK E -- Bottom - 12 HR Clock
local number_marks_E=12
-- set mark length
local m_length_E=0
-- set mark width
local m_width_E=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,0,1-- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK E HOUR HAND
-- set length of hour hand
hh_length_E=25
-- set hour hand width
hh_width_E=2
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,0,1-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK E MINUTE HAND SETUP
-- set length of minute hand
mh_length_E=35
-- set minute hand width
mh_width_E=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,0,1-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK E SECOND HAND SETUP
-- set length of seconds hand
sh_length_E=32
-- set hour hand width
sh_width_E=1
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
shr,shg,shb,sha=1,0,0,1-- fully opaque red
-- CLOCK E ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=45
clock_centerx=init.center_x
clock_centery=init.center_y+85
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_E
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_E)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR SECOND MARKS
for i=1,number_marks_E do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_E))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line-- MARKS AROUND CLOCK A
cairo_stroke (cr)
end-- of for loop
-- SET MARKS ##############################################
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=init.hour
-- set mark length
local m_length_A=0
-- set mark width
local m_width_A=0
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,1 -- opaque white
-- SETUP HOUR HANDS #######################################
-- CLOCK A HOUR HAND
-- set length of hour hand
hh_length_A=130
-- set hour hand width
hh_width_A=3
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
hhr,hhg,hhb,hha=1,1,1,.5-- fully opaque white
-- SETUP MINUTE HANDS #####################################
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=145
-- set minute hand width
mh_width_A=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
mhr,mhg,mhb,mha=1,1,1,.5-- fully opaque white
-- SETUP SECOND HANDS #####################################
-- CLOCK A SECOND HAND SETUP
-- set length of seconds hand
sh_length_A=150
-- set hour hand width
sh_width_A=2
-- set hour hand line cap
sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
shr,shg,shb,sha=1,0,0,1-- fully opaque red
-- CLOCK A ###### 12 HR TIME ##############################
-- CLOCK SETTINGS
clock_radius=200
clock_centerx=init.center_x
clock_centery=init.center_y
-- DRAWING CODE
-- DRAW BORDER
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_A)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end-- of for loop
-- HOUR MARKS
-- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A))-- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
--cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_cap (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds just as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
--cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_source_rgba (cr,169/255,169/255,169/255,1)
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- DRAW SECOND HAND
--[[
-- calculate degrees for each second
sec_degs=seconds*6
-- set radius to calculate hand points
radius=sh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of seconds hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))BOLD
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes
cairo_set_line_width (cr,sh_width_A)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap (cr, sh_cap)
cairo_stroke (cr)
]]
-- ####################################################################
local center_x=init.center_x
local center_y=init.center_y
local radius=init.radius-5
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 15)
cairo_set_source_rgba (cr,1,1,1,1) --(cr,194/255,204/255,255/255,1) -- (cr,1,1,1,1)
-- TABLE OF TEXT -- in order
if init.hour == 12 then
text_days={"00","01","02","03","04","05","06","07","08","09","10","11",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=150
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
if init.hour == 24 then
text_days={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,24 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
--local extents=cairo_text_extents_t:create()
--tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=150
for i=1,24 do
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
-- part of a second hand
--position
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
if init.line == true then
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=140
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=158
local x2=0+radius2*math.sin(arc)
local y2=0-radius2*math.cos(arc)
--draw line connecting points
cairo_move_to (cr, center_x+x1,center_y+y1)
cairo_line_to (cr, center_x+x2, center_y+y2)
cairo_set_source_rgba (cr,255/255,0/255,0/255,1)
cairo_stroke (cr)
end
-- ####################################################################
-- POSITION FOR TEXT HOUR NUMBERS
--affiche secondes
if init.hour == 12 and init.second == true then
text_days={"","1","2","3","4","","6","7","8","9","","11","12","13","14","","16","17","18","19","","21","22","23","24","","26","27","28","29","","31","32","33","34","","36","37","38","39","","41","42","43","44","","46","47","48","49","","51","52","53","54","","56","57","58","59","",}
-- INNER POINTS POSITION, radius smaller than text circle
cairo_set_source_rgba (cr,1,1,1,1)
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
for i=1,60 do
local radius=150
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
if seconds == i-1 then
cairo_set_source_rgba (cr,255/255,0/255,0/255,1)
else
if i-1 == 0 or i-1 == 5 or i-1 == 10 or i-1 == 15 or i-1 == 25 or i-1 == 30 or i-1 == 35 or i-1 == 40 or i-1 == 45 or i-1 == 50 or i-1 == 55 then
cairo_set_source_rgba (cr,1,1,1,1)
else
cairo_set_source_rgba (cr,0,1,1,1)
end
end
cairo_arc (cr,center_x+x,center_y+y,1/2,0,2*math.pi)
cairo_stroke (cr)
end
radius=radius-3
cairo_set_font_size (cr, 10)
for i=1,60 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
if seconds == tonumber(text) then
cairo_set_source_rgba (cr,0,0,1,1)
else
cairo_set_source_rgba (cr,0,1,1,1)
end
--local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
end
-- Fin affiche secondes
-- FONT
-- ########################################################
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
function rgb_to_r_g_b(col,alp) -- ONLY NEED ONE COPY OF THIS FUNCTION
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
si sa inspire quelqu'un
P.S. : bien sur ont peut choisir d'afficher ou non les aiguilles, enfin je vous laisse découvrir
Dernière modification par Didier-T (Le 15/11/2012, à 21:23)
Hors ligne
#1548 Le 15/11/2012, à 21:43
- Didier-T
Re : [Conky] Alternative à weather.com (2)
@ Phyllinux,
en effet, il y avait bien un soucis, situé au niveau de la restitution d'information.
sa devrait fonctionner mieux maintenant.
meteo.lua
-- Créé par Didier-T (forum.ubuntu-fr.org)
-- Nécessite imagemagick http://apt.ubuntu.com/p/imagemagick
require "io"
require "os"
local Version = "v4.8"
local conditionJour = {}
local conditionNuit = {}
local conditionMatin = {}
local conditionAM = {}
local conditionSoiree = {}
local conditionNoct = {}
local InfoJour = {}
local conditioncourante = {}
local huitHeures = {}
local Rep, cmd, jours, matin, apresmidi, soiree, nuit, delais, r, repsauv, l, fichier_init, MAJ, tc, dermodif, VilleAdresse
local Debug = "Problème Info "
--Liste des accents et carractère non pris en charge par les patterns
local pat="%é%è%à%ä%â%ê%ô%ç%É%È%À%Â%Ä%Ê%Ô%Ç"
--Traduction date
function trad_date(d)
local date = d
date = date:gsub("Monday", "Lundi"):gsub("Tuesday", "Mardi"):gsub("Wednesday", "Mercredi"):gsub("Thursday", "Jeudi"):gsub("Friday", "Vendredi"):gsub("Saturday", "Samedi"):gsub("Sunday", "Dimanche")
date = date:gsub("lun", "Lun"):gsub("mar", "Mar"):gsub("mer", "Mer"):gsub("jeu", "Jeu"):gsub("ven", "Ven"):gsub("sam", "Sam"):gsub("dim", "Dim")
date = date:gsub("Mon", "Lun"):gsub("Tue", "Mar"):gsub("Wed", "Mer"):gsub("Thu", "Jeu"):gsub("Fri", "Ven"):gsub("Sat", "Sam"):gsub("Sun", "Dim")
date = date:gsub("January", "Janvier"):gsub("February", "Février"):gsub("March", "Mars"):gsub("April", "Avril"):gsub("May", "Mai"):gsub("June", "Juin"):gsub("July", "Juillet"):gsub("August", "Août"):gsub("September", "Septembre"):gsub("October", "Octobre"):gsub("November", "Novembre"):gsub("December", "Décembre")
date = date:gsub("jan", "Jan"):gsub("fev", "Fév"):gsub("mar", "Mar"):gsub("avr", "Avr"):gsub("mai", "Mai"):gsub("jui", "Jui"):gsub("aou", "Aoû"):gsub("sep", "Sep"):gsub("oct", "Oct"):gsub("nov", "Nov"):gsub("dec", "Déc")
date = date:gsub("Feb", "Fév"):gsub("Apr", "Avr"):gsub("May", "Mai"):gsub("Jun", "Juin"):gsub("Jul", "Juil"):gsub("Aug", "Aoû"):gsub("Dec", "Déc")
return date
end
--Vérifier l'existence d'un fichier
function existe(file)
local a = io.open(file, "r")
local present
if a then
present = true
io.close(a)
else
present = false
end
return present
end
--Formatage des pages web
function string.formatage(ligne)
ligne = ligne:gsub("ô", "ô"):gsub("â", "â"):gsub("é", "é"):gsub("è", "è"):gsub("à", "à"):gsub("ç", "ç"):gsub("ê", "ê"):gsub("ö", "ö"):gsub("î", "î"):gsub("ï", "ï"):gsub("û", "û"):gsub("ü", "ü"):gsub("'", "'"):gsub("Poudreries", "Bourrasques de neige"):gsub("É", "É"):gsub("°",""):gsub("[\n\r]",""):gsub("é", "é")
return ligne
end
--Traitement Huit prochaines heures
function Huit_Heures(web)
local f, i, line, heure1, heure2, heure3, heure4, heure5, heure6, heure7, heure8, icone1, icone2, icone3, icone4, icone5, icone6, icone7, icone8, Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Temp8, TempR1, TempR2, TempR3, TempR4, TempR5, TempR6, TempR7, TempR8, Humi1, Humi2, Humi3, Humi4, Humi5, Humi6, Humi7, Humi8, Pluie1, Pluie2, Pluie3, Pluie4, Pluie5, Pluie6, Pluie7, Pluie8, Neige1, Neige2, Neige3, Neige4, Neige5, Neige6, Neige7, Neige8, Verglas1, Verglas2, Verglas3, Verglas4, Verglas5, Verglas6, Verglas7, Verglas8, Vitesse1, Dir1, Vitesse2, Dir2, Vitesse3, Dir3, Vitesse4, Dir4, Vitesse5, Dir5, Vitesse6, Dir6, Vitesse7, Dir7, Vitesse8, Dir8, UV1, UV2, UV3, UV4, UV5, UV6, UV7, UV8, CouvNuage1, CouvNuage2, CouvNuage3, CouvNuage4, CouvNuage5, CouvNuage6, CouvNuage7, CouvNuage8, Rosee1, Rosee2, Rosee3, Rosee4, Rosee5, Rosee6, Rosee7, Rosee8, h, Dbg
f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A202 'hourly\"' | sed 's/%//g'"))
line=f:read()
i=0
for line in f:lines() do
i=i+1
--Récup. des heures
if i==8 then
heure1=line:match("/>(%d*)</")
elseif i==9 then
heure2=line:match(">(%d*)</")
elseif i==10 then
heure3=line:match(">(%d*)</")
elseif i==11 then
heure4=line:match(">(%d*)</")
elseif i==12 then
heure5=line:match(">(%d*)</")
elseif i==13 then
heure6=line:match(">(%d*)</")
elseif i==14 then
heure7=line:match(">(%d*)</")
elseif i==15 then
heure8=line:match(">(%d*)</")
--Récup. des icones
elseif i==34 then
icone1=line:match("i%p(%a*)\">")
elseif i==37 then
icone2=line:match("i%p(%a*)\">")
elseif i==40 then
icone3=line:match("i%p(%a*)\">")
elseif i==43 then
icone4=line:match("i%p(%a*)\">")
elseif i==46 then
icone5=line:match("i%p(%a*)\">")
elseif i==49 then
icone6=line:match("i%p(%a*)\">")
elseif i==52 then
icone7=line:match("i%p(%a*)\">")
elseif i==55 then
icone8=line:match("i%p(%a*)\">")
--Températures
elseif i==60 then
Temp1=line:match(">([%p%d]*)&")
elseif i==61 then
Temp2=line:match(">([%p%d]*)&")
elseif i==62 then
Temp3=line:match(">([%p%d]*)&")
elseif i==63 then
Temp4=line:match(">([%p%d]*)&")
elseif i==64 then
Temp5=line:match(">([%p%d]*)&")
elseif i==65 then
Temp6=line:match(">([%p%d]*)&")
elseif i==66 then
Temp7=line:match(">([%p%d]*)&")
elseif i==67 then
Temp8=line:match(">([%p%d]*)&")
--Températures ressentie
elseif i==71 then
TempR1=line:match(">([%p%d]*)&")
elseif i==72 then
TempR2=line:match(">([%p%d]*)&")
elseif i==73 then
TempR3=line:match(">([%p%d]*)&")
elseif i==74 then
TempR4=line:match(">([%p%d]*)&")
elseif i==75 then
TempR5=line:match(">([%p%d]*)&")
elseif i==76 then
TempR6=line:match(">([%p%d]*)&")
elseif i==77 then
TempR7=line:match(">([%p%d]*)&")
elseif i==78 then
TempR8=line:match(">([%p%d]*)&")
--Humidité
elseif i==82 then
Humi1=line:match(">(%d*)<")
elseif i==83 then
Humi2=line:match(">(%d*)<")
elseif i==84 then
Humi3=line:match(">(%d*)<")
elseif i==85 then
Humi4=line:match(">(%d*)<")
elseif i==86 then
Humi5=line:match(">(%d*)<")
elseif i==87 then
Humi6=line:match(">(%d*)<")
elseif i==88 then
Humi7=line:match(">(%d*)<")
elseif i==89 then
Humi8=line:match(">(%d*)<")
--Pluie
elseif i==109 then
Pluie1=line:match("v>(%d*)<")
elseif i==110 then
Pluie2=line:match("v>(%d*)<")
elseif i==111 then
Pluie3=line:match("v>(%d*)<")
elseif i==112 then
Pluie4=line:match("v>(%d*)<")
elseif i==113 then
Pluie5=line:match("v>(%d*)<")
elseif i==114 then
Pluie6=line:match("v>(%d*)<")
elseif i==115 then
Pluie7=line:match("v>(%d*)<")
elseif i==116 then
Pluie8=line:match("v>(%d*)<")
--Neige
elseif i==120 then
Neige1=line:match("v>(%d*)<")
elseif i==121 then
Neige2=line:match("v>(%d*)<")
elseif i==122 then
Neige3=line:match("v>(%d*)<")
elseif i==123 then
Neige4=line:match("v>(%d*)<")
elseif i==124 then
Neige5=line:match("v>(%d*)<")
elseif i==125 then
Neige6=line:match("v>(%d*)<")
elseif i==126 then
Neige7=line:match("v>(%d*)<")
elseif i==127 then
Neige8=line:match("v>(%d*)<")
--Verglas
elseif i==131 then
Verglas1=line:match("v>(%d*)<")
elseif i==132 then
Verglas2=line:match("v>(%d*)<")
elseif i==133 then
Verglas3=line:match("v>(%d*)<")
elseif i==134 then
Verglas4=line:match("v>(%d*)<")
elseif i==135 then
Verglas5=line:match("v>(%d*)<")
elseif i==136 then
Verglas6=line:match("v>(%d*)<")
elseif i==137 then
Verglas7=line:match("v>(%d*)<")
elseif i==138 then
Verglas8=line:match("v>(%d*)<")
--Vent
elseif i==159 then
Vitesse1, Dir1=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP1=vent_plein(Dir1)
elseif i==160 then
Vitesse2, Dir2=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP2=vent_plein(Dir2)
elseif i==161 then
Vitesse3, Dir3=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP3=vent_plein(Dir3)
elseif i==162 then
Vitesse4, Dir4=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP4=vent_plein(Dir4)
elseif i==163 then
Vitesse5, Dir5=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP5=vent_plein(Dir5)
elseif i==164 then
Vitesse6, Dir6=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP6=vent_plein(Dir6)
elseif i==165 then
Vitesse7, Dir7=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP7=vent_plein(Dir7)
elseif i==166 then
Vitesse8, Dir8=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
VentP8=vent_plein(Dir8)
--Uv
elseif i==170 then
UV1=line:match(">(%d*)<")
elseif i==171 then
UV2=line:match(">(%d*)<")
elseif i==172 then
UV3=line:match(">(%d*)<")
elseif i==173 then
UV4=line:match(">(%d*)<")
elseif i==174 then
UV5=line:match(">(%d*)<")
elseif i==175 then
UV6=line:match(">(%d*)<")
elseif i==176 then
UV7=line:match(">(%d*)<")
elseif i==177 then
UV8=line:match(">(%d*)<")
--Couverture nuageuse
elseif i==181 then
CouvNuage1=line:match(">(%d*)<")
elseif i==182 then
CouvNuage2=line:match(">(%d*)<")
elseif i==183 then
CouvNuage3=line:match(">(%d*)<")
elseif i==184 then
CouvNuage4=line:match(">(%d*)<")
elseif i==185 then
CouvNuage5=line:match(">(%d*)<")
elseif i==186 then
CouvNuage6=line:match(">(%d*)<")
elseif i==187 then
CouvNuage7=line:match(">(%d*)<")
elseif i==188 then
CouvNuage8=line:match(">(%d*)<")
--Point de rosée
elseif i==192 then
Rosee1=line:match(">([%p%d]*)&")
elseif i==193 then
Rosee2=line:match(">([%p%d]*)&")
elseif i==194 then
Rosee3=line:match(">([%p%d]*)&")
elseif i==195 then
Rosee4=line:match(">([%p%d]*)&")
elseif i==196 then
Rosee5=line:match(">([%p%d]*)&")
elseif i==197 then
Rosee6=line:match(">([%p%d]*)&")
elseif i==198 then
Rosee7=line:match(">([%p%d]*)&")
elseif i==199 then
Rosee8=line:match(">([%p%d]*)&")
end
end
f:close()
huitHeures[1] = {Heure=heure1, Icone=icone1, TempMax=Temp1, TempMaxR=TempR1, VentDir=Dir1, VentForce=Vitesse1, Humidite=Humi1, CouvNuage=CouvNuage1, PointRosee=Rosee1, UV=UV1, Pluie=Pluie1, Neige=Neige1, Verglas=Verglas1, VentP=VentP1}
huitHeures[2] = {Heure=heure2, Icone=icone2, TempMax=Temp2, TempMaxR=TempR2, VentDir=Dir2, VentForce=Vitesse2, Humidite=Humi2, CouvNuage=CouvNuage2, PointRosee=Rosee2, UV=UV2, Pluie=Pluie2, Neige=Neige2, Verglas=Verglas2, VentP=VentP2}
huitHeures[3] = {Heure=heure3, Icone=icone3, TempMax=Temp3, TempMaxR=TempR3, VentDir=Dir3, VentForce=Vitesse3, Humidite=Humi3, CouvNuage=CouvNuage3, PointRosee=Rosee3, UV=UV3, Pluie=Pluie3, Neige=Neige3, Verglas=Verglas3, VentP=VentP3}
huitHeures[4] = {Heure=heure4, Icone=icone4, TempMax=Temp4, TempMaxR=TempR4, VentDir=Dir4, VentForce=Vitesse4, Humidite=Humi4, CouvNuage=CouvNuage4, PointRosee=Rosee4, UV=UV4, Pluie=Pluie4, Neige=Neige4, Verglas=Verglas4, VentP=VentP4}
huitHeures[5] = {Heure=heure5, Icone=icone5, TempMax=Temp5, TempMaxR=TempR5, VentDir=Dir5, VentForce=Vitesse5, Humidite=Humi5, CouvNuage=CouvNuage5, PointRosee=Rosee5, UV=UV5, Pluie=Pluie5, Neige=Neige5, Verglas=Verglas5, VentP=VentP5}
huitHeures[6] = {Heure=heure6, Icone=icone6, TempMax=Temp6, TempMaxR=TempR6, VentDir=Dir6, VentForce=Vitesse6, Humidite=Humi6, CouvNuage=CouvNuage6, PointRosee=Rosee6, UV=UV6, Pluie=Pluie6, Neige=Neige6, Verglas=Verglas6, VentP=VentP6}
huitHeures[7] = {Heure=heure7, Icone=icone7, TempMax=Temp7, TempMaxR=TempR7, VentDir=Dir7, VentForce=Vitesse7, Humidite=Humi7, CouvNuage=CouvNuage7, PointRosee=Rosee7, UV=UV7, Pluie=Pluie7, Neige=Neige7, Verglas=Verglas7, VentP=VentP7}
huitHeures[8] = {Heure=heure8, Icone=icone8, TempMax=Temp8, TempMaxR=TempR8, VentDir=Dir8, VentForce=Vitesse8, Humidite=Humi8, CouvNuage=CouvNuage8, PointRosee=Rosee8, UV=UV8, Pluie=Pluie8, Neige=Neige8, Verglas=Verglas8, VentP=VentP8}
local t = {"VentP", "Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas"}
for j = 1, 8 do
local donee = {}
donee = huitHeures[j]
for i = 1,13 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug,"huitHeures ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
huitHeures[j] = donee
end
for h = 1,8 do
if huitHeures[h].VentDir == "CLM" then
huitHeures[h].VentDir = "Calme"
huitHeures[h].VentForce = "0"
end
huitHeures[h].VentIcone = icone_vent(direction_vent(huitHeures[h].VentDir), huitHeures[h].VentForce)
huitHeures[h].VentP = vent_plein(huitHeures[h].VentDir)
end
end
--Traitement information Quart de journée
function Prevision_Quart_T(web)
local f, i, line, icone, cond, Tmax, Tmin, Tmaxres, Tminres, dirvent, forcevent, Precipitationpourcent, Pluie, Neige, Humidite,Couverture, Pointrosee, Visibilite, Dbg
f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A50 '/#detail-' | sed 's/%//g'"))
line=f:read()
i=0
for line in f:lines() do
i=i+1
if i==4 then
icone=line:match("icon i%p(%a*)\">")
elseif i==5 then
cond=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</")
elseif i==6 then
Tmax=line:match(">([%p%d]*)<s")
elseif i==7 then
Tmin=line:match("lo\">%a*%s([%p%d]*)<s")
elseif i==10 then
Tmaxres, Tminres=line:formatage():match("® ([%p%d]*) / ([%p%d]*)</")
elseif i==27 then
dirvent=line:gsub("W","O"):match("'(%a*)'")
elseif i==28 then
forcevent=line:match("'(%d*)[%a%p]*'")
elseif i==38 then
Precipitationpourcent=line:match(">(%d*)</")
elseif i==39 then
Pluie=line:match(">(%d*) %a*</")
elseif i==40 then
Neige=line:match(">(%d*) %a*</")
elseif i==41 then
Humidite=line:match(">(%d*)</")
elseif i==42 then
Couverture=line:match(">(%d*)</")
elseif i==43 then
Pointrosee=line:match(">([%p%d]*)&#")
elseif i==44 then
Visibilite=line:match(">(%d*) %a*</")
end
end
f:close()
return {Icone=icone, CondMeteo=cond, TempMax=Tmax, TempMin=Tmin, TempMaxR=Tmaxres, TempMinR=Tminres, VentDir=dirvent, VentForce=forcevent, Humidite=Humidite, CouvNuage=Couverture, PointRosee=Pointrosee, ProbPrec=Precipitationpourcent, Visibilite=Visibilite, QNeige=Neige, QPluie=Pluie}
end
--Prévision
function prevision(web)
local f, i, line, iconej, Tmax, Tmaxr, ProbPrecj, Vdirj, Vforcej, Vrafalesj, Descriptifj, UV, ProbOragesj, Precj, Pluiej, Neigej, Verglasj, iconen, Tmin, Tminr, ProbPrecn, Vdirn, Vforcen, Vrafalesn, Descriptifn, UVn, ProbOragesn, Precn, Pluien, Neigen, Verglasn, jour,mois, annee, AujoudhuiMax, NormaleMax, RecordMax, Histo_Max, AujoudhuiMin, NormaleMin, RecordMin, Histo_Min, LeverSoleil, LeverSoleilH, LeverSoleilM, Culmine, CulmineH, CulmineM, CoucherSoleil, CoucherSoleilH, CoucherSoleilM, Datej
f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'"))
line=f:read()
i=0
for line in f:lines() do
i=i+1
--jour
if i==5 then
iconej=line:match("icon i%p(%a*)\">")
elseif i==6 then
Tmax=line:match("temp\">([%p%d]*)<")
elseif i==7 then
Tmaxr=line:match("174; ([%p%d]*)&#")
elseif i==8 then
ProbPrecj=line:match("feel[%a%p%d]* (%d*)</")
elseif i==40 then
Vdirj, Vforcej=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<")
elseif i==43 then
Vrafalesj=line:match("> (%d*) [%a%p]*<")
elseif i==47 then
Descriptifj=line:formatage():gsub(";",""):match("<p>([%a%p%s"..pat.."]*)</p>")
elseif i==51 then
UV=line:match("g>(%d*)</s")
elseif i==52 then
ProbOragesj=line:match(">(%d*)</s")
elseif i==53 then
Precj=line:match(">(%d*) %a*</s")
elseif i==54 then
Pluiej=line:match(">(%d*) %a*</s")
elseif i==55 then
Neigej=line:match(">(%d*) %a*</s")
elseif i==56 then
Verglasj=line:match(">(%d*) %a*</s")
--nuit
elseif i==65 then
iconen=line:match("icon i%p(%a*)\">")
elseif i==66 then
Tmin=line:match("temp\">([%p%d]*)<")
elseif i==67 then
Tminr=line:match("174; ([%p%d]*)&#")
elseif i==68 then
ProbPrecn=line:match("feel[%a%p%d]* (%d*)</")
elseif i==101 then
Vdirn, Vforcen=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<")
elseif i==104 then
Vrafalesn=line:match("> (%d*) [%a%p]*<")
elseif i==108 then
Descriptifn=line:formatage():gsub(";",""):match("<p>([%a%p%s"..pat.."]*)</p>")
elseif i==112 then
UVn=line:match("g>([%a%p%d]*)</s")
elseif i==113 then
ProbOragesn=line:match(">(%d*)</s")
elseif i==114 then
Precn=line:match(">(%d*) %a*</s")
elseif i==115 then
Pluien=line:match(">(%d*) %a*</s")
elseif i==116 then
Neigen=line:match(">(%d*) %a*</s")
elseif i==117 then
Verglasn=line:match(">(%d*) %a*</s")
--historique
elseif i==133 then
jour,mois,annee=line:match("- (%d*)/(%d*)/(%d*)</")
elseif i==151 then
AujoudhuiMax=line:formatage():match(">([%d%a%p]*)</")
elseif i==153 then
NormaleMax=line:formatage():match(">([%d%a%p]*)</")
elseif i==155 then
RecordMax=line:formatage():match(">([%d%a%p]*)</")
elseif i==157 then
Histo_Max=line:formatage():match(">([%d%a%p]*)</")
elseif i==162 then
AujoudhuiMin=line:formatage():match(">([%d%a%p]*)</")
elseif i==164 then
NormaleMin=line:formatage():match(">([%d%a%p]*)</")
elseif i==166 then
RecordMin=line:formatage():match(">([%d%a%p]*)</")
elseif i==168 then
Histo_Min=line:formatage():match(">([%d%a%p]*)</")
--Lever coucher soleil
elseif i==185 then
LeverSoleil,LeverSoleilH,LeverSoleilM=line:match(">((%d*):(%d*))<")
elseif i==188 then
Culmine, CulmineH, CulmineM=line:match(">((%d*):(%d*))<")
elseif i==191 then
CoucherSoleil,CoucherSoleilH,CoucherSoleilM=line:match(">((%d*):(%d*))<")
end
end
f:close()
Datej = os.time{year=annee, month=mois, day=jour, hour=0}
return { Icone=iconej, CondMeteo=Descriptifj, Temp=Tmax, TempRes=Tmaxr, ProbPrec=ProbPrecj, VentDir=Vdirj, VentForce=Vforcej, VentRafales=Vrafalesj, Uv=UV, ProbOrage=ProbOragesj, NivPrec=Precj, QPluie=Pluiej, QNeige=Neigej, EVerglas=Verglasj }, { Icone=iconen, CondMeteo=Descriptifn, Temp=Tmin, TempRes=Tminr, ProbPrec=ProbPrecn, VentDir=Vdirn, VentForce=Vforcen, VentRafales=Vrafalesn, ProbOrage=ProbOragesn, NivPrec=Precn, QPluie=Pluien, QNeige=Neigen, EVerglas=Verglasn }, { Jour=Datej, LeverSoleil=LeverSoleil, LeverSoleilH=LeverSoleilH, LeverSoleilM=LeverSoleilM, CoucherSoleil=CoucherSoleil, CoucherSoleilH=CoucherSoleilH, CoucherSoleilM=CoucherSoleilM, Histo_Max=Histo_Max, Histo_Min=Histo_Min }
end
--Infos condition courante
function current(web)
local f, i, line, ville, lat, lon, icone, cur, temp, tempres, directvent, vitessevent, Humidite, Pression, Couvnuageuse, UV, Pointderosee, Precipitations, Visibilite, jour, mois, annee, Date, Dbg
f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed -e 's/%//g' -e '/var apgWxInfoObj/,/\"detail-now\"/d' | grep -A60 'meta'"))
line=f:read()
i=0
for line in f:lines() do
i=i+1
if i==2 then
ville,lat,lon=line:match("city: '([%w%s%-]*)'[%s%w%p]*lat: '([%d%p]*)'[%s%w%p]*lon: '([%d%p]*)'")
elseif i==5 then
icone=line:match("icon i%p(%a*)\">")
elseif i==6 then
cur, temp, tempres=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</[%a%p%s]*temp\">([%p%d]*)<s[%w%p%s]*; ([%p%d]*)<s")
elseif i==22 then
directvent=line:gsub("W","O"):match("'(%a*)'")
elseif i==23 then
vitessevent=line:match("'(%d*)[%a%p]*'")
elseif i==34 then
Humidite=line:match("g>(%d*)</s")
elseif i==35 then
Pression=line:match("g>(%d*).")
elseif i==36 then
Couvnuageuse=line:match("g>(%d*)</s")
elseif i==37 then
UV=line:match("g>(%d*)</s")
elseif i==38 then
Pointderosee=line:match("g>([%p%d]*)°")
elseif i==39 then
Precipitations=line:formatage():match("g>(%d*) ")
elseif i==40 then
Visibilite=line:match("g>(%d*) ")
elseif i==57 then
jour, mois, annee=line:match(">[%a%d%p%s]* (%d*)/(%d*)/(%d*)<")
end
end
f:close()
Date = os.time{year=annee, month=mois, day=jour, hour=0}
return {Icone=icone, Cond=cur, Temp=temp, Tempr=tempres, VentDir=directvent, VentForce=vitessevent, Humidite=Humidite, Pression=Pression, CouvNuage=Couvnuageuse, Uv=UV, PointRosee=Pointderosee, QPrec=Precipitations, Visibilite=Visibilite, Date=Date, Ville=ville, latitude=lat, longitude=lon}
end
--Infos lunaison
function lunaison(r)
local s, web, Lune
web="http://www.calendrier-lunaire.net/"
f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A53 'ephemerides\"' | sed 's/%//g'"))
line=f:read()
i=0
for line in f:lines() do
i=i+1
if i==3 then
icone=line:match("src=\"([%w%p]*)\"")
elseif i==7 then
ephemerides1, ephemerides2=line:formatage():match(">(%a*)</span> (%a*)<")
elseif i==11 then
Visibilite=line:match("\">([%d%p]*) <")
elseif i==12 then
Phases, Phases1, Phases2=line:formatage():match("\">(([%a%p%d"..pat.."]*),%s*([%a%p%d"..pat.."]*))</s")
elseif i==13 then
Noeud_lunaire=line:match("\">([%a%d%p%s]*)</s")
elseif i==14 then
Apogee=line:match("\">([%a%d%p%s]*)</s")
elseif i==15 then
Perigee=line:match("\">([%a%d%p%s]*)</s")
elseif i==16 then
Distance=line:match("\">(%d*) %a*</s")
elseif i==18 then
Age=line:match("\">([%a%d%s]*)</")
elseif i==19 then
Lever_LuneHeure, Lever_LuneMinute, Coucher_LuneHeure, Coucher_LuneMinute=line:match("\">([%d%p]*):([%d%p]*)</span>[%a%p%s]*;\">([%d%p]*):([%d%p]*)</")
elseif i==48 then
Eclipse_partielle=line:match("\">([%w%s]* <br /> [%d%p]*)</a>")
elseif i==49 then
Eclipse_total=line:match("\">([%w%s]* <br /> [%d%p]*)</a>")
end
end
f:close() if Noeud_lunaire:match("(%d+)") ~= nil then Noeud_lunaire = Noeud_lunaire:match("(%d+)") end
if Apogee:match("(%d+)") ~= nil then Apogee = Apogee:match("(%d+)") end
if Perigee:match("(%d+)") ~= nil then Perigee = Perigee:match("(%d+)") end
ephemerides = ephemerides1.." "..ephemerides2
Eclipse_partielle = datelune(Eclipse_partielle)
Eclipse_total = datelune(Eclipse_total)
s = "${exec wget --tries=3 -q -O "..r.."/lune.png http://www.calendrier-lunaire.net/"..icone.."}"
conky_parse( s )
conky_parse( "${exec convert "..r.."/lune.png -transparent '#091a2a' "..r.."/lune.png}" )
end
function datelune(d)
local j, m, a, h, min = d:gsub("Janvier", "01"):gsub("Février", "02"):gsub("Mars", "03"):gsub("Avril", "04"):gsub("Mais", "05"):gsub("Juin", "06"):gsub("Juillet", "07"):gsub("Août", "08"):gsub("septembre", "09"):gsub("Octobre", "10"):gsub("Novembre", "11"):gsub("Décembre", "12"):match("(%d+) (%d+) (%d+) <br /> (%d+):(%d+)")
d = os.time{year=a, month=m, day=j, hour=h, min=min}
return d
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 <= Palier then
n = d
elseif f <= Palier*2 then
n = d + 17
elseif f <= Palier*3 then
n = d + 34
elseif f >= (Palier*3)+1 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, dm, dp
if string.len(d) >= 22 then
n = math.ceil(string.len(d)/2)
dm = string.sub(d, 1, n)
dp = string.sub(d, n)
p1 = string.find(dp, " ")
local b = 1
p2 = nil
if string.find(dm, ' ') then
while p2 == nil do
b = b+1
p2 = string.find(dm, ' ', -b)
end
end
if p1 ~= nil then p1 = n+p1-1 end
if p1 == nil and p2 == nil then p1 = string.find(d, " ") end
if p2 == nil then p2 = p1 end
if p1 == nil then p1 = p2 end
if p1-n >= n-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
--Information Matin
function Prevision_Matin(a, j, x)
local i = j+x
conditionMatin[j] = Prevision_Quart_T(a..'?day='..i)
local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
local donee = {}
donee = conditionMatin[j]
for i = 1,15 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditionMatin ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
conditionMatin[j]=donee
if conditionMatin[j].VentDir == "CLM" then
conditionMatin[j].VentDir = "Calme"
conditionMatin[j].VentForce = "0"
end
conditionMatin[j].VentIcone = icone_vent(direction_vent(conditionMatin[j].VentDir), conditionMatin[j].VentForce)
conditionMatin[j].VentP = vent_plein(conditionMatin[j].VentDir)
conditionMatin[j].CondMeteo1, conditionMatin[j].CondMeteo2, conditionMatin[j].CondMeteo1se, conditionMatin[j].CondMeteo2se = decoupage(conditionMatin[j].CondMeteo)
print("Matin "..j.." Ok")
end
--Information Après-midi
function Prevision_AM(a, j, x)
local i = j+x
conditionAM[j] = Prevision_Quart_T(a..'?day='..i)
local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
local donee = {}
donee = conditionAM[j]
for i = 1,15 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditionAM ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
conditionAM[j]=donee
if conditionAM[j].VentDir == "CLM" then
conditionAM[j].VentDir = "Calme"
conditionAM[j].VentForce = "0"
end
conditionAM[j].VentIcone = icone_vent(direction_vent(conditionAM[j].VentDir), conditionAM[j].VentForce)
conditionAM[j].VentP = vent_plein(conditionAM[j].VentDir)
conditionAM[j].CondMeteo1, conditionAM[j].CondMeteo2, conditionAM[j].CondMeteo1se, conditionAM[j].CondMeteo2se = decoupage(conditionAM[j].CondMeteo)
print("Apres Midi "..j.." Ok")
end
--Information Soirée
function Prevision_Soiree(a, j, x)
local i = j+x
conditionSoiree[j] = Prevision_Quart_T(a..'?day='..i)
local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
local donee = {}
donee = conditionSoiree[j]
for i = 1,15 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditionSoiree ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
conditionSoiree[j]=donee
if conditionSoiree[j].VentDir == "CLM" then
conditionSoiree[j].VentDir = "Calme"
conditionSoiree[j].VentForce = "0"
end
conditionSoiree[j].VentIcone = icone_vent(direction_vent(conditionSoiree[j].VentDir), conditionSoiree[j].VentForce)
conditionSoiree[j].VentP = vent_plein(conditionSoiree[j].VentDir)
conditionSoiree[j].CondMeteo1, conditionSoiree[j].CondMeteo2, conditionSoiree[j].CondMeteo1se, conditionSoiree[j].CondMeteo2se = decoupage(conditionSoiree[j].CondMeteo)
print("Soiree "..j.." Ok")
end
--Information Nuit
function Prevision_Nuit(a, j, x)
local i = j+x
conditionNoct[j] = Prevision_Quart_T(a..'?day='..i)
local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
local donee = {}
donee = conditionNoct[j]
for i = 1,15 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditionNoct ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
conditionNoct[j]=donee
if conditionNoct[j].VentDir == "CLM" then
conditionNoct[j].VentDir = "Calme"
conditionNoct[j].VentForce = "0"
end
conditionNoct[j].VentIcone = icone_vent(direction_vent(conditionNoct[j].VentDir), conditionNoct[j].VentForce)
conditionNoct[j].VentP = vent_plein(conditionNoct[j].VentDir)
conditionNoct[j].CondMeteo1, conditionNoct[j].CondMeteo2, conditionNoct[j].CondMeteo1se, conditionNoct[j].CondMeteo2se = decoupage(conditionNoct[j].CondMeteo)
print("Nuit "..j.." Ok")
end
--Information Huit heures
function Prevision_Huit_Heures(a)
Huit_Heures(a)
print("Huit prochaines heures Ok")
end
--Traitement infos prévisions (15 jours max) jour 1 = aujourd'hui
function jour_n(a, j, x)
local i = j+x
conditionJour[j], conditionNuit[j], InfoJour[j] = prevision(a..'?day='..i)
local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" }
local donee = {}
donee = conditionJour[j]
for i = 1,14 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditionJour ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
conditionJour[j]=donee
local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" }
donee = conditionNuit[j]
for i = 1,13 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditionNuit ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
conditionNuit[j]=donee
local t = { "Jour", "LeverSoleil", "LeverSoleilH", "LeverSoleilM", "CoucherSoleil", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min" }
donee = InfoJour[j]
for i = 1,9 do
if donee[t[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "InfoJour ", t[i]," jour n° ", j)
donee[t[i]]="N/A"
end
end
InfoJour[j]=donee
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].RafalesIcone = icone_vent(direction_vent(conditionJour[j].VentDir), conditionJour[j].VentRafales)
conditionJour[j].VentP = 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].RafalesIcone = icone_vent(direction_vent(conditionNuit[j].VentDir), conditionNuit[j].VentRafales)
conditionNuit[j].VentP = vent_plein(conditionNuit[j].VentDir)
conditionNuit[j].CondMeteo1, conditionNuit[j].CondMeteo2, conditionNuit[j].CondMeteo1se, conditionNuit[j].CondMeteo2se = decoupage(conditionNuit[j].CondMeteo)
print("Prévision "..j.." Ok")
end
--initialisation paramètres
function conky_init(cfg)
local cmd1, pos1
local home = os.getenv("HOME")
cfg = string.gsub(cfg, "~", home)
cfg = string.gsub(cfg, "$HOME", home)
fichier_init = cfg
local file = assert(io.open(cfg, "rb") )
local line = file:read()
for line in file:lines() do
pos1 = string.find(line, '#')
if pos1 ~= nil then
line = string.sub(line, 1, pos1-1)
end
pos1 = string.find(line, '=')
if string.find(line, 'repsauv=') ~= nil then
repsauv = string.sub(line, pos1+1)
elseif string.find(line, 'TempShell=') ~= nil then
r = string.sub(line, pos1+1)
elseif string.find(line, 'web=') ~= nil then
cmd1 = string.sub(line, pos1+1)
elseif string.find(line, 'periode=') ~= nil then
jours = string.sub(line, pos1+1)
elseif string.find(line, 'matinée=') ~= nil then
matin = string.sub(line, pos1+1)
elseif string.find(line, 'am=') ~= nil then
apresmidi = string.sub(line, pos1+1)
elseif string.find(line, 'soiree=') ~= nil then
soiree = string.sub(line, pos1+1)
elseif string.find(line, 'nuit=') ~= nil then
nuit = string.sub(line, pos1+1)
elseif string.find(line, 'Prev8heures=') ~= nil then
huit = string.sub(line, pos1+1)
elseif string.find(line, 'Palier=') ~= nil then
Palier = tonumber(string.sub(line, pos1+1))
elseif string.find(line, 'update=') ~= nil then
delais = string.sub(line, pos1+1)
end
end
io.close(file)
r = r:gsub("~", home):gsub("$HOME", home)
repsauv = repsauv:gsub("~", home):gsub("$HOME", home)
VilleAdresse=string.match(cmd1, ".com/%a*/%a*/([%w%p%s]*)/%d*/%a*")
print("", "version = "..Version.."\n", "web = "..cmd1.."\n", "Pévision Nb jours = "..jours.."\n", "Pévision Matin = "..matin.."\n", "Pévision Après Midi = "..apresmidi.."\n", "Pévision Soirée = "..soiree.."\n", "Pévision Nuit = "..nuit.."\n","Prévision sur 8 heures = "..huit.."\n", "Délais = "..delais.."\n", "Chemin de travail = "..r.."\n","Palier = "..Palier.."\n", "Chemin de sauvegarde = "..repsauv)
--Création répertoire de travail
l = cmd1:match("/(%d+)")
if string.find(cmd1, 'forecast') ~= nil then
pos1 = string.find(cmd1, '/weather')
cmd = string.sub(cmd1, 0, pos1-1)
else
pos1 = string.find(cmd1, '/current')
cmd = string.sub(cmd1, 0, pos1-1)
end
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.."&& mkdir "..Rep)
end
--initialisation compteurs
t = os.time()-delais
tc = t
start = 1
--Vérification existence repsauv
if os.execute("cd "..repsauv) ~= 0 then
--création de repsauv si inexistant
local pos1 = 1
local chemin = nil
local cheminsup = nil
while pos1 ~= nil do
pos1 = string.find(repsauv, '/', pos1+1)
if pos1 ~= nil then
cheminsup = string.sub(repsauv, pos1)
chemin = string.gsub(repsauv, cheminsup, "")
else
cheminsup = ""
chemin = repsauv
end
if os.execute("cd "..chemin) ~= 0 then
os.execute("mkdir "..chemin)
end
end
end
if not existe(repsauv.."/CondCour") then
conky_Meteo_enligne()
end
MAJ ="0"
end
--Mise à jour météo
function conky_Meteo_Maj()
local s = '${if_gw}${lua conky_Meteo_enligne}${else}${lua conky_Meteo_horsligne}${endif}'
conky_parse( s )
return " "
end
--hors ligne récupération de données
function conky_Meteo_horsligne()
if dermodif == nil or dermodif ~= conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}") then
dermodif=conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}")
--Récupération dernière condition courante
local file = assert(io.open(repsauv.."/CondCour", "r") )
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"}
for i = 1,23 do
conditioncourante[t[i]] = donee[i]
end
time = donee[24]
io.close(file)
--Récupération prévision
for j = 1,jours do
local file = assert(io.open(repsauv.."/prevision"..j, "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local info = {}
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
conditionJour[j] = {}
for i = 1, 21 do
info[t[i]] = donee[i]
end
conditionJour[j] = info
local info1 = {}
t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
conditionNuit[j] = {}
for i = 22, 41 do
info1[t[i-21]] = donee[i]
end
conditionNuit[j] = info1
local info2 = {}
t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"}
InfoJour[j] = {}
for i = 42, 48 do
info2[t[i-41]] = donee[i]
end
InfoJour[j] = info2
io.close(file)
if matin == "oui" then
local file = assert(io.open(repsauv.."/matin"..j, "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
conditionMatin[j] = {}
local info3 = {}
for i = 1, 21 do
info3[t[i]] = donee[i]
end
conditionMatin[j] = info3
io.close(file)
end
if apresmidi == "oui" then
local file = assert(io.open(repsauv.."/ApresMidi"..j, "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
conditionAM[j] = {}
local info3 = {}
for i = 1, 21 do
info3[t[i]] = donee[i]
end
conditionAM[j] = info3
io.close(file)
end
if soiree == "oui" then
local file = assert(io.open(repsauv.."/Soiree"..j, "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
conditionSoiree[j] = {}
local info3 = {}
for i = 1, 21 do
info3[t[i]] = donee[i]
end
conditionSoiree[j] = info3
io.close(file)
end
if nuit == "oui" then
local file = assert(io.open(repsauv.."/Nuit"..j, "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
conditionNoct[j] = {}
local info3 = {}
for i = 1, 21 do
info3[t[i]] = donee[i]
end
conditionNoct[j] = info3
io.close(file)
end
end
if huit == "oui" then
for j = 1,8 do
local file = assert(io.open(repsauv.."/huitHeures"..j, "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"}
huitHeures[j] = {}
local info3 = {}
for i = 1, 15 do
info3[t[i]] = donee[i]
end
huitHeures[j] = info3
io.close(file)
end
end
--Récupération lunaison
local file = assert(io.open(repsauv.."/lunaison", "r"))
local line = file:read()
local i = 0
local donee = {}
for line in file:lines() do
i = i+1
donee[i] = line
end
ephemerides = donee[1]
ephemerides1 = donee[2]
ephemerides2 = donee[3]
Visibilite = donee[4]
Phases = donee[5]
Phases1 = donee[6]
Phases2 = donee[7]
Noeud_lunaire = donee[8]
Apogee = donee[9]
Perigee = donee[10]
Distance = donee[11]
Age = donee[12]
Lever_LuneHeure = donee[13]
Lever_LuneMinute = donee[14]
Coucher_LuneHeure = donee[15]
Coucher_LuneMinute = donee[16]
Eclipse_partielle = donee[17]
Eclipse_total = donee[18]
io.close(file)
if MAJ == "0" then
MAJ = "1"
else
MAJ = "0"
end
collectgarbage()
end
return ""
end
--en ligne mise à jour
function conky_Meteo_enligne()
local i
if tonumber(delais) <= os.difftime(os.time(), t) then
t = os.time()
time = t
conditioncourante.Date = nil
while conditioncourante.Date == nil do
conditioncourante = current(cmd..'/current-weather/'..l)
local y = {"Icone", "Cond", "Temp", "Tempr", "VentDir", "VentForce", "Humidite", "Pression", "CouvNuage", "Uv", "PointRosee", "QPrec", "Visibilite", "Ville", "latitude","Date", "longitude"}
local donee = conditioncourante
for i = 1,17 do
if donee[y[i]] == nil then
local file = assert(io.open(repsauv.."/Debug", "a+"))
file:write ("\n", Debug, "conditioncourante ", y[i])
donee[y[i]]="N/A"
end
end
conditioncourante=donee
if conditioncourante.VentDir == "CLM" then
conditioncourante.VentDir = "Calme"
conditioncourante.VentForce = "0"
end
if conditioncourante.Ville == "" then
conditioncourante.Ville = VilleAdresse
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)
print("Condition courante Ok")
if 14400 <= os.difftime(os.time(), tc) or start == 1 then
start = 2
tc = t
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
--infos matin si demandée
if matin == "oui" then
addr_week = cmd..'/morning-weather-forecast/'..l
if conditioncourante.Date == InfoJour[1].Jour then
for i = 1,jours do Prevision_Matin(addr_week, i, 0) end
else
for i = 1,jours do Prevision_Matin(addr_week, i, 1) end
end
end
--infos Après Midi si demandée
if apresmidi == "oui" then
addr_week = cmd..'/afternoon-weather-forecast/'..l
if conditioncourante.Date == InfoJour[1].Jour then
for i = 1,jours do Prevision_AM(addr_week, i, 0) end
else
for i = 1,jours do Prevision_AM(addr_week, i, 1) end
end
end
--infos Soirée si demandée
if soiree == "oui" then
addr_week = cmd..'/evening-weather-forecast/'..l
if conditioncourante.Date == InfoJour[1].Jour then
for i = 1,jours do Prevision_Soiree(addr_week, i, 0) end
else
for i = 1,jours do Prevision_Soiree(addr_week, i, 1) end
end
end
--infos Nuit si demandée
if nuit == "oui" then
addr_week = cmd..'/overnight-weather-forecast/'..l
if conditioncourante.Date == InfoJour[1].Jour then
for i = 1,jours do Prevision_Nuit(addr_week, i, 0) end
else
for i = 1,jours do Prevision_Nuit(addr_week, i, 1) end
end
end
end -- fin mise à jour compète
end
if huit == "oui" then
addr_week = cmd..'/hourly-weather-forecast/'..l
Prevision_Huit_Heures(addr_week)
end
lunaison(r)
print("lunaison Ok")
--lancement sauvegarde
if repsauv ~= nil then
sauvegarde()
end
if MAJ == "0" then
MAJ = "1"
else
MAJ = "0"
end
collectgarbage()
print(os.difftime(os.time(), t).." seconde(s)")
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.."/jour/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
else
return "${image "..r.."/nuit/"..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)
format = string.gsub(format, "_", " ")
return trad_date(os.date(format, conditioncourante.Date))
end
function conky_Meteo_Ville()
return conditioncourante.Ville
end
function conky_Meteo_CouvNuage()
return tonumber(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", time)
end
function conky_Meteo_Minute()
return os.date("%M", time)
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_ProbPrec(j)
return tonumber(conditionJour[tonumber(j)].ProbPrec)
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_EVerglas(j)
return tonumber(conditionJour[tonumber(j)].EVerglas)
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
function conky_Meteo_Jour_IconeR(r, p, s, f, j)
return "${image "..r.."/"..conditionJour[tonumber(j)].RafalesIcone.." -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_ProbPrec(j)
return tonumber(conditionNuit[tonumber(j)].ProbPrec)
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_EVerglas(j)
return tonumber(conditionNuit[tonumber(j)].EVerglas)
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
function conky_Meteo_Nuit_IconeR(r, p, s, f, j)
return "${image "..r.."/"..conditionNuit[tonumber(j)].RafalesIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Infos sur la journée
function conky_Meteo_Jour(format, j)
format = string.gsub(format, "_", " ")
return trad_date(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_LeverSoleil(j)
return tonumber((InfoJour[tonumber(j)].LeverSoleilH*60)+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
function conky_Meteo_CoucherSoleil(j)
return tonumber((InfoJour[tonumber(j)].CoucherSoleilH*60)+InfoJour[tonumber(j)].CoucherSoleilM)
end
function conky_Meteo_HDureeJour(j)
return InfoJour[tonumber(j)].CoucherSoleilH-InfoJour[tonumber(j)].LeverSoleilH
end
function conky_Meteo_MDureeJour(j)
return os.date("%M", ((((InfoJour[tonumber(j)].CoucherSoleilH*3600)-3600)+(InfoJour[tonumber(j)].CoucherSoleilM*60))-(((InfoJour[tonumber(j)].LeverSoleilH*3600))+(InfoJour[tonumber(j)].LeverSoleilM*60))))
end
function conky_Meteo_Histo_Min(j)
return InfoJour[tonumber(j)].Histo_Min
end
function conky_Meteo_Histo_Max(j)
return InfoJour[tonumber(j)].Histo_Max
end
--Matin
function conky_Meteo_Matin_CondMeteo(j)
return conditionMatin[tonumber(j)].CondMeteo
end
function conky_Meteo_Matin_CondMeteo1(j)
return conditionMatin[tonumber(j)].CondMeteo1
end
function conky_Meteo_Matin_CondMeteo2(j)
return conditionMatin[tonumber(j)].CondMeteo2
end
function conky_Meteo_Matin_CondMeteo1se(j)
return conditionMatin[tonumber(j)].CondMeteo1se
end
function conky_Meteo_Matin_CondMeteo2se(j)
return conditionMatin[tonumber(j)].CondMeteo2se
end
function conky_Meteo_Matin_TempMax(j)
return tonumber(conditionMatin[tonumber(j)].TempMax)
end
function conky_Meteo_Matin_TempMin(j)
return tonumber(conditionMatin[tonumber(j)].TempMin)
end
function conky_Meteo_Matin_TempMaxRes(j)
return tonumber(conditionMatin[tonumber(j)].TempMaxR)
end
function conky_Meteo_Matin_TempMinRes(j)
return tonumber(conditionMatin[tonumber(j)].TempMinR)
end
function conky_Meteo_Matin_ProbPrec(j)
return tonumber(conditionMatin[tonumber(j)].ProbPrec)
end
function conky_Meteo_Matin_VentDir(j)
return conditionMatin[tonumber(j)].VentDir
end
function conky_Meteo_Matin_VentDirP(j)
return conditionMatin[tonumber(j)].VentP
end
function conky_Meteo_Matin_VentForce(j)
return tonumber(conditionMatin[tonumber(j)].VentForce)
end
function conky_Meteo_Matin_QPluie(j)
return tonumber(conditionMatin[tonumber(j)].QPluie)
end
function conky_Meteo_Matin_QNeige(j)
return tonumber(conditionMatin[tonumber(j)].QNeige)
end
function conky_Meteo_Matin_Humidite(j)
return tonumber(conditionMatin[tonumber(j)].Humidite)
end
function conky_Meteo_Matin_CouvNuage(j, r)
if r == nil then r = 100 end
local Couv = (tonumber(conditionMatin[tonumber(j)].CouvNuage) / 100) * r
if Couv - math.floor(Couv) <= 0.5 then
Couv = math.floor(Couv)
else
Couv = math.ceil(Couv)
end
return Couv
end
function conky_Meteo_Matin_Rose(j)
return tonumber(conditionMatin[tonumber(j)].PointRosee)
end
function conky_Meteo_Matin_Visibilite(j)
return tonumber(conditionMatin[tonumber(j)].Visibilite)
end
function conky_Meteo_Matin_IconeM(r, p, s, f, j)
return "${image "..r.."/jour/"..conditionMatin[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_Matin_IconeV(r, p, s, f, j)
return "${image "..r.."/"..conditionMatin[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Après Midi
function conky_Meteo_AM_CondMeteo(j)
return conditionAM[tonumber(j)].CondMeteo
end
function conky_Meteo_AM_CondMeteo1(j)
return conditionAM[tonumber(j)].CondMeteo1
end
function conky_Meteo_AM_CondMeteo2(j)
return conditionAM[tonumber(j)].CondMeteo2
end
function conky_Meteo_AM_CondMeteo1se(j)
return conditionAM[tonumber(j)].CondMeteo1se
end
function conky_Meteo_AM_CondMeteo2se(j)
return conditionAM[tonumber(j)].CondMeteo2se
end
function conky_Meteo_AM_TempMax(j)
return tonumber(conditionAM[tonumber(j)].TempMax)
end
function conky_Meteo_AM_TempMin(j)
return tonumber(conditionAM[tonumber(j)].TempMin)
end
function conky_Meteo_AM_TempMaxRes(j)
return tonumber(conditionAM[tonumber(j)].TempMaxR)
end
function conky_Meteo_AM_TempMinRes(j)
return tonumber(conditionAM[tonumber(j)].TempMinR)
end
function conky_Meteo_AM_ProbPrec(j)
return tonumber(conditionAM[tonumber(j)].ProbPrec)
end
function conky_Meteo_AM_VentDir(j)
return conditionAM[tonumber(j)].VentDir
end
function conky_Meteo_AM_VentDirP(j)
return conditionAM[tonumber(j)].VentP
end
function conky_Meteo_AM_VentForce(j)
return tonumber(conditionAM[tonumber(j)].VentForce)
end
function conky_Meteo_AM_QPluie(j)
return tonumber(conditionAM[tonumber(j)].QPluie)
end
function conky_Meteo_AM_QNeige(j)
return tonumber(conditionAM[tonumber(j)].QNeige)
end
function conky_Meteo_AM_Humidite(j)
return tonumber(conditionAM[tonumber(j)].Humidite)
end
function conky_Meteo_AM_CouvNuage(j, r)
if r == nil then r = 100 end
local Couv = (tonumber(conditionAM[tonumber(j)].CouvNuage) / 100) * r
if Couv - math.floor(Couv) <= 0.5 then
Couv = math.floor(Couv)
else
Couv = math.ceil(Couv)
end
return Couv
end
function conky_Meteo_AM_Rose(j)
return tonumber(conditionAM[tonumber(j)].PointRosee)
end
function conky_Meteo_AM_Visibilite(j)
return tonumber(conditionAM[tonumber(j)].Visibilite)
end
function conky_Meteo_AM_IconeM(r, p, s, f, j)
return "${image "..r.."/jour/"..conditionAM[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_AM_IconeV(r, p, s, f, j)
return "${image "..r.."/"..conditionAM[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Soirée
function conky_Meteo_Soiree_CondMeteo(j)
return conditionSoiree[tonumber(j)].CondMeteo
end
function conky_Meteo_Soiree_CondMeteo1(j)
return conditionSoiree[tonumber(j)].CondMeteo1
end
function conky_Meteo_Soiree_CondMeteo2(j)
return conditionSoiree[tonumber(j)].CondMeteo2
end
function conky_Meteo_Soiree_CondMeteo1se(j)
return conditionSoiree[tonumber(j)].CondMeteo1se
end
function conky_Meteo_Soiree_CondMeteo2se(j)
return conditionSoiree[tonumber(j)].CondMeteo2se
end
function conky_Meteo_Soiree_TempMax(j)
return tonumber(conditionSoiree[tonumber(j)].TempMax)
end
function conky_Meteo_Soiree_TempMin(j)
return tonumber(conditionSoiree[tonumber(j)].TempMin)
end
function conky_Meteo_Soiree_TempMaxRes(j)
return tonumber(conditionSoiree[tonumber(j)].TempMaxR)
end
function conky_Meteo_Soiree_TempMinRes(j)
return tonumber(conditionSoiree[tonumber(j)].TempMinR)
end
function conky_Meteo_Soiree_ProbPrec(j)
return tonumber(conditionSoiree[tonumber(j)].ProbPrec)
end
function conky_Meteo_Soiree_VentDir(j)
return conditionSoiree[tonumber(j)].VentDir
end
function conky_Meteo_Soiree_VentDirP(j)
return conditionSoiree[tonumber(j)].VentP
end
function conky_Meteo_Soiree_VentForce(j)
return tonumber(conditionSoiree[tonumber(j)].VentForce)
end
function conky_Meteo_Soiree_QPluie(j)
return tonumber(conditionSoiree[tonumber(j)].QPluie)
end
function conky_Meteo_Soiree_QNeige(j)
return tonumber(conditionSoiree[tonumber(j)].QNeige)
end
function conky_Meteo_Soiree_Humidite(j)
return tonumber(conditionSoiree[tonumber(j)].Humidite)
end
function conky_Meteo_Soiree_CouvNuage(j, r)
if r == nil then r = 100 end
local Couv = (tonumber(conditionSoiree[tonumber(j)].CouvNuage) / 100) * r
if Couv - math.floor(Couv) <= 0.5 then
Couv = math.floor(Couv)
else
Couv = math.ceil(Couv)
end
return Couv
end
function conky_Meteo_Soiree_Rose(j)
return tonumber(conditionSoiree[tonumber(j)].PointRosee)
end
function conky_Meteo_Soiree_Visibilite(j)
return tonumber(conditionSoiree[tonumber(j)].Visibilite)
end
function conky_Meteo_Soiree_IconeM(r, p, s, f, j)
return "${image "..r.."/jour/"..conditionSoiree[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_Soiree_IconeV(r, p, s, f, j)
return "${image "..r.."/"..conditionSoiree[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Nuit
function conky_Meteo_Noct_CondMeteo(j)
return conditionNoct[tonumber(j)].CondMeteo
end
function conky_Meteo_Noct_CondMeteo1(j)
return conditionNoct[tonumber(j)].CondMeteo1
end
function conky_Meteo_Noct_CondMeteo2(j)
return conditionNoct[tonumber(j)].CondMeteo2
end
function conky_Meteo_Noct_CondMeteo1se(j)
return conditionNoct[tonumber(j)].CondMeteo1se
end
function conky_Meteo_Noct_CondMeteo2se(j)
return conditionNoct[tonumber(j)].CondMeteo2se
end
function conky_Meteo_Noct_TempMax(j)
return tonumber(conditionNoct[tonumber(j)].TempMax)
end
function conky_Meteo_Noct_TempMin(j)
return tonumber(conditionNoct[tonumber(j)].TempMin)
end
function conky_Meteo_Noct_TempMaxRes(j)
return tonumber(conditionNoct[tonumber(j)].TempMaxR)
end
function conky_Meteo_Noct_TempMinRes(j)
return tonumber(conditionNoct[tonumber(j)].TempMinR)
end
function conky_Meteo_Noct_ProbPrec(j)
return tonumber(conditionNoct[tonumber(j)].ProbPrec)
end
function conky_Meteo_Noct_VentDir(j)
return conditionNoct[tonumber(j)].VentDir
end
function conky_Meteo_Noct_VentDirP(j)
return conditionNoct[tonumber(j)].VentP
end
function conky_Meteo_Noct_VentForce(j)
return tonumber(conditionNoct[tonumber(j)].VentForce)
end
function conky_Meteo_Noct_QPluie(j)
return tonumber(conditionNoct[tonumber(j)].QPluie)
end
function conky_Meteo_Noct_QNeige(j)
return tonumber(conditionNoct[tonumber(j)].QNeige)
end
function conky_Meteo_Noct_Humidite(j)
return tonumber(conditionNoct[tonumber(j)].Humidite)
end
function conky_Meteo_Noct_CouvNuage(j, r)
if r == nil then r = 100 end
local Couv = (tonumber(conditionNoct[tonumber(j)].CouvNuage) / 100) * r
if Couv - math.floor(Couv) <= 0.5 then
Couv = math.floor(Couv)
else
Couv = math.ceil(Couv)
end
return Couv
end
function conky_Meteo_Noct_Rose(j)
return tonumber(conditionNoct[tonumber(j)].PointRosee)
end
function conky_Meteo_Noct_Visibilite(j)
return tonumber(conditionNoct[tonumber(j)].Visibilite)
end
function conky_Meteo_Noct_IconeM(r, p, s, f, j)
return "${image "..r.."/nuit/"..conditionNoct[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_Noct_IconeV(r, p, s, f, j)
return "${image "..r.."/"..conditionNoct[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
--Huit prochaines heures
function conky_Meteo_huitHeures_VentDirP(j)
return huitHeures[tonumber(j)].VentP
end
function conky_Meteo_huitHeures_IconeV(r, p, s, f, j)
return "${image "..r.."/"..huitHeures[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end
function conky_Meteo_huitHeures_Heure(j)
return tonumber(huitHeures[tonumber(j)].Heure)
end
function conky_Meteo_huitHeures_IconeM(r, p, s, f, j)
if huitHeures[tonumber(j)].Heure <= InfoJour[1].CoucherSoleilH and huitHeures[tonumber(j)].Heure >= InfoJour[1].LeverSoleilH then
return "${image "..r.."/jour/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
else
return "${image "..r.."/nuit/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end
end
function conky_Meteo_huitHeures_Temp(j)
return tonumber(huitHeures[tonumber(j)].TempMax)
end
function conky_Meteo_huitHeures_TempR(j)
return tonumber(huitHeures[tonumber(j)].TempMaxR)
end
function conky_Meteo_huitHeures_VentDir(j)
return huitHeures[tonumber(j)].VentDir
end
function conky_Meteo_huitHeures_VentForce(j)
return tonumber(huitHeures[tonumber(j)].VentForce)
end
function conky_Meteo_huitHeures_Humidite(j)
return tonumber(huitHeures[tonumber(j)].Humidite)
end
function conky_Meteo_huitHeures_CouvNuage(j)
return tonumber(huitHeures[tonumber(j)].CouvNuage)
end
function conky_Meteo_huitHeures_Rose(j)
return tonumber(huitHeures[tonumber(j)].PointRosee)
end
function conky_Meteo_huitHeures_ProbPluie(j)
return tonumber(huitHeures[tonumber(j)].Pluie)
end
function conky_Meteo_huitHeures_ProbNeige(j)
return tonumber(huitHeures[tonumber(j)].Neige)
end
function conky_Meteo_huitHeures_ProbVerglas(j)
return tonumber(huitHeures[tonumber(j)].Verglas)
end
function conky_Meteo_huitHeures_Uv(j)
return tonumber(huitHeures[tonumber(j)].UV)
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(format)
if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end
format = string.gsub(format, "_", " ")
return trad_date(os.date(format, Eclipse_partielle))
end
function conky_Lune_EclipseTotal()
if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end
format = string.gsub(format, "_", " ")
return trad_date(os.date(format, Eclipse_total))
end
--Informations sur le lua
function conky_Version()
return Version
end
function conky_Meteo_fichier_init()
return fichier_init
end
function conky_Meteo_etat_MAJ()
return MAJ
end
--Sauvegarde des données
function sauvegarde()
--sauvegarde prévision
for j = 1,jours do
local file = assert(io.open(repsauv.."/prevision"..j, "w+"))
file:write ("\n")
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
for i = 1, 21 do
file:write (conditionJour[j][t[i]], "\n")
end
t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
for i = 1, 20 do
file:write (conditionNuit[j][t[i]], "\n")
end
t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"}
for i = 1, 7 do
file:write (InfoJour[j][t[i]], "\n")
end
io.close(file)
if matin == "oui" then
local file = assert(io.open(repsauv.."/matin"..j, "w+"))
file:write ("\n")
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
for i = 1, 21 do
file:write (conditionMatin[j][t[i]], "\n")
end
io.close(file)
end
if apresmidi == "oui" then
local file = assert(io.open(repsauv.."/ApresMidi"..j, "w+"))
file:write ("\n")
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
for i = 1, 21 do
file:write (conditionAM[j][t[i]], "\n")
end
io.close(file)
end
if soiree == "oui" then
local file = assert(io.open(repsauv.."/Soiree"..j, "w+"))
file:write ("\n")
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
for i = 1, 21 do
file:write (conditionSoiree[j][t[i]], "\n")
end
io.close(file)
end
if nuit == "oui" then
local file = assert(io.open(repsauv.."/Nuit"..j, "w+"))
file:write ("\n")
local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
for i = 1, 21 do
file:write (conditionNoct[j][t[i]], "\n")
end
io.close(file)
end
end
if huit == "oui" then
for j = 1,8 do
local file = assert(io.open(repsauv.."/huitHeures"..j, "w+"))
file:write ("\n")
local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"}
for i = 1, 15 do
file:write (huitHeures[j][t[i]], "\n")
end
io.close(file)
end
end
--sauvegarde lunaison
local file = assert(io.open(repsauv.."/lunaison", "w+"))
file:write ("\n", ephemerides, "\n")
file:write (ephemerides1, "\n")
file:write (ephemerides2, "\n")
file:write (Visibilite, "\n")
file:write (Phases, "\n")
file:write (Phases1, "\n")
file:write (Phases2, "\n")
file:write (Noeud_lunaire, "\n")
file:write (Apogee, "\n")
file:write (Perigee, "\n")
file:write (Distance, "\n")
file:write (Age, "\n")
file:write (Lever_LuneHeure, "\n")
file:write (Lever_LuneMinute, "\n")
file:write (Coucher_LuneHeure, "\n")
file:write (Coucher_LuneMinute, "\n")
file:write (Eclipse_partielle, "\n")
file:write (Eclipse_total, "\n")
io.close(file)
--Sauvegarde condition courante
local file = assert(io.open(repsauv.."/CondCour", "w+") )
file:write ("\n")
local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"}
for i = 1,23 do
file:write (conditioncourante[t[i]], "\n")
end
file:write (time, "\n")
io.close(file)
--modification des droits utilisateur
os.execute('chmod o+rw- '..r..'/*lun*')
os.execute('chmod -R o+rw- '..repsauv)
os.execute('chmod -R o+rw- '..Rep)
end
Edit : modif code suite remarque oubli ). merci jpdipsy
Dernière modification par Didier-T (Le 16/11/2012, à 06:29)
Hors ligne
#1549 Le 16/11/2012, à 06:25
- jpdipsy
Re : [Conky] Alternative à weather.com (2)
@ Phyllinux,
en effet, il y avait bien un soucis, situé au niveau de la restitution d'information.
sa devrait fonctionner mieux maintenant.
meteo.lua-- Créé par Didier-T (forum.ubuntu-fr.org) -- Nécessite imagemagick http://apt.ubuntu.com/p/imagemagick require "io" require "os" local Version = "v4.8" local conditionJour = {} local conditionNuit = {} local conditionMatin = {} local conditionAM = {} local conditionSoiree = {} local conditionNoct = {} local InfoJour = {} local conditioncourante = {} local huitHeures = {} local Rep, cmd, jours, matin, apresmidi, soiree, nuit, delais, r, repsauv, l, fichier_init, MAJ, tc, dermodif, VilleAdresse local Debug = "Problème Info " --Liste des accents et carractère non pris en charge par les patterns local pat="%é%è%à%ä%â%ê%ô%ç%É%È%À%Â%Ä%Ê%Ô%Ç" --Traduction date function trad_date(d) local date = d date = date:gsub("Monday", "Lundi"):gsub("Tuesday", "Mardi"):gsub("Wednesday", "Mercredi"):gsub("Thursday", "Jeudi"):gsub("Friday", "Vendredi"):gsub("Saturday", "Samedi"):gsub("Sunday", "Dimanche") date = date:gsub("lun", "Lun"):gsub("mar", "Mar"):gsub("mer", "Mer"):gsub("jeu", "Jeu"):gsub("ven", "Ven"):gsub("sam", "Sam"):gsub("dim", "Dim") date = date:gsub("Mon", "Lun"):gsub("Tue", "Mar"):gsub("Wed", "Mer"):gsub("Thu", "Jeu"):gsub("Fri", "Ven"):gsub("Sat", "Sam"):gsub("Sun", "Dim") date = date:gsub("January", "Janvier"):gsub("February", "Février"):gsub("March", "Mars"):gsub("April", "Avril"):gsub("May", "Mai"):gsub("June", "Juin"):gsub("July", "Juillet"):gsub("August", "Août"):gsub("September", "Septembre"):gsub("October", "Octobre"):gsub("November", "Novembre"):gsub("December", "Décembre") date = date:gsub("jan", "Jan"):gsub("fev", "Fév"):gsub("mar", "Mar"):gsub("avr", "Avr"):gsub("mai", "Mai"):gsub("jui", "Jui"):gsub("aou", "Aoû"):gsub("sep", "Sep"):gsub("oct", "Oct"):gsub("nov", "Nov"):gsub("dec", "Déc") date = date:gsub("Feb", "Fév"):gsub("Apr", "Avr"):gsub("May", "Mai"):gsub("Jun", "Juin"):gsub("Jul", "Juil"):gsub("Aug", "Aoû"):gsub("Dec", "Déc") return date end --Vérifier l'existence d'un fichier function existe(file) local a = io.open(file, "r") local present if a then present = true io.close(a) else present = false end return present end --Formatage des pages web function string.formatage(ligne) ligne = ligne:gsub("ô", "ô"):gsub("â", "â"):gsub("é", "é"):gsub("è", "è"):gsub("à", "à"):gsub("ç", "ç"):gsub("ê", "ê"):gsub("ö", "ö"):gsub("î", "î"):gsub("ï", "ï"):gsub("û", "û"):gsub("ü", "ü"):gsub("'", "'"):gsub("Poudreries", "Bourrasques de neige"):gsub("É", "É"):gsub("°",""):gsub("[\n\r]",""):gsub("é", "é") return ligne end --Traitement Huit prochaines heures function Huit_Heures(web) local f, i, line, heure1, heure2, heure3, heure4, heure5, heure6, heure7, heure8, icone1, icone2, icone3, icone4, icone5, icone6, icone7, icone8, Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Temp8, TempR1, TempR2, TempR3, TempR4, TempR5, TempR6, TempR7, TempR8, Humi1, Humi2, Humi3, Humi4, Humi5, Humi6, Humi7, Humi8, Pluie1, Pluie2, Pluie3, Pluie4, Pluie5, Pluie6, Pluie7, Pluie8, Neige1, Neige2, Neige3, Neige4, Neige5, Neige6, Neige7, Neige8, Verglas1, Verglas2, Verglas3, Verglas4, Verglas5, Verglas6, Verglas7, Verglas8, Vitesse1, Dir1, Vitesse2, Dir2, Vitesse3, Dir3, Vitesse4, Dir4, Vitesse5, Dir5, Vitesse6, Dir6, Vitesse7, Dir7, Vitesse8, Dir8, UV1, UV2, UV3, UV4, UV5, UV6, UV7, UV8, CouvNuage1, CouvNuage2, CouvNuage3, CouvNuage4, CouvNuage5, CouvNuage6, CouvNuage7, CouvNuage8, Rosee1, Rosee2, Rosee3, Rosee4, Rosee5, Rosee6, Rosee7, Rosee8, h, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A202 'hourly\"' | sed 's/%//g'")) line=f:read() i=0 for line in f:lines() do i=i+1 --Récup. des heures if i==8 then heure1=line:match("/>(%d*)</") elseif i==9 then heure2=line:match(">(%d*)</") elseif i==10 then heure3=line:match(">(%d*)</") elseif i==11 then heure4=line:match(">(%d*)</") elseif i==12 then heure5=line:match(">(%d*)</") elseif i==13 then heure6=line:match(">(%d*)</") elseif i==14 then heure7=line:match(">(%d*)</") elseif i==15 then heure8=line:match(">(%d*)</") --Récup. des icones elseif i==34 then icone1=line:match("i%p(%a*)\">") elseif i==37 then icone2=line:match("i%p(%a*)\">") elseif i==40 then icone3=line:match("i%p(%a*)\">") elseif i==43 then icone4=line:match("i%p(%a*)\">") elseif i==46 then icone5=line:match("i%p(%a*)\">") elseif i==49 then icone6=line:match("i%p(%a*)\">") elseif i==52 then icone7=line:match("i%p(%a*)\">") elseif i==55 then icone8=line:match("i%p(%a*)\">") --Températures elseif i==60 then Temp1=line:match(">([%p%d]*)&") elseif i==61 then Temp2=line:match(">([%p%d]*)&") elseif i==62 then Temp3=line:match(">([%p%d]*)&") elseif i==63 then Temp4=line:match(">([%p%d]*)&") elseif i==64 then Temp5=line:match(">([%p%d]*)&") elseif i==65 then Temp6=line:match(">([%p%d]*)&") elseif i==66 then Temp7=line:match(">([%p%d]*)&") elseif i==67 then Temp8=line:match(">([%p%d]*)&") --Températures ressentie elseif i==71 then TempR1=line:match(">([%p%d]*)&") elseif i==72 then TempR2=line:match(">([%p%d]*)&") elseif i==73 then TempR3=line:match(">([%p%d]*)&") elseif i==74 then TempR4=line:match(">([%p%d]*)&") elseif i==75 then TempR5=line:match(">([%p%d]*)&") elseif i==76 then TempR6=line:match(">([%p%d]*)&") elseif i==77 then TempR7=line:match(">([%p%d]*)&") elseif i==78 then TempR8=line:match(">([%p%d]*)&") --Humidité elseif i==82 then Humi1=line:match(">(%d*)<") elseif i==83 then Humi2=line:match(">(%d*)<") elseif i==84 then Humi3=line:match(">(%d*)<") elseif i==85 then Humi4=line:match(">(%d*)<") elseif i==86 then Humi5=line:match(">(%d*)<") elseif i==87 then Humi6=line:match(">(%d*)<") elseif i==88 then Humi7=line:match(">(%d*)<") elseif i==89 then Humi8=line:match(">(%d*)<") --Pluie elseif i==109 then Pluie1=line:match("v>(%d*)<") elseif i==110 then Pluie2=line:match("v>(%d*)<") elseif i==111 then Pluie3=line:match("v>(%d*)<") elseif i==112 then Pluie4=line:match("v>(%d*)<") elseif i==113 then Pluie5=line:match("v>(%d*)<") elseif i==114 then Pluie6=line:match("v>(%d*)<") elseif i==115 then Pluie7=line:match("v>(%d*)<") elseif i==116 then Pluie8=line:match("v>(%d*)<") --Neige elseif i==120 then Neige1=line:match("v>(%d*)<") elseif i==121 then Neige2=line:match("v>(%d*)<") elseif i==122 then Neige3=line:match("v>(%d*)<") elseif i==123 then Neige4=line:match("v>(%d*)<") elseif i==124 then Neige5=line:match("v>(%d*)<") elseif i==125 then Neige6=line:match("v>(%d*)<") elseif i==126 then Neige7=line:match("v>(%d*)<") elseif i==127 then Neige8=line:match("v>(%d*)<") --Verglas elseif i==131 then Verglas1=line:match("v>(%d*)<") elseif i==132 then Verglas2=line:match("v>(%d*)<") elseif i==133 then Verglas3=line:match("v>(%d*)<") elseif i==134 then Verglas4=line:match("v>(%d*)<") elseif i==135 then Verglas5=line:match("v>(%d*)<") elseif i==136 then Verglas6=line:match("v>(%d*)<") elseif i==137 then Verglas7=line:match("v>(%d*)<") elseif i==138 then Verglas8=line:match("v>(%d*)<") --Vent elseif i==159 then Vitesse1, Dir1=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP1=vent_plein(Dir1) elseif i==160 then Vitesse2, Dir2=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP2=vent_plein(Dir2) elseif i==161 then Vitesse3, Dir3=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP3=vent_plein(Dir3) elseif i==162 then Vitesse4, Dir4=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP4=vent_plein(Dir4) elseif i==163 then Vitesse5, Dir5=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP5=vent_plein(Dir5) elseif i==164 then Vitesse6, Dir6=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP6=vent_plein(Dir6) elseif i==165 then Vitesse7, Dir7=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP7=vent_plein(Dir7) elseif i==166 then Vitesse8, Dir8=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP8=vent_plein(Dir8) --Uv elseif i==170 then UV1=line:match(">(%d*)<") elseif i==171 then UV2=line:match(">(%d*)<") elseif i==172 then UV3=line:match(">(%d*)<") elseif i==173 then UV4=line:match(">(%d*)<") elseif i==174 then UV5=line:match(">(%d*)<") elseif i==175 then UV6=line:match(">(%d*)<") elseif i==176 then UV7=line:match(">(%d*)<") elseif i==177 then UV8=line:match(">(%d*)<") --Couverture nuageuse elseif i==181 then CouvNuage1=line:match(">(%d*)<") elseif i==182 then CouvNuage2=line:match(">(%d*)<") elseif i==183 then CouvNuage3=line:match(">(%d*)<") elseif i==184 then CouvNuage4=line:match(">(%d*)<") elseif i==185 then CouvNuage5=line:match(">(%d*)<") elseif i==186 then CouvNuage6=line:match(">(%d*)<") elseif i==187 then CouvNuage7=line:match(">(%d*)<") elseif i==188 then CouvNuage8=line:match(">(%d*)<") --Point de rosée elseif i==192 then Rosee1=line:match(">([%p%d]*)&") elseif i==193 then Rosee2=line:match(">([%p%d]*)&") elseif i==194 then Rosee3=line:match(">([%p%d]*)&") elseif i==195 then Rosee4=line:match(">([%p%d]*)&") elseif i==196 then Rosee5=line:match(">([%p%d]*)&") elseif i==197 then Rosee6=line:match(">([%p%d]*)&") elseif i==198 then Rosee7=line:match(">([%p%d]*)&") elseif i==199 then Rosee8=line:match(">([%p%d]*)&") end end f:close() huitHeures[1] = {Heure=heure1, Icone=icone1, TempMax=Temp1, TempMaxR=TempR1, VentDir=Dir1, VentForce=Vitesse1, Humidite=Humi1, CouvNuage=CouvNuage1, PointRosee=Rosee1, UV=UV1, Pluie=Pluie1, Neige=Neige1, Verglas=Verglas1, VentP=VentP1} huitHeures[2] = {Heure=heure2, Icone=icone2, TempMax=Temp2, TempMaxR=TempR2, VentDir=Dir2, VentForce=Vitesse2, Humidite=Humi2, CouvNuage=CouvNuage2, PointRosee=Rosee2, UV=UV2, Pluie=Pluie2, Neige=Neige2, Verglas=Verglas2, VentP=VentP2} huitHeures[3] = {Heure=heure3, Icone=icone3, TempMax=Temp3, TempMaxR=TempR3, VentDir=Dir3, VentForce=Vitesse3, Humidite=Humi3, CouvNuage=CouvNuage3, PointRosee=Rosee3, UV=UV3, Pluie=Pluie3, Neige=Neige3, Verglas=Verglas3, VentP=VentP3} huitHeures[4] = {Heure=heure4, Icone=icone4, TempMax=Temp4, TempMaxR=TempR4, VentDir=Dir4, VentForce=Vitesse4, Humidite=Humi4, CouvNuage=CouvNuage4, PointRosee=Rosee4, UV=UV4, Pluie=Pluie4, Neige=Neige4, Verglas=Verglas4, VentP=VentP4} huitHeures[5] = {Heure=heure5, Icone=icone5, TempMax=Temp5, TempMaxR=TempR5, VentDir=Dir5, VentForce=Vitesse5, Humidite=Humi5, CouvNuage=CouvNuage5, PointRosee=Rosee5, UV=UV5, Pluie=Pluie5, Neige=Neige5, Verglas=Verglas5, VentP=VentP5} huitHeures[6] = {Heure=heure6, Icone=icone6, TempMax=Temp6, TempMaxR=TempR6, VentDir=Dir6, VentForce=Vitesse6, Humidite=Humi6, CouvNuage=CouvNuage6, PointRosee=Rosee6, UV=UV6, Pluie=Pluie6, Neige=Neige6, Verglas=Verglas6, VentP=VentP6} huitHeures[7] = {Heure=heure7, Icone=icone7, TempMax=Temp7, TempMaxR=TempR7, VentDir=Dir7, VentForce=Vitesse7, Humidite=Humi7, CouvNuage=CouvNuage7, PointRosee=Rosee7, UV=UV7, Pluie=Pluie7, Neige=Neige7, Verglas=Verglas7, VentP=VentP7} huitHeures[8] = {Heure=heure8, Icone=icone8, TempMax=Temp8, TempMaxR=TempR8, VentDir=Dir8, VentForce=Vitesse8, Humidite=Humi8, CouvNuage=CouvNuage8, PointRosee=Rosee8, UV=UV8, Pluie=Pluie8, Neige=Neige8, Verglas=Verglas8, VentP=VentP8} local t = {"VentP", "Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas"} for j = 1, 8 do local donee = {} donee = huitHeures[j] for i = 1,13 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug,"huitHeures ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end huitHeures[j] = donee end for h = 1,8 do if huitHeures[h].VentDir == "CLM" then huitHeures[h].VentDir = "Calme" huitHeures[h].VentForce = "0" end huitHeures[h].VentIcone = icone_vent(direction_vent(huitHeures[h].VentDir), huitHeures[h].VentForce) huitHeures[h].VentP = vent_plein(huitHeures[h].VentDir) end end --Traitement information Quart de journée function Prevision_Quart_T(web) local f, i, line, icone, cond, Tmax, Tmin, Tmaxres, Tminres, dirvent, forcevent, Precipitationpourcent, Pluie, Neige, Humidite,Couverture, Pointrosee, Visibilite, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A50 '/#detail-' | sed 's/%//g'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==4 then icone=line:match("icon i%p(%a*)\">") elseif i==5 then cond=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</") elseif i==6 then Tmax=line:match(">([%p%d]*)<s") elseif i==7 then Tmin=line:match("lo\">%a*%s([%p%d]*)<s") elseif i==10 then Tmaxres, Tminres=line:formatage():match("® ([%p%d]*) / ([%p%d]*)</") elseif i==27 then dirvent=line:gsub("W","O"):match("'(%a*)'") elseif i==28 then forcevent=line:match("'(%d*)[%a%p]*'") elseif i==38 then Precipitationpourcent=line:match(">(%d*)</") elseif i==39 then Pluie=line:match(">(%d*) %a*</") elseif i==40 then Neige=line:match(">(%d*) %a*</") elseif i==41 then Humidite=line:match(">(%d*)</") elseif i==42 then Couverture=line:match(">(%d*)</") elseif i==43 then Pointrosee=line:match(">([%p%d]*)&#") elseif i==44 then Visibilite=line:match(">(%d*) %a*</") end end f:close() return {Icone=icone, CondMeteo=cond, TempMax=Tmax, TempMin=Tmin, TempMaxR=Tmaxres, TempMinR=Tminres, VentDir=dirvent, VentForce=forcevent, Humidite=Humidite, CouvNuage=Couverture, PointRosee=Pointrosee, ProbPrec=Precipitationpourcent, Visibilite=Visibilite, QNeige=Neige, QPluie=Pluie} end --Prévision function prevision(web) local f, i, line, iconej, Tmax, Tmaxr, ProbPrecj, Vdirj, Vforcej, Vrafalesj, Descriptifj, UV, ProbOragesj, Precj, Pluiej, Neigej, Verglasj, iconen, Tmin, Tminr, ProbPrecn, Vdirn, Vforcen, Vrafalesn, Descriptifn, UVn, ProbOragesn, Precn, Pluien, Neigen, Verglasn, jour,mois, annee, AujoudhuiMax, NormaleMax, RecordMax, Histo_Max, AujoudhuiMin, NormaleMin, RecordMin, Histo_Min, LeverSoleil, LeverSoleilH, LeverSoleilM, Culmine, CulmineH, CulmineM, CoucherSoleil, CoucherSoleilH, CoucherSoleilM, Datej f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'")) line=f:read() i=0 for line in f:lines() do i=i+1 --jour if i==5 then iconej=line:match("icon i%p(%a*)\">") elseif i==6 then Tmax=line:match("temp\">([%p%d]*)<") elseif i==7 then Tmaxr=line:match("174; ([%p%d]*)&#") elseif i==8 then ProbPrecj=line:match("feel[%a%p%d]* (%d*)</") elseif i==40 then Vdirj, Vforcej=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<") elseif i==43 then Vrafalesj=line:match("> (%d*) [%a%p]*<") elseif i==47 then Descriptifj=line:formatage():gsub(";",""):match("<p>([%a%p%s"..pat.."]*)</p>") elseif i==51 then UV=line:match("g>(%d*)</s") elseif i==52 then ProbOragesj=line:match(">(%d*)</s") elseif i==53 then Precj=line:match(">(%d*) %a*</s") elseif i==54 then Pluiej=line:match(">(%d*) %a*</s") elseif i==55 then Neigej=line:match(">(%d*) %a*</s") elseif i==56 then Verglasj=line:match(">(%d*) %a*</s") --nuit elseif i==65 then iconen=line:match("icon i%p(%a*)\">") elseif i==66 then Tmin=line:match("temp\">([%p%d]*)<") elseif i==67 then Tminr=line:match("174; ([%p%d]*)&#") elseif i==68 then ProbPrecn=line:match("feel[%a%p%d]* (%d*)</") elseif i==101 then Vdirn, Vforcen=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<") elseif i==104 then Vrafalesn=line:match("> (%d*) [%a%p]*<") elseif i==108 then Descriptifn=line:formatage():gsub(";",""):match("<p>([%a%p%s"..pat.."]*)</p>") elseif i==112 then UVn=line:match("g>([%a%p%d]*)</s") elseif i==113 then ProbOragesn=line:match(">(%d*)</s") elseif i==114 then Precn=line:match(">(%d*) %a*</s") elseif i==115 then Pluien=line:match(">(%d*) %a*</s") elseif i==116 then Neigen=line:match(">(%d*) %a*</s") elseif i==117 then Verglasn=line:match(">(%d*) %a*</s") --historique elseif i==133 then jour,mois,annee=line:match("- (%d*)/(%d*)/(%d*)</") elseif i==151 then AujoudhuiMax=line:formatage():match(">([%d%a%p]*)</") elseif i==153 then NormaleMax=line:formatage():match(">([%d%a%p]*)</") elseif i==155 then RecordMax=line:formatage():match(">([%d%a%p]*)</") elseif i==157 then Histo_Max=line:formatage():match(">([%d%a%p]*)</") elseif i==162 then AujoudhuiMin=line:formatage():match(">([%d%a%p]*)</") elseif i==164 then NormaleMin=line:formatage():match(">([%d%a%p]*)</") elseif i==166 then RecordMin=line:formatage():match(">([%d%a%p]*)</") elseif i==168 then Histo_Min=line:formatage():match(">([%d%a%p]*)</") --Lever coucher soleil elseif i==185 then LeverSoleil,LeverSoleilH,LeverSoleilM=line:match(">((%d*):(%d*))<") elseif i==188 then Culmine, CulmineH, CulmineM=line:match(">((%d*):(%d*))<") elseif i==191 then CoucherSoleil,CoucherSoleilH,CoucherSoleilM=line:match(">((%d*):(%d*))<") end end f:close() Datej = os.time{year=annee, month=mois, day=jour, hour=0} return { Icone=iconej, CondMeteo=Descriptifj, Temp=Tmax, TempRes=Tmaxr, ProbPrec=ProbPrecj, VentDir=Vdirj, VentForce=Vforcej, VentRafales=Vrafalesj, Uv=UV, ProbOrage=ProbOragesj, NivPrec=Precj, QPluie=Pluiej, QNeige=Neigej, EVerglas=Verglasj }, { Icone=iconen, CondMeteo=Descriptifn, Temp=Tmin, TempRes=Tminr, ProbPrec=ProbPrecn, VentDir=Vdirn, VentForce=Vforcen, VentRafales=Vrafalesn, ProbOrage=ProbOragesn, NivPrec=Precn, QPluie=Pluien, QNeige=Neigen, EVerglas=Verglasn }, { Jour=Datej, LeverSoleil=LeverSoleil, LeverSoleilH=LeverSoleilH, LeverSoleilM=LeverSoleilM, CoucherSoleil=CoucherSoleil, CoucherSoleilH=CoucherSoleilH, CoucherSoleilM=CoucherSoleilM, Histo_Max=Histo_Max, Histo_Min=Histo_Min } end --Infos condition courante function current(web) local f, i, line, ville, lat, lon, icone, cur, temp, tempres, directvent, vitessevent, Humidite, Pression, Couvnuageuse, UV, Pointderosee, Precipitations, Visibilite, jour, mois, annee, Date, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed -e 's/%//g' -e '/var apgWxInfoObj/,/\"detail-now\"/d' | grep -A60 'meta'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==2 then ville,lat,lon=line:match("city: '([%w%s%-]*)'[%s%w%p]*lat: '([%d%p]*)'[%s%w%p]*lon: '([%d%p]*)'") elseif i==5 then icone=line:match("icon i%p(%a*)\">") elseif i==6 then cur, temp, tempres=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</[%a%p%s]*temp\">([%p%d]*)<s[%w%p%s]*; ([%p%d]*)<s") elseif i==22 then directvent=line:gsub("W","O"):match("'(%a*)'") elseif i==23 then vitessevent=line:match("'(%d*)[%a%p]*'") elseif i==34 then Humidite=line:match("g>(%d*)</s") elseif i==35 then Pression=line:match("g>(%d*).") elseif i==36 then Couvnuageuse=line:match("g>(%d*)</s") elseif i==37 then UV=line:match("g>(%d*)</s") elseif i==38 then Pointderosee=line:match("g>([%p%d]*)°") elseif i==39 then Precipitations=line:formatage():match("g>(%d*) ") elseif i==40 then Visibilite=line:match("g>(%d*) ") elseif i==57 then jour, mois, annee=line:match(">[%a%d%p%s]* (%d*)/(%d*)/(%d*)<") end end f:close() Date = os.time{year=annee, month=mois, day=jour, hour=0} return {Icone=icone, Cond=cur, Temp=temp, Tempr=tempres, VentDir=directvent, VentForce=vitessevent, Humidite=Humidite, Pression=Pression, CouvNuage=Couvnuageuse, Uv=UV, PointRosee=Pointderosee, QPrec=Precipitations, Visibilite=Visibilite, Date=Date, Ville=ville, latitude=lat, longitude=lon} end --Infos lunaison function lunaison(r) local s, web, Lune web="http://www.calendrier-lunaire.net/" f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A53 'ephemerides\"' | sed 's/%//g'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==3 then icone=line:match("src=\"([%w%p]*)\"") elseif i==7 then ephemerides1, ephemerides2=line:formatage():match(">(%a*)</span> (%a*)<") elseif i==11 then Visibilite=line:match("\">([%d%p]*) <") elseif i==12 then Phases, Phases1, Phases2=line:formatage():match("\">(([%a%p%d"..pat.."]*),%s*([%a%p%d"..pat.."]*))</s") elseif i==13 then Noeud_lunaire=line:match("\">([%a%d%p%s]*)</s") elseif i==14 then Apogee=line:match("\">([%a%d%p%s]*)</s") elseif i==15 then Perigee=line:match("\">([%a%d%p%s]*)</s") elseif i==16 then Distance=line:match("\">(%d*) %a*</s") elseif i==18 then Age=line:match("\">([%a%d%s]*)</") elseif i==19 then Lever_LuneHeure, Lever_LuneMinute, Coucher_LuneHeure, Coucher_LuneMinute=line:match("\">([%d%p]*):([%d%p]*)</span>[%a%p%s]*;\">([%d%p]*):([%d%p]*)</") elseif i==48 then Eclipse_partielle=line:match("\">([%w%s]* <br /> [%d%p]*)</a>") elseif i==49 then Eclipse_total=line:match("\">([%w%s]* <br /> [%d%p]*)</a>") end end f:close() if Noeud_lunaire:match("(%d+)") ~= nil then Noeud_lunaire = Noeud_lunaire:match("(%d+)") end if Apogee:match("(%d+)") ~= nil then Apogee = Apogee:match("(%d+)") end if Perigee:match("(%d+)") ~= nil then Perigee = Perigee:match("(%d+)") end ephemerides = ephemerides1.." "..ephemerides2 Eclipse_partielle = datelune(Eclipse_partielle) Eclipse_total = datelune(Eclipse_total) s = "${exec wget --tries=3 -q -O "..r.."/lune.png http://www.calendrier-lunaire.net/"..icone.."}" conky_parse( s ) conky_parse( "${exec convert "..r.."/lune.png -transparent '#091a2a' "..r.."/lune.png}" ) end function datelune(d) local j, m, a, h, min = d:gsub("Janvier", "01"):gsub("Février", "02"):gsub("Mars", "03"):gsub("Avril", "04"):gsub("Mais", "05"):gsub("Juin", "06"):gsub("Juillet", "07"):gsub("Août", "08"):gsub("septembre", "09"):gsub("Octobre", "10"):gsub("Novembre", "11"):gsub("Décembre", "12"):match("(%d+) (%d+) (%d+) <br /> (%d+):(%d+)") d = os.time{year=a, month=m, day=j, hour=h, min=min} return d 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 <= Palier then n = d elseif f <= Palier*2 then n = d + 17 elseif f <= Palier*3 then n = d + 34 elseif f >= (Palier*3)+1 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, dm, dp if string.len(d) >= 22 then n = math.ceil(string.len(d)/2) dm = string.sub(d, 1, n) dp = string.sub(d, n) p1 = string.find(dp, " ") local b = 1 p2 = nil if string.find(dm, ' ') then while p2 == nil do b = b+1 p2 = string.find(dm, ' ', -b) end end if p1 ~= nil then p1 = n+p1-1 end if p1 == nil and p2 == nil then p1 = string.find(d, " ") end if p2 == nil then p2 = p1 end if p1 == nil then p1 = p2 end if p1-n >= n-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 --Information Matin function Prevision_Matin(a, j, x) local i = j+x conditionMatin[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionMatin[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionMatin ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionMatin[j]=donee if conditionMatin[j].VentDir == "CLM" then conditionMatin[j].VentDir = "Calme" conditionMatin[j].VentForce = "0" end conditionMatin[j].VentIcone = icone_vent(direction_vent(conditionMatin[j].VentDir), conditionMatin[j].VentForce) conditionMatin[j].VentP = vent_plein(conditionMatin[j].VentDir) conditionMatin[j].CondMeteo1, conditionMatin[j].CondMeteo2, conditionMatin[j].CondMeteo1se, conditionMatin[j].CondMeteo2se = decoupage(conditionMatin[j].CondMeteo) print("Matin "..j.." Ok") end --Information Après-midi function Prevision_AM(a, j, x) local i = j+x conditionAM[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionAM[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionAM ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionAM[j]=donee if conditionAM[j].VentDir == "CLM" then conditionAM[j].VentDir = "Calme" conditionAM[j].VentForce = "0" end conditionAM[j].VentIcone = icone_vent(direction_vent(conditionAM[j].VentDir), conditionAM[j].VentForce) conditionAM[j].VentP = vent_plein(conditionAM[j].VentDir) conditionAM[j].CondMeteo1, conditionAM[j].CondMeteo2, conditionAM[j].CondMeteo1se, conditionAM[j].CondMeteo2se = decoupage(conditionAM[j].CondMeteo) print("Apres Midi "..j.." Ok") end --Information Soirée function Prevision_Soiree(a, j, x) local i = j+x conditionSoiree[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionSoiree[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionSoiree ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionSoiree[j]=donee if conditionSoiree[j].VentDir == "CLM" then conditionSoiree[j].VentDir = "Calme" conditionSoiree[j].VentForce = "0" end conditionSoiree[j].VentIcone = icone_vent(direction_vent(conditionSoiree[j].VentDir), conditionSoiree[j].VentForce) conditionSoiree[j].VentP = vent_plein(conditionSoiree[j].VentDir) conditionSoiree[j].CondMeteo1, conditionSoiree[j].CondMeteo2, conditionSoiree[j].CondMeteo1se, conditionSoiree[j].CondMeteo2se = decoupage(conditionSoiree[j].CondMeteo) print("Soiree "..j.." Ok") end --Information Nuit function Prevision_Nuit(a, j, x) local i = j+x conditionNoct[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionNoct[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionNoct ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionNoct[j]=donee if conditionNoct[j].VentDir == "CLM" then conditionNoct[j].VentDir = "Calme" conditionNoct[j].VentForce = "0" end conditionNoct[j].VentIcone = icone_vent(direction_vent(conditionNoct[j].VentDir), conditionNoct[j].VentForce) conditionNoct[j].VentP = vent_plein(conditionNoct[j].VentDir) conditionNoct[j].CondMeteo1, conditionNoct[j].CondMeteo2, conditionNoct[j].CondMeteo1se, conditionNoct[j].CondMeteo2se = decoupage(conditionNoct[j].CondMeteo) print("Nuit "..j.." Ok") end --Information Huit heures function Prevision_Huit_Heures(a) Huit_Heures(a) print("Huit prochaines heures Ok") end --Traitement infos prévisions (15 jours max) jour 1 = aujourd'hui function jour_n(a, j, x) local i = j+x conditionJour[j], conditionNuit[j], InfoJour[j] = prevision(a..'?day='..i) local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" } local donee = {} donee = conditionJour[j] for i = 1,14 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionJour ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionJour[j]=donee local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" } donee = conditionNuit[j] for i = 1,13 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionNuit ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionNuit[j]=donee local t = { "Jour", "LeverSoleil", "LeverSoleilH", "LeverSoleilM", "CoucherSoleil", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min" } donee = InfoJour[j] for i = 1,9 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "InfoJour ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end InfoJour[j]=donee 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].RafalesIcone = icone_vent(direction_vent(conditionJour[j].VentDir), conditionJour[j].VentRafales) conditionJour[j].VentP = 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].RafalesIcone = icone_vent(direction_vent(conditionNuit[j].VentDir), conditionNuit[j].VentRafales) conditionNuit[j].VentP = vent_plein(conditionNuit[j].VentDir) conditionNuit[j].CondMeteo1, conditionNuit[j].CondMeteo2, conditionNuit[j].CondMeteo1se, conditionNuit[j].CondMeteo2se = decoupage(conditionNuit[j].CondMeteo) print("Prévision "..j.." Ok") end --initialisation paramètres function conky_init(cfg) local cmd1, pos1 local home = os.getenv("HOME") cfg = string.gsub(cfg, "~", home) cfg = string.gsub(cfg, "$HOME", home) fichier_init = cfg local file = assert(io.open(cfg, "rb") ) local line = file:read() for line in file:lines() do pos1 = string.find(line, '#') if pos1 ~= nil then line = string.sub(line, 1, pos1-1) end pos1 = string.find(line, '=') if string.find(line, 'repsauv=') ~= nil then repsauv = string.sub(line, pos1+1) elseif string.find(line, 'TempShell=') ~= nil then r = string.sub(line, pos1+1) elseif string.find(line, 'web=') ~= nil then cmd1 = string.sub(line, pos1+1) elseif string.find(line, 'periode=') ~= nil then jours = string.sub(line, pos1+1) elseif string.find(line, 'matinée=') ~= nil then matin = string.sub(line, pos1+1) elseif string.find(line, 'am=') ~= nil then apresmidi = string.sub(line, pos1+1) elseif string.find(line, 'soiree=') ~= nil then soiree = string.sub(line, pos1+1) elseif string.find(line, 'nuit=') ~= nil then nuit = string.sub(line, pos1+1) elseif string.find(line, 'Prev8heures=') ~= nil then huit = string.sub(line, pos1+1) elseif string.find(line, 'Palier=') ~= nil then Palier = tonumber(string.sub(line, pos1+1)) elseif string.find(line, 'update=') ~= nil then delais = string.sub(line, pos1+1) end end io.close(file) r = r:gsub("~", home):gsub("$HOME", home) repsauv = repsauv:gsub("~", home):gsub("$HOME", home) VilleAdresse=string.match(cmd1, ".com/%a*/%a*/([%w%p%s]*)/%d*/%a*") print("", "version = "..Version.."\n", "web = "..cmd1.."\n", "Pévision Nb jours = "..jours.."\n", "Pévision Matin = "..matin.."\n", "Pévision Après Midi = "..apresmidi.."\n", "Pévision Soirée = "..soiree.."\n", "Pévision Nuit = "..nuit.."\n","Prévision sur 8 heures = "..huit.."\n", "Délais = "..delais.."\n", "Chemin de travail = "..r.."\n","Palier = "..Palier.."\n", "Chemin de sauvegarde = "..repsauv) --Création répertoire de travail l = cmd1:match("/(%d+)") if string.find(cmd1, 'forecast') ~= nil then pos1 = string.find(cmd1, '/weather') cmd = string.sub(cmd1, 0, pos1-1) else pos1 = string.find(cmd1, '/current') cmd = string.sub(cmd1, 0, pos1-1) end 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.."&& mkdir "..Rep) end --initialisation compteurs t = os.time()-delais tc = t start = 1 --Vérification existence repsauv if os.execute("cd "..repsauv) ~= 0 then --création de repsauv si inexistant local pos1 = 1 local chemin = nil local cheminsup = nil while pos1 ~= nil do pos1 = string.find(repsauv, '/', pos1+1) if pos1 ~= nil then cheminsup = string.sub(repsauv, pos1) chemin = string.gsub(repsauv, cheminsup, "") else cheminsup = "" chemin = repsauv end if os.execute("cd "..chemin) ~= 0 then os.execute("mkdir "..chemin) end end end if not existe(repsauv.."/CondCour") then conky_Meteo_enligne() end MAJ ="0" end --Mise à jour météo function conky_Meteo_Maj() local s = '${if_gw}${lua conky_Meteo_enligne}${else}${lua conky_Meteo_horsligne}${endif}' conky_parse( s ) return " " end --hors ligne récupération de données function conky_Meteo_horsligne() if dermodif == nil or dermodif ~= conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}") then dermodif=conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}") --Récupération dernière condition courante local file = assert(io.open(repsauv.."/CondCour", "r") ) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"} for i = 1,23 do conditioncourante[t[i]] = donee[i] end time = donee[24] io.close(file) --Récupération prévision for j = 1,jours do local file = assert(io.open(repsauv.."/prevision"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local info = {} local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} conditionJour[j] = {} for i = 1, 21 do info[t[i]] = donee[i] end conditionJour[j] = info local info1 = {} t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} conditionNuit[j] = {} for i = 22, 41 do info1[t[i-21]] = donee[i] end conditionNuit[j] = info1 local info2 = {} t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"} InfoJour[j] = {} for i = 42, 48 do info2[t[i-41]] = donee[i] end InfoJour[j] = info2 io.close(file) if matin == "oui" then local file = assert(io.open(repsauv.."/matin"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionMatin[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionMatin[j] = info3 io.close(file) end if apresmidi == "oui" then local file = assert(io.open(repsauv.."/ApresMidi"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionAM[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionAM[j] = info3 io.close(file) end if soiree == "oui" then local file = assert(io.open(repsauv.."/Soiree"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionSoiree[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionSoiree[j] = info3 io.close(file) end if nuit == "oui" then local file = assert(io.open(repsauv.."/Nuit"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionNoct[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionNoct[j] = info3 io.close(file) end end if huit == "oui" then for j = 1,8 do local file = assert(io.open(repsauv.."/huitHeures"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"} huitHeures[j] = {} local info3 = {} for i = 1, 15 do info3[t[i]] = donee[i] end huitHeures[j] = info3 io.close(file) end end --Récupération lunaison local file = assert(io.open(repsauv.."/lunaison", "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end ephemerides = donee[1] ephemerides1 = donee[2] ephemerides2 = donee[3] Visibilite = donee[4] Phases = donee[5] Phases1 = donee[6] Phases2 = donee[7] Noeud_lunaire = donee[8] Apogee = donee[9] Perigee = donee[10] Distance = donee[11] Age = donee[12] Lever_LuneHeure = donee[13] Lever_LuneMinute = donee[14] Coucher_LuneHeure = donee[15] Coucher_LuneMinute = donee[16] Eclipse_partielle = donee[17] Eclipse_total = donee[18] io.close(file) if MAJ == "0" then MAJ = "1" else MAJ = "0" end collectgarbage() end return "" end --en ligne mise à jour function conky_Meteo_enligne() local i if tonumber(delais) <= os.difftime(os.time(), t) then t = os.time() time = t conditioncourante.Date = nil while conditioncourante.Date == nil do conditioncourante = current(cmd..'/current-weather/'..l) local y = {"Icone", "Cond", "Temp", "Tempr", "VentDir", "VentForce", "Humidite", "Pression", "CouvNuage", "Uv", "PointRosee", "QPrec", "Visibilite", "Ville", "latitude","Date", "longitude"} local donee = conditioncourante for i = 1,17 do if donee[y[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditioncourante ", y[i]) donee[y[i]]="N/A" end end conditioncourante=donee if conditioncourante.VentDir == "CLM" then conditioncourante.VentDir = "Calme" conditioncourante.VentForce = "0" end if conditioncourante.Ville == "" then conditioncourante.Ville = VilleAdresse 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) print("Condition courante Ok") if 14400 <= os.difftime(os.time(), tc) or start == 1 then start = 2 tc = t 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 --infos matin si demandée if matin == "oui" then addr_week = cmd..'/morning-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_Matin(addr_week, i, 0) end else for i = 1,jours do Prevision_Matin(addr_week, i, 1) end end end --infos Après Midi si demandée if apresmidi == "oui" then addr_week = cmd..'/afternoon-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_AM(addr_week, i, 0) end else for i = 1,jours do Prevision_AM(addr_week, i, 1) end end end --infos Soirée si demandée if soiree == "oui" then addr_week = cmd..'/evening-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_Soiree(addr_week, i, 0) end else for i = 1,jours do Prevision_Soiree(addr_week, i, 1) end end end --infos Nuit si demandée if nuit == "oui" then addr_week = cmd..'/overnight-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_Nuit(addr_week, i, 0) end else for i = 1,jours do Prevision_Nuit(addr_week, i, 1) end end end end -- fin mise à jour compète end if huit == "oui" then addr_week = cmd..'/hourly-weather-forecast/'..l Prevision_Huit_Heures(addr_week) end lunaison(r) print("lunaison Ok") --lancement sauvegarde if repsauv ~= nil then sauvegarde() end if MAJ == "0" then MAJ = "1" else MAJ = "0" end collectgarbage() print(os.difftime(os.time(), t).." seconde(s)") 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.."/jour/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}" else return "${image "..r.."/nuit/"..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) format = string.gsub(format, "_", " ") return trad_date(os.date(format, conditioncourante.Date)) end function conky_Meteo_Ville() return conditioncourante.Ville end function conky_Meteo_CouvNuage() return tonumber(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", time) end function conky_Meteo_Minute() return os.date("%M", time) 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_ProbPrec(j) return tonumber(conditionJour[tonumber(j)].ProbPrec) 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_EVerglas(j) return tonumber(conditionJour[tonumber(j)].EVerglas) 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 function conky_Meteo_Jour_IconeR(r, p, s, f, j) return "${image "..r.."/"..conditionJour[tonumber(j)].RafalesIcone.." -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_ProbPrec(j) return tonumber(conditionNuit[tonumber(j)].ProbPrec) 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_EVerglas(j) return tonumber(conditionNuit[tonumber(j)].EVerglas) 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 function conky_Meteo_Nuit_IconeR(r, p, s, f, j) return "${image "..r.."/"..conditionNuit[tonumber(j)].RafalesIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Infos sur la journée function conky_Meteo_Jour(format, j) format = string.gsub(format, "_", " ") return trad_date(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_LeverSoleil(j) return tonumber((InfoJour[tonumber(j)].LeverSoleilH*60)+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 function conky_Meteo_CoucherSoleil(j) return tonumber((InfoJour[tonumber(j)].CoucherSoleilH*60)+InfoJour[tonumber(j)].CoucherSoleilM) end function conky_Meteo_HDureeJour(j) return InfoJour[tonumber(j)].CoucherSoleilH-InfoJour[tonumber(j)].LeverSoleilH end function conky_Meteo_MDureeJour(j) return os.date("%M", ((((InfoJour[tonumber(j)].CoucherSoleilH*3600)-3600)+(InfoJour[tonumber(j)].CoucherSoleilM*60))-(((InfoJour[tonumber(j)].LeverSoleilH*3600))+(InfoJour[tonumber(j)].LeverSoleilM*60)))) end function conky_Meteo_Histo_Min(j) return InfoJour[tonumber(j)].Histo_Min end function conky_Meteo_Histo_Max(j) return InfoJour[tonumber(j)].Histo_Max end --Matin function conky_Meteo_Matin_CondMeteo(j) return conditionMatin[tonumber(j)].CondMeteo end function conky_Meteo_Matin_CondMeteo1(j) return conditionMatin[tonumber(j)].CondMeteo1 end function conky_Meteo_Matin_CondMeteo2(j) return conditionMatin[tonumber(j)].CondMeteo2 end function conky_Meteo_Matin_CondMeteo1se(j) return conditionMatin[tonumber(j)].CondMeteo1se end function conky_Meteo_Matin_CondMeteo2se(j) return conditionMatin[tonumber(j)].CondMeteo2se end function conky_Meteo_Matin_TempMax(j) return tonumber(conditionMatin[tonumber(j)].TempMax) end function conky_Meteo_Matin_TempMin(j) return tonumber(conditionMatin[tonumber(j)].TempMin) end function conky_Meteo_Matin_TempMaxRes(j) return tonumber(conditionMatin[tonumber(j)].TempMaxR) end function conky_Meteo_Matin_TempMinRes(j) return tonumber(conditionMatin[tonumber(j)].TempMinR) end function conky_Meteo_Matin_ProbPrec(j) return tonumber(conditionMatin[tonumber(j)].ProbPrec) end function conky_Meteo_Matin_VentDir(j) return conditionMatin[tonumber(j)].VentDir end function conky_Meteo_Matin_VentDirP(j) return conditionMatin[tonumber(j)].VentP end function conky_Meteo_Matin_VentForce(j) return tonumber(conditionMatin[tonumber(j)].VentForce) end function conky_Meteo_Matin_QPluie(j) return tonumber(conditionMatin[tonumber(j)].QPluie) end function conky_Meteo_Matin_QNeige(j) return tonumber(conditionMatin[tonumber(j)].QNeige) end function conky_Meteo_Matin_Humidite(j) return tonumber(conditionMatin[tonumber(j)].Humidite) end function conky_Meteo_Matin_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionMatin[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_Matin_Rose(j) return tonumber(conditionMatin[tonumber(j)].PointRosee) end function conky_Meteo_Matin_Visibilite(j) return tonumber(conditionMatin[tonumber(j)].Visibilite) end function conky_Meteo_Matin_IconeM(r, p, s, f, j) return "${image "..r.."/jour/"..conditionMatin[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_Matin_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionMatin[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Après Midi function conky_Meteo_AM_CondMeteo(j) return conditionAM[tonumber(j)].CondMeteo end function conky_Meteo_AM_CondMeteo1(j) return conditionAM[tonumber(j)].CondMeteo1 end function conky_Meteo_AM_CondMeteo2(j) return conditionAM[tonumber(j)].CondMeteo2 end function conky_Meteo_AM_CondMeteo1se(j) return conditionAM[tonumber(j)].CondMeteo1se end function conky_Meteo_AM_CondMeteo2se(j) return conditionAM[tonumber(j)].CondMeteo2se end function conky_Meteo_AM_TempMax(j) return tonumber(conditionAM[tonumber(j)].TempMax) end function conky_Meteo_AM_TempMin(j) return tonumber(conditionAM[tonumber(j)].TempMin) end function conky_Meteo_AM_TempMaxRes(j) return tonumber(conditionAM[tonumber(j)].TempMaxR) end function conky_Meteo_AM_TempMinRes(j) return tonumber(conditionAM[tonumber(j)].TempMinR) end function conky_Meteo_AM_ProbPrec(j) return tonumber(conditionAM[tonumber(j)].ProbPrec) end function conky_Meteo_AM_VentDir(j) return conditionAM[tonumber(j)].VentDir end function conky_Meteo_AM_VentDirP(j) return conditionAM[tonumber(j)].VentP end function conky_Meteo_AM_VentForce(j) return tonumber(conditionAM[tonumber(j)].VentForce) end function conky_Meteo_AM_QPluie(j) return tonumber(conditionAM[tonumber(j)].QPluie) end function conky_Meteo_AM_QNeige(j) return tonumber(conditionAM[tonumber(j)].QNeige) end function conky_Meteo_AM_Humidite(j) return tonumber(conditionAM[tonumber(j)].Humidite) end function conky_Meteo_AM_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionAM[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_AM_Rose(j) return tonumber(conditionAM[tonumber(j)].PointRosee) end function conky_Meteo_AM_Visibilite(j) return tonumber(conditionAM[tonumber(j)].Visibilite) end function conky_Meteo_AM_IconeM(r, p, s, f, j) return "${image "..r.."/jour/"..conditionAM[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_AM_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionAM[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Soirée function conky_Meteo_Soiree_CondMeteo(j) return conditionSoiree[tonumber(j)].CondMeteo end function conky_Meteo_Soiree_CondMeteo1(j) return conditionSoiree[tonumber(j)].CondMeteo1 end function conky_Meteo_Soiree_CondMeteo2(j) return conditionSoiree[tonumber(j)].CondMeteo2 end function conky_Meteo_Soiree_CondMeteo1se(j) return conditionSoiree[tonumber(j)].CondMeteo1se end function conky_Meteo_Soiree_CondMeteo2se(j) return conditionSoiree[tonumber(j)].CondMeteo2se end function conky_Meteo_Soiree_TempMax(j) return tonumber(conditionSoiree[tonumber(j)].TempMax) end function conky_Meteo_Soiree_TempMin(j) return tonumber(conditionSoiree[tonumber(j)].TempMin) end function conky_Meteo_Soiree_TempMaxRes(j) return tonumber(conditionSoiree[tonumber(j)].TempMaxR) end function conky_Meteo_Soiree_TempMinRes(j) return tonumber(conditionSoiree[tonumber(j)].TempMinR) end function conky_Meteo_Soiree_ProbPrec(j) return tonumber(conditionSoiree[tonumber(j)].ProbPrec) end function conky_Meteo_Soiree_VentDir(j) return conditionSoiree[tonumber(j)].VentDir end function conky_Meteo_Soiree_VentDirP(j) return conditionSoiree[tonumber(j)].VentP end function conky_Meteo_Soiree_VentForce(j) return tonumber(conditionSoiree[tonumber(j)].VentForce) end function conky_Meteo_Soiree_QPluie(j) return tonumber(conditionSoiree[tonumber(j)].QPluie) end function conky_Meteo_Soiree_QNeige(j) return tonumber(conditionSoiree[tonumber(j)].QNeige) end function conky_Meteo_Soiree_Humidite(j) return tonumber(conditionSoiree[tonumber(j)].Humidite) end function conky_Meteo_Soiree_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionSoiree[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_Soiree_Rose(j) return tonumber(conditionSoiree[tonumber(j)].PointRosee) end function conky_Meteo_Soiree_Visibilite(j) return tonumber(conditionSoiree[tonumber(j)].Visibilite) end function conky_Meteo_Soiree_IconeM(r, p, s, f, j) return "${image "..r.."/jour/"..conditionSoiree[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_Soiree_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionSoiree[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Nuit function conky_Meteo_Noct_CondMeteo(j) return conditionNoct[tonumber(j)].CondMeteo end function conky_Meteo_Noct_CondMeteo1(j) return conditionNoct[tonumber(j)].CondMeteo1 end function conky_Meteo_Noct_CondMeteo2(j) return conditionNoct[tonumber(j)].CondMeteo2 end function conky_Meteo_Noct_CondMeteo1se(j) return conditionNoct[tonumber(j)].CondMeteo1se end function conky_Meteo_Noct_CondMeteo2se(j) return conditionNoct[tonumber(j)].CondMeteo2se end function conky_Meteo_Noct_TempMax(j) return tonumber(conditionNoct[tonumber(j)].TempMax) end function conky_Meteo_Noct_TempMin(j) return tonumber(conditionNoct[tonumber(j)].TempMin) end function conky_Meteo_Noct_TempMaxRes(j) return tonumber(conditionNoct[tonumber(j)].TempMaxR) end function conky_Meteo_Noct_TempMinRes(j) return tonumber(conditionNoct[tonumber(j)].TempMinR) end function conky_Meteo_Noct_ProbPrec(j) return tonumber(conditionNoct[tonumber(j)].ProbPrec) end function conky_Meteo_Noct_VentDir(j) return conditionNoct[tonumber(j)].VentDir end function conky_Meteo_Noct_VentDirP(j) return conditionNoct[tonumber(j)].VentP end function conky_Meteo_Noct_VentForce(j) return tonumber(conditionNoct[tonumber(j)].VentForce) end function conky_Meteo_Noct_QPluie(j) return tonumber(conditionNoct[tonumber(j)].QPluie) end function conky_Meteo_Noct_QNeige(j) return tonumber(conditionNoct[tonumber(j)].QNeige) end function conky_Meteo_Noct_Humidite(j) return tonumber(conditionNoct[tonumber(j)].Humidite) end function conky_Meteo_Noct_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionNoct[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_Noct_Rose(j) return tonumber(conditionNoct[tonumber(j)].PointRosee) end function conky_Meteo_Noct_Visibilite(j) return tonumber(conditionNoct[tonumber(j)].Visibilite) end function conky_Meteo_Noct_IconeM(r, p, s, f, j) return "${image "..r.."/nuit/"..conditionNoct[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_Noct_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionNoct[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Huit prochaines heures function conky_Meteo_huitHeures_VentDirP(j) return huitHeures[tonumber(j)].VentP end function conky_Meteo_huitHeures_IconeV(r, p, s, f, j) return "${image "..r.."/"..huitHeures[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_huitHeures_Heure(j) return tonumber(huitHeures[tonumber(j)].Heure) end function conky_Meteo_huitHeures_IconeM(r, p, s, f, j) if huitHeures[tonumber(j)].Heure <= InfoJour[1].CoucherSoleilH and huitHeures[tonumber(j)].Heure >= InfoJour[1].LeverSoleilH then return "${image "..r.."/jour/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" else return "${image "..r.."/nuit/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end end function conky_Meteo_huitHeures_Temp(j) return tonumber(huitHeures[tonumber(j)].TempMax) end function conky_Meteo_huitHeures_TempR(j) return tonumber(huitHeures[tonumber(j)].TempMaxR) end function conky_Meteo_huitHeures_VentDir(j) return huitHeures[tonumber(j)].VentDir end function conky_Meteo_huitHeures_VentForce(j) return tonumber(huitHeures[tonumber(j)].VentForce) end function conky_Meteo_huitHeures_Humidite(j) return tonumber(huitHeures[tonumber(j)].Humidite) end function conky_Meteo_huitHeures_CouvNuage(j) return tonumber(huitHeures[tonumber(j)].CouvNuage) end function conky_Meteo_huitHeures_Rose(j) return tonumber(huitHeures[tonumber(j)].PointRosee) end function conky_Meteo_huitHeures_ProbPluie(j) return tonumber(huitHeures[tonumber(j)].Pluie) end function conky_Meteo_huitHeures_ProbNeige(j) return tonumber(huitHeures[tonumber(j)].Neige) end function conky_Meteo_huitHeures_ProbVerglas(j) return tonumber(huitHeures[tonumber(j)].Verglas) end function conky_Meteo_huitHeures_Uv(j) return tonumber(huitHeures[tonumber(j)].UV) 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(format) if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end format = string.gsub(format, "_", " ") return trad_date(os.date(format, Eclipse_partielle)) end function conky_Lune_EclipseTotal() if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end format = string.gsub(format, "_", " ") return trad_date(os.date(format, Eclipse_total)) end --Informations sur le lua function conky_Version() return Version end function conky_Meteo_fichier_init() return fichier_init end function conky_Meteo_etat_MAJ() return MAJ end --Sauvegarde des données function sauvegarde() --sauvegarde prévision for j = 1,jours do local file = assert(io.open(repsauv.."/prevision"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} for i = 1, 21 do file:write (conditionJour[j][t[i]], "\n") end t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} for i = 1, 20 do file:write (conditionNuit[j][t[i]], "\n") end t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"} for i = 1, 7 do file:write (InfoJour[j][t[i]], "\n") end io.close(file) if matin == "oui" then local file = assert(io.open(repsauv.."/matin"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionMatin[j][t[i]], "\n") end io.close(file) end if apresmidi == "oui" then local file = assert(io.open(repsauv.."/ApresMidi"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionAM[j][t[i]], "\n") end io.close(file) end if soiree == "oui" then local file = assert(io.open(repsauv.."/Soiree"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionSoiree[j][t[i]], "\n") end io.close(file) end if nuit == "oui" then local file = assert(io.open(repsauv.."/Nuit"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionNoct[j][t[i]], "\n") end io.close(file) end end if huit == "oui" then for j = 1,8 do local file = assert(io.open(repsauv.."/huitHeures"..j, "w+")) file:write ("\n") local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"} for i = 1, 15 do file:write (huitHeures[j][t[i]], "\n") end io.close(file) end end --sauvegarde lunaison local file = assert(io.open(repsauv.."/lunaison", "w+")) file:write ("\n", ephemerides, "\n") file:write (ephemerides1, "\n") file:write (ephemerides2, "\n") file:write (Visibilite, "\n") file:write (Phases, "\n") file:write (Phases1, "\n") file:write (Phases2, "\n") file:write (Noeud_lunaire, "\n") file:write (Apogee, "\n") file:write (Perigee, "\n") file:write (Distance, "\n") file:write (Age, "\n") file:write (Lever_LuneHeure, "\n") file:write (Lever_LuneMinute, "\n") file:write (Coucher_LuneHeure, "\n") file:write (Coucher_LuneMinute, "\n") file:write (Eclipse_partielle, "\n") file:write (Eclipse_total, "\n") io.close(file) --Sauvegarde condition courante local file = assert(io.open(repsauv.."/CondCour", "w+") ) file:write ("\n") local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"} for i = 1,23 do file:write (conditioncourante[t[i]], "\n") end file:write (time, "\n") io.close(file) --modification des droits utilisateur os.execute('chmod o+rw- '..r..'/*lun*') os.execute('chmod -R o+rw- '..repsauv) os.execute('chmod -R o+rw- '..Rep) end
Didier ligne 1409
function conky_Meteo_CouvNuage()
return tonumber(conditioncourante.CouvNuage
end
manque ) return tonumber(conditioncourante.CouvNuage)
Hors ligne
#1550 Le 16/11/2012, à 06:27
- Didier-T
Re : [Conky] Alternative à weather.com (2)
Didier-T a écrit :@ Phyllinux,
en effet, il y avait bien un soucis, situé au niveau de la restitution d'information.
sa devrait fonctionner mieux maintenant.
meteo.lua-- Créé par Didier-T (forum.ubuntu-fr.org) -- Nécessite imagemagick http://apt.ubuntu.com/p/imagemagick require "io" require "os" local Version = "v4.8" local conditionJour = {} local conditionNuit = {} local conditionMatin = {} local conditionAM = {} local conditionSoiree = {} local conditionNoct = {} local InfoJour = {} local conditioncourante = {} local huitHeures = {} local Rep, cmd, jours, matin, apresmidi, soiree, nuit, delais, r, repsauv, l, fichier_init, MAJ, tc, dermodif, VilleAdresse local Debug = "Problème Info " --Liste des accents et carractère non pris en charge par les patterns local pat="%é%è%à%ä%â%ê%ô%ç%É%È%À%Â%Ä%Ê%Ô%Ç" --Traduction date function trad_date(d) local date = d date = date:gsub("Monday", "Lundi"):gsub("Tuesday", "Mardi"):gsub("Wednesday", "Mercredi"):gsub("Thursday", "Jeudi"):gsub("Friday", "Vendredi"):gsub("Saturday", "Samedi"):gsub("Sunday", "Dimanche") date = date:gsub("lun", "Lun"):gsub("mar", "Mar"):gsub("mer", "Mer"):gsub("jeu", "Jeu"):gsub("ven", "Ven"):gsub("sam", "Sam"):gsub("dim", "Dim") date = date:gsub("Mon", "Lun"):gsub("Tue", "Mar"):gsub("Wed", "Mer"):gsub("Thu", "Jeu"):gsub("Fri", "Ven"):gsub("Sat", "Sam"):gsub("Sun", "Dim") date = date:gsub("January", "Janvier"):gsub("February", "Février"):gsub("March", "Mars"):gsub("April", "Avril"):gsub("May", "Mai"):gsub("June", "Juin"):gsub("July", "Juillet"):gsub("August", "Août"):gsub("September", "Septembre"):gsub("October", "Octobre"):gsub("November", "Novembre"):gsub("December", "Décembre") date = date:gsub("jan", "Jan"):gsub("fev", "Fév"):gsub("mar", "Mar"):gsub("avr", "Avr"):gsub("mai", "Mai"):gsub("jui", "Jui"):gsub("aou", "Aoû"):gsub("sep", "Sep"):gsub("oct", "Oct"):gsub("nov", "Nov"):gsub("dec", "Déc") date = date:gsub("Feb", "Fév"):gsub("Apr", "Avr"):gsub("May", "Mai"):gsub("Jun", "Juin"):gsub("Jul", "Juil"):gsub("Aug", "Aoû"):gsub("Dec", "Déc") return date end --Vérifier l'existence d'un fichier function existe(file) local a = io.open(file, "r") local present if a then present = true io.close(a) else present = false end return present end --Formatage des pages web function string.formatage(ligne) ligne = ligne:gsub("ô", "ô"):gsub("â", "â"):gsub("é", "é"):gsub("è", "è"):gsub("à", "à"):gsub("ç", "ç"):gsub("ê", "ê"):gsub("ö", "ö"):gsub("î", "î"):gsub("ï", "ï"):gsub("û", "û"):gsub("ü", "ü"):gsub("'", "'"):gsub("Poudreries", "Bourrasques de neige"):gsub("É", "É"):gsub("°",""):gsub("[\n\r]",""):gsub("é", "é") return ligne end --Traitement Huit prochaines heures function Huit_Heures(web) local f, i, line, heure1, heure2, heure3, heure4, heure5, heure6, heure7, heure8, icone1, icone2, icone3, icone4, icone5, icone6, icone7, icone8, Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Temp8, TempR1, TempR2, TempR3, TempR4, TempR5, TempR6, TempR7, TempR8, Humi1, Humi2, Humi3, Humi4, Humi5, Humi6, Humi7, Humi8, Pluie1, Pluie2, Pluie3, Pluie4, Pluie5, Pluie6, Pluie7, Pluie8, Neige1, Neige2, Neige3, Neige4, Neige5, Neige6, Neige7, Neige8, Verglas1, Verglas2, Verglas3, Verglas4, Verglas5, Verglas6, Verglas7, Verglas8, Vitesse1, Dir1, Vitesse2, Dir2, Vitesse3, Dir3, Vitesse4, Dir4, Vitesse5, Dir5, Vitesse6, Dir6, Vitesse7, Dir7, Vitesse8, Dir8, UV1, UV2, UV3, UV4, UV5, UV6, UV7, UV8, CouvNuage1, CouvNuage2, CouvNuage3, CouvNuage4, CouvNuage5, CouvNuage6, CouvNuage7, CouvNuage8, Rosee1, Rosee2, Rosee3, Rosee4, Rosee5, Rosee6, Rosee7, Rosee8, h, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A202 'hourly\"' | sed 's/%//g'")) line=f:read() i=0 for line in f:lines() do i=i+1 --Récup. des heures if i==8 then heure1=line:match("/>(%d*)</") elseif i==9 then heure2=line:match(">(%d*)</") elseif i==10 then heure3=line:match(">(%d*)</") elseif i==11 then heure4=line:match(">(%d*)</") elseif i==12 then heure5=line:match(">(%d*)</") elseif i==13 then heure6=line:match(">(%d*)</") elseif i==14 then heure7=line:match(">(%d*)</") elseif i==15 then heure8=line:match(">(%d*)</") --Récup. des icones elseif i==34 then icone1=line:match("i%p(%a*)\">") elseif i==37 then icone2=line:match("i%p(%a*)\">") elseif i==40 then icone3=line:match("i%p(%a*)\">") elseif i==43 then icone4=line:match("i%p(%a*)\">") elseif i==46 then icone5=line:match("i%p(%a*)\">") elseif i==49 then icone6=line:match("i%p(%a*)\">") elseif i==52 then icone7=line:match("i%p(%a*)\">") elseif i==55 then icone8=line:match("i%p(%a*)\">") --Températures elseif i==60 then Temp1=line:match(">([%p%d]*)&") elseif i==61 then Temp2=line:match(">([%p%d]*)&") elseif i==62 then Temp3=line:match(">([%p%d]*)&") elseif i==63 then Temp4=line:match(">([%p%d]*)&") elseif i==64 then Temp5=line:match(">([%p%d]*)&") elseif i==65 then Temp6=line:match(">([%p%d]*)&") elseif i==66 then Temp7=line:match(">([%p%d]*)&") elseif i==67 then Temp8=line:match(">([%p%d]*)&") --Températures ressentie elseif i==71 then TempR1=line:match(">([%p%d]*)&") elseif i==72 then TempR2=line:match(">([%p%d]*)&") elseif i==73 then TempR3=line:match(">([%p%d]*)&") elseif i==74 then TempR4=line:match(">([%p%d]*)&") elseif i==75 then TempR5=line:match(">([%p%d]*)&") elseif i==76 then TempR6=line:match(">([%p%d]*)&") elseif i==77 then TempR7=line:match(">([%p%d]*)&") elseif i==78 then TempR8=line:match(">([%p%d]*)&") --Humidité elseif i==82 then Humi1=line:match(">(%d*)<") elseif i==83 then Humi2=line:match(">(%d*)<") elseif i==84 then Humi3=line:match(">(%d*)<") elseif i==85 then Humi4=line:match(">(%d*)<") elseif i==86 then Humi5=line:match(">(%d*)<") elseif i==87 then Humi6=line:match(">(%d*)<") elseif i==88 then Humi7=line:match(">(%d*)<") elseif i==89 then Humi8=line:match(">(%d*)<") --Pluie elseif i==109 then Pluie1=line:match("v>(%d*)<") elseif i==110 then Pluie2=line:match("v>(%d*)<") elseif i==111 then Pluie3=line:match("v>(%d*)<") elseif i==112 then Pluie4=line:match("v>(%d*)<") elseif i==113 then Pluie5=line:match("v>(%d*)<") elseif i==114 then Pluie6=line:match("v>(%d*)<") elseif i==115 then Pluie7=line:match("v>(%d*)<") elseif i==116 then Pluie8=line:match("v>(%d*)<") --Neige elseif i==120 then Neige1=line:match("v>(%d*)<") elseif i==121 then Neige2=line:match("v>(%d*)<") elseif i==122 then Neige3=line:match("v>(%d*)<") elseif i==123 then Neige4=line:match("v>(%d*)<") elseif i==124 then Neige5=line:match("v>(%d*)<") elseif i==125 then Neige6=line:match("v>(%d*)<") elseif i==126 then Neige7=line:match("v>(%d*)<") elseif i==127 then Neige8=line:match("v>(%d*)<") --Verglas elseif i==131 then Verglas1=line:match("v>(%d*)<") elseif i==132 then Verglas2=line:match("v>(%d*)<") elseif i==133 then Verglas3=line:match("v>(%d*)<") elseif i==134 then Verglas4=line:match("v>(%d*)<") elseif i==135 then Verglas5=line:match("v>(%d*)<") elseif i==136 then Verglas6=line:match("v>(%d*)<") elseif i==137 then Verglas7=line:match("v>(%d*)<") elseif i==138 then Verglas8=line:match("v>(%d*)<") --Vent elseif i==159 then Vitesse1, Dir1=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP1=vent_plein(Dir1) elseif i==160 then Vitesse2, Dir2=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP2=vent_plein(Dir2) elseif i==161 then Vitesse3, Dir3=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP3=vent_plein(Dir3) elseif i==162 then Vitesse4, Dir4=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP4=vent_plein(Dir4) elseif i==163 then Vitesse5, Dir5=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP5=vent_plein(Dir5) elseif i==164 then Vitesse6, Dir6=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP6=vent_plein(Dir6) elseif i==165 then Vitesse7, Dir7=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP7=vent_plein(Dir7) elseif i==166 then Vitesse8, Dir8=line:gsub("W","O"):match(">(%d*)%s(%a*)<") VentP8=vent_plein(Dir8) --Uv elseif i==170 then UV1=line:match(">(%d*)<") elseif i==171 then UV2=line:match(">(%d*)<") elseif i==172 then UV3=line:match(">(%d*)<") elseif i==173 then UV4=line:match(">(%d*)<") elseif i==174 then UV5=line:match(">(%d*)<") elseif i==175 then UV6=line:match(">(%d*)<") elseif i==176 then UV7=line:match(">(%d*)<") elseif i==177 then UV8=line:match(">(%d*)<") --Couverture nuageuse elseif i==181 then CouvNuage1=line:match(">(%d*)<") elseif i==182 then CouvNuage2=line:match(">(%d*)<") elseif i==183 then CouvNuage3=line:match(">(%d*)<") elseif i==184 then CouvNuage4=line:match(">(%d*)<") elseif i==185 then CouvNuage5=line:match(">(%d*)<") elseif i==186 then CouvNuage6=line:match(">(%d*)<") elseif i==187 then CouvNuage7=line:match(">(%d*)<") elseif i==188 then CouvNuage8=line:match(">(%d*)<") --Point de rosée elseif i==192 then Rosee1=line:match(">([%p%d]*)&") elseif i==193 then Rosee2=line:match(">([%p%d]*)&") elseif i==194 then Rosee3=line:match(">([%p%d]*)&") elseif i==195 then Rosee4=line:match(">([%p%d]*)&") elseif i==196 then Rosee5=line:match(">([%p%d]*)&") elseif i==197 then Rosee6=line:match(">([%p%d]*)&") elseif i==198 then Rosee7=line:match(">([%p%d]*)&") elseif i==199 then Rosee8=line:match(">([%p%d]*)&") end end f:close() huitHeures[1] = {Heure=heure1, Icone=icone1, TempMax=Temp1, TempMaxR=TempR1, VentDir=Dir1, VentForce=Vitesse1, Humidite=Humi1, CouvNuage=CouvNuage1, PointRosee=Rosee1, UV=UV1, Pluie=Pluie1, Neige=Neige1, Verglas=Verglas1, VentP=VentP1} huitHeures[2] = {Heure=heure2, Icone=icone2, TempMax=Temp2, TempMaxR=TempR2, VentDir=Dir2, VentForce=Vitesse2, Humidite=Humi2, CouvNuage=CouvNuage2, PointRosee=Rosee2, UV=UV2, Pluie=Pluie2, Neige=Neige2, Verglas=Verglas2, VentP=VentP2} huitHeures[3] = {Heure=heure3, Icone=icone3, TempMax=Temp3, TempMaxR=TempR3, VentDir=Dir3, VentForce=Vitesse3, Humidite=Humi3, CouvNuage=CouvNuage3, PointRosee=Rosee3, UV=UV3, Pluie=Pluie3, Neige=Neige3, Verglas=Verglas3, VentP=VentP3} huitHeures[4] = {Heure=heure4, Icone=icone4, TempMax=Temp4, TempMaxR=TempR4, VentDir=Dir4, VentForce=Vitesse4, Humidite=Humi4, CouvNuage=CouvNuage4, PointRosee=Rosee4, UV=UV4, Pluie=Pluie4, Neige=Neige4, Verglas=Verglas4, VentP=VentP4} huitHeures[5] = {Heure=heure5, Icone=icone5, TempMax=Temp5, TempMaxR=TempR5, VentDir=Dir5, VentForce=Vitesse5, Humidite=Humi5, CouvNuage=CouvNuage5, PointRosee=Rosee5, UV=UV5, Pluie=Pluie5, Neige=Neige5, Verglas=Verglas5, VentP=VentP5} huitHeures[6] = {Heure=heure6, Icone=icone6, TempMax=Temp6, TempMaxR=TempR6, VentDir=Dir6, VentForce=Vitesse6, Humidite=Humi6, CouvNuage=CouvNuage6, PointRosee=Rosee6, UV=UV6, Pluie=Pluie6, Neige=Neige6, Verglas=Verglas6, VentP=VentP6} huitHeures[7] = {Heure=heure7, Icone=icone7, TempMax=Temp7, TempMaxR=TempR7, VentDir=Dir7, VentForce=Vitesse7, Humidite=Humi7, CouvNuage=CouvNuage7, PointRosee=Rosee7, UV=UV7, Pluie=Pluie7, Neige=Neige7, Verglas=Verglas7, VentP=VentP7} huitHeures[8] = {Heure=heure8, Icone=icone8, TempMax=Temp8, TempMaxR=TempR8, VentDir=Dir8, VentForce=Vitesse8, Humidite=Humi8, CouvNuage=CouvNuage8, PointRosee=Rosee8, UV=UV8, Pluie=Pluie8, Neige=Neige8, Verglas=Verglas8, VentP=VentP8} local t = {"VentP", "Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas"} for j = 1, 8 do local donee = {} donee = huitHeures[j] for i = 1,13 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug,"huitHeures ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end huitHeures[j] = donee end for h = 1,8 do if huitHeures[h].VentDir == "CLM" then huitHeures[h].VentDir = "Calme" huitHeures[h].VentForce = "0" end huitHeures[h].VentIcone = icone_vent(direction_vent(huitHeures[h].VentDir), huitHeures[h].VentForce) huitHeures[h].VentP = vent_plein(huitHeures[h].VentDir) end end --Traitement information Quart de journée function Prevision_Quart_T(web) local f, i, line, icone, cond, Tmax, Tmin, Tmaxres, Tminres, dirvent, forcevent, Precipitationpourcent, Pluie, Neige, Humidite,Couverture, Pointrosee, Visibilite, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A50 '/#detail-' | sed 's/%//g'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==4 then icone=line:match("icon i%p(%a*)\">") elseif i==5 then cond=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</") elseif i==6 then Tmax=line:match(">([%p%d]*)<s") elseif i==7 then Tmin=line:match("lo\">%a*%s([%p%d]*)<s") elseif i==10 then Tmaxres, Tminres=line:formatage():match("® ([%p%d]*) / ([%p%d]*)</") elseif i==27 then dirvent=line:gsub("W","O"):match("'(%a*)'") elseif i==28 then forcevent=line:match("'(%d*)[%a%p]*'") elseif i==38 then Precipitationpourcent=line:match(">(%d*)</") elseif i==39 then Pluie=line:match(">(%d*) %a*</") elseif i==40 then Neige=line:match(">(%d*) %a*</") elseif i==41 then Humidite=line:match(">(%d*)</") elseif i==42 then Couverture=line:match(">(%d*)</") elseif i==43 then Pointrosee=line:match(">([%p%d]*)&#") elseif i==44 then Visibilite=line:match(">(%d*) %a*</") end end f:close() return {Icone=icone, CondMeteo=cond, TempMax=Tmax, TempMin=Tmin, TempMaxR=Tmaxres, TempMinR=Tminres, VentDir=dirvent, VentForce=forcevent, Humidite=Humidite, CouvNuage=Couverture, PointRosee=Pointrosee, ProbPrec=Precipitationpourcent, Visibilite=Visibilite, QNeige=Neige, QPluie=Pluie} end --Prévision function prevision(web) local f, i, line, iconej, Tmax, Tmaxr, ProbPrecj, Vdirj, Vforcej, Vrafalesj, Descriptifj, UV, ProbOragesj, Precj, Pluiej, Neigej, Verglasj, iconen, Tmin, Tminr, ProbPrecn, Vdirn, Vforcen, Vrafalesn, Descriptifn, UVn, ProbOragesn, Precn, Pluien, Neigen, Verglasn, jour,mois, annee, AujoudhuiMax, NormaleMax, RecordMax, Histo_Max, AujoudhuiMin, NormaleMin, RecordMin, Histo_Min, LeverSoleil, LeverSoleilH, LeverSoleilM, Culmine, CulmineH, CulmineM, CoucherSoleil, CoucherSoleilH, CoucherSoleilM, Datej f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'")) line=f:read() i=0 for line in f:lines() do i=i+1 --jour if i==5 then iconej=line:match("icon i%p(%a*)\">") elseif i==6 then Tmax=line:match("temp\">([%p%d]*)<") elseif i==7 then Tmaxr=line:match("174; ([%p%d]*)&#") elseif i==8 then ProbPrecj=line:match("feel[%a%p%d]* (%d*)</") elseif i==40 then Vdirj, Vforcej=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<") elseif i==43 then Vrafalesj=line:match("> (%d*) [%a%p]*<") elseif i==47 then Descriptifj=line:formatage():gsub(";",""):match("<p>([%a%p%s"..pat.."]*)</p>") elseif i==51 then UV=line:match("g>(%d*)</s") elseif i==52 then ProbOragesj=line:match(">(%d*)</s") elseif i==53 then Precj=line:match(">(%d*) %a*</s") elseif i==54 then Pluiej=line:match(">(%d*) %a*</s") elseif i==55 then Neigej=line:match(">(%d*) %a*</s") elseif i==56 then Verglasj=line:match(">(%d*) %a*</s") --nuit elseif i==65 then iconen=line:match("icon i%p(%a*)\">") elseif i==66 then Tmin=line:match("temp\">([%p%d]*)<") elseif i==67 then Tminr=line:match("174; ([%p%d]*)&#") elseif i==68 then ProbPrecn=line:match("feel[%a%p%d]* (%d*)</") elseif i==101 then Vdirn, Vforcen=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<") elseif i==104 then Vrafalesn=line:match("> (%d*) [%a%p]*<") elseif i==108 then Descriptifn=line:formatage():gsub(";",""):match("<p>([%a%p%s"..pat.."]*)</p>") elseif i==112 then UVn=line:match("g>([%a%p%d]*)</s") elseif i==113 then ProbOragesn=line:match(">(%d*)</s") elseif i==114 then Precn=line:match(">(%d*) %a*</s") elseif i==115 then Pluien=line:match(">(%d*) %a*</s") elseif i==116 then Neigen=line:match(">(%d*) %a*</s") elseif i==117 then Verglasn=line:match(">(%d*) %a*</s") --historique elseif i==133 then jour,mois,annee=line:match("- (%d*)/(%d*)/(%d*)</") elseif i==151 then AujoudhuiMax=line:formatage():match(">([%d%a%p]*)</") elseif i==153 then NormaleMax=line:formatage():match(">([%d%a%p]*)</") elseif i==155 then RecordMax=line:formatage():match(">([%d%a%p]*)</") elseif i==157 then Histo_Max=line:formatage():match(">([%d%a%p]*)</") elseif i==162 then AujoudhuiMin=line:formatage():match(">([%d%a%p]*)</") elseif i==164 then NormaleMin=line:formatage():match(">([%d%a%p]*)</") elseif i==166 then RecordMin=line:formatage():match(">([%d%a%p]*)</") elseif i==168 then Histo_Min=line:formatage():match(">([%d%a%p]*)</") --Lever coucher soleil elseif i==185 then LeverSoleil,LeverSoleilH,LeverSoleilM=line:match(">((%d*):(%d*))<") elseif i==188 then Culmine, CulmineH, CulmineM=line:match(">((%d*):(%d*))<") elseif i==191 then CoucherSoleil,CoucherSoleilH,CoucherSoleilM=line:match(">((%d*):(%d*))<") end end f:close() Datej = os.time{year=annee, month=mois, day=jour, hour=0} return { Icone=iconej, CondMeteo=Descriptifj, Temp=Tmax, TempRes=Tmaxr, ProbPrec=ProbPrecj, VentDir=Vdirj, VentForce=Vforcej, VentRafales=Vrafalesj, Uv=UV, ProbOrage=ProbOragesj, NivPrec=Precj, QPluie=Pluiej, QNeige=Neigej, EVerglas=Verglasj }, { Icone=iconen, CondMeteo=Descriptifn, Temp=Tmin, TempRes=Tminr, ProbPrec=ProbPrecn, VentDir=Vdirn, VentForce=Vforcen, VentRafales=Vrafalesn, ProbOrage=ProbOragesn, NivPrec=Precn, QPluie=Pluien, QNeige=Neigen, EVerglas=Verglasn }, { Jour=Datej, LeverSoleil=LeverSoleil, LeverSoleilH=LeverSoleilH, LeverSoleilM=LeverSoleilM, CoucherSoleil=CoucherSoleil, CoucherSoleilH=CoucherSoleilH, CoucherSoleilM=CoucherSoleilM, Histo_Max=Histo_Max, Histo_Min=Histo_Min } end --Infos condition courante function current(web) local f, i, line, ville, lat, lon, icone, cur, temp, tempres, directvent, vitessevent, Humidite, Pression, Couvnuageuse, UV, Pointderosee, Precipitations, Visibilite, jour, mois, annee, Date, Dbg f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed -e 's/%//g' -e '/var apgWxInfoObj/,/\"detail-now\"/d' | grep -A60 'meta'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==2 then ville,lat,lon=line:match("city: '([%w%s%-]*)'[%s%w%p]*lat: '([%d%p]*)'[%s%w%p]*lon: '([%d%p]*)'") elseif i==5 then icone=line:match("icon i%p(%a*)\">") elseif i==6 then cur, temp, tempres=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</[%a%p%s]*temp\">([%p%d]*)<s[%w%p%s]*; ([%p%d]*)<s") elseif i==22 then directvent=line:gsub("W","O"):match("'(%a*)'") elseif i==23 then vitessevent=line:match("'(%d*)[%a%p]*'") elseif i==34 then Humidite=line:match("g>(%d*)</s") elseif i==35 then Pression=line:match("g>(%d*).") elseif i==36 then Couvnuageuse=line:match("g>(%d*)</s") elseif i==37 then UV=line:match("g>(%d*)</s") elseif i==38 then Pointderosee=line:match("g>([%p%d]*)°") elseif i==39 then Precipitations=line:formatage():match("g>(%d*) ") elseif i==40 then Visibilite=line:match("g>(%d*) ") elseif i==57 then jour, mois, annee=line:match(">[%a%d%p%s]* (%d*)/(%d*)/(%d*)<") end end f:close() Date = os.time{year=annee, month=mois, day=jour, hour=0} return {Icone=icone, Cond=cur, Temp=temp, Tempr=tempres, VentDir=directvent, VentForce=vitessevent, Humidite=Humidite, Pression=Pression, CouvNuage=Couvnuageuse, Uv=UV, PointRosee=Pointderosee, QPrec=Precipitations, Visibilite=Visibilite, Date=Date, Ville=ville, latitude=lat, longitude=lon} end --Infos lunaison function lunaison(r) local s, web, Lune web="http://www.calendrier-lunaire.net/" f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A53 'ephemerides\"' | sed 's/%//g'")) line=f:read() i=0 for line in f:lines() do i=i+1 if i==3 then icone=line:match("src=\"([%w%p]*)\"") elseif i==7 then ephemerides1, ephemerides2=line:formatage():match(">(%a*)</span> (%a*)<") elseif i==11 then Visibilite=line:match("\">([%d%p]*) <") elseif i==12 then Phases, Phases1, Phases2=line:formatage():match("\">(([%a%p%d"..pat.."]*),%s*([%a%p%d"..pat.."]*))</s") elseif i==13 then Noeud_lunaire=line:match("\">([%a%d%p%s]*)</s") elseif i==14 then Apogee=line:match("\">([%a%d%p%s]*)</s") elseif i==15 then Perigee=line:match("\">([%a%d%p%s]*)</s") elseif i==16 then Distance=line:match("\">(%d*) %a*</s") elseif i==18 then Age=line:match("\">([%a%d%s]*)</") elseif i==19 then Lever_LuneHeure, Lever_LuneMinute, Coucher_LuneHeure, Coucher_LuneMinute=line:match("\">([%d%p]*):([%d%p]*)</span>[%a%p%s]*;\">([%d%p]*):([%d%p]*)</") elseif i==48 then Eclipse_partielle=line:match("\">([%w%s]* <br /> [%d%p]*)</a>") elseif i==49 then Eclipse_total=line:match("\">([%w%s]* <br /> [%d%p]*)</a>") end end f:close() if Noeud_lunaire:match("(%d+)") ~= nil then Noeud_lunaire = Noeud_lunaire:match("(%d+)") end if Apogee:match("(%d+)") ~= nil then Apogee = Apogee:match("(%d+)") end if Perigee:match("(%d+)") ~= nil then Perigee = Perigee:match("(%d+)") end ephemerides = ephemerides1.." "..ephemerides2 Eclipse_partielle = datelune(Eclipse_partielle) Eclipse_total = datelune(Eclipse_total) s = "${exec wget --tries=3 -q -O "..r.."/lune.png http://www.calendrier-lunaire.net/"..icone.."}" conky_parse( s ) conky_parse( "${exec convert "..r.."/lune.png -transparent '#091a2a' "..r.."/lune.png}" ) end function datelune(d) local j, m, a, h, min = d:gsub("Janvier", "01"):gsub("Février", "02"):gsub("Mars", "03"):gsub("Avril", "04"):gsub("Mais", "05"):gsub("Juin", "06"):gsub("Juillet", "07"):gsub("Août", "08"):gsub("septembre", "09"):gsub("Octobre", "10"):gsub("Novembre", "11"):gsub("Décembre", "12"):match("(%d+) (%d+) (%d+) <br /> (%d+):(%d+)") d = os.time{year=a, month=m, day=j, hour=h, min=min} return d 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 <= Palier then n = d elseif f <= Palier*2 then n = d + 17 elseif f <= Palier*3 then n = d + 34 elseif f >= (Palier*3)+1 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, dm, dp if string.len(d) >= 22 then n = math.ceil(string.len(d)/2) dm = string.sub(d, 1, n) dp = string.sub(d, n) p1 = string.find(dp, " ") local b = 1 p2 = nil if string.find(dm, ' ') then while p2 == nil do b = b+1 p2 = string.find(dm, ' ', -b) end end if p1 ~= nil then p1 = n+p1-1 end if p1 == nil and p2 == nil then p1 = string.find(d, " ") end if p2 == nil then p2 = p1 end if p1 == nil then p1 = p2 end if p1-n >= n-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 --Information Matin function Prevision_Matin(a, j, x) local i = j+x conditionMatin[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionMatin[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionMatin ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionMatin[j]=donee if conditionMatin[j].VentDir == "CLM" then conditionMatin[j].VentDir = "Calme" conditionMatin[j].VentForce = "0" end conditionMatin[j].VentIcone = icone_vent(direction_vent(conditionMatin[j].VentDir), conditionMatin[j].VentForce) conditionMatin[j].VentP = vent_plein(conditionMatin[j].VentDir) conditionMatin[j].CondMeteo1, conditionMatin[j].CondMeteo2, conditionMatin[j].CondMeteo1se, conditionMatin[j].CondMeteo2se = decoupage(conditionMatin[j].CondMeteo) print("Matin "..j.." Ok") end --Information Après-midi function Prevision_AM(a, j, x) local i = j+x conditionAM[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionAM[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionAM ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionAM[j]=donee if conditionAM[j].VentDir == "CLM" then conditionAM[j].VentDir = "Calme" conditionAM[j].VentForce = "0" end conditionAM[j].VentIcone = icone_vent(direction_vent(conditionAM[j].VentDir), conditionAM[j].VentForce) conditionAM[j].VentP = vent_plein(conditionAM[j].VentDir) conditionAM[j].CondMeteo1, conditionAM[j].CondMeteo2, conditionAM[j].CondMeteo1se, conditionAM[j].CondMeteo2se = decoupage(conditionAM[j].CondMeteo) print("Apres Midi "..j.." Ok") end --Information Soirée function Prevision_Soiree(a, j, x) local i = j+x conditionSoiree[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionSoiree[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionSoiree ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionSoiree[j]=donee if conditionSoiree[j].VentDir == "CLM" then conditionSoiree[j].VentDir = "Calme" conditionSoiree[j].VentForce = "0" end conditionSoiree[j].VentIcone = icone_vent(direction_vent(conditionSoiree[j].VentDir), conditionSoiree[j].VentForce) conditionSoiree[j].VentP = vent_plein(conditionSoiree[j].VentDir) conditionSoiree[j].CondMeteo1, conditionSoiree[j].CondMeteo2, conditionSoiree[j].CondMeteo1se, conditionSoiree[j].CondMeteo2se = decoupage(conditionSoiree[j].CondMeteo) print("Soiree "..j.." Ok") end --Information Nuit function Prevision_Nuit(a, j, x) local i = j+x conditionNoct[j] = Prevision_Quart_T(a..'?day='..i) local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"} local donee = {} donee = conditionNoct[j] for i = 1,15 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionNoct ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionNoct[j]=donee if conditionNoct[j].VentDir == "CLM" then conditionNoct[j].VentDir = "Calme" conditionNoct[j].VentForce = "0" end conditionNoct[j].VentIcone = icone_vent(direction_vent(conditionNoct[j].VentDir), conditionNoct[j].VentForce) conditionNoct[j].VentP = vent_plein(conditionNoct[j].VentDir) conditionNoct[j].CondMeteo1, conditionNoct[j].CondMeteo2, conditionNoct[j].CondMeteo1se, conditionNoct[j].CondMeteo2se = decoupage(conditionNoct[j].CondMeteo) print("Nuit "..j.." Ok") end --Information Huit heures function Prevision_Huit_Heures(a) Huit_Heures(a) print("Huit prochaines heures Ok") end --Traitement infos prévisions (15 jours max) jour 1 = aujourd'hui function jour_n(a, j, x) local i = j+x conditionJour[j], conditionNuit[j], InfoJour[j] = prevision(a..'?day='..i) local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" } local donee = {} donee = conditionJour[j] for i = 1,14 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionJour ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionJour[j]=donee local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" } donee = conditionNuit[j] for i = 1,13 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditionNuit ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end conditionNuit[j]=donee local t = { "Jour", "LeverSoleil", "LeverSoleilH", "LeverSoleilM", "CoucherSoleil", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min" } donee = InfoJour[j] for i = 1,9 do if donee[t[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "InfoJour ", t[i]," jour n° ", j) donee[t[i]]="N/A" end end InfoJour[j]=donee 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].RafalesIcone = icone_vent(direction_vent(conditionJour[j].VentDir), conditionJour[j].VentRafales) conditionJour[j].VentP = 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].RafalesIcone = icone_vent(direction_vent(conditionNuit[j].VentDir), conditionNuit[j].VentRafales) conditionNuit[j].VentP = vent_plein(conditionNuit[j].VentDir) conditionNuit[j].CondMeteo1, conditionNuit[j].CondMeteo2, conditionNuit[j].CondMeteo1se, conditionNuit[j].CondMeteo2se = decoupage(conditionNuit[j].CondMeteo) print("Prévision "..j.." Ok") end --initialisation paramètres function conky_init(cfg) local cmd1, pos1 local home = os.getenv("HOME") cfg = string.gsub(cfg, "~", home) cfg = string.gsub(cfg, "$HOME", home) fichier_init = cfg local file = assert(io.open(cfg, "rb") ) local line = file:read() for line in file:lines() do pos1 = string.find(line, '#') if pos1 ~= nil then line = string.sub(line, 1, pos1-1) end pos1 = string.find(line, '=') if string.find(line, 'repsauv=') ~= nil then repsauv = string.sub(line, pos1+1) elseif string.find(line, 'TempShell=') ~= nil then r = string.sub(line, pos1+1) elseif string.find(line, 'web=') ~= nil then cmd1 = string.sub(line, pos1+1) elseif string.find(line, 'periode=') ~= nil then jours = string.sub(line, pos1+1) elseif string.find(line, 'matinée=') ~= nil then matin = string.sub(line, pos1+1) elseif string.find(line, 'am=') ~= nil then apresmidi = string.sub(line, pos1+1) elseif string.find(line, 'soiree=') ~= nil then soiree = string.sub(line, pos1+1) elseif string.find(line, 'nuit=') ~= nil then nuit = string.sub(line, pos1+1) elseif string.find(line, 'Prev8heures=') ~= nil then huit = string.sub(line, pos1+1) elseif string.find(line, 'Palier=') ~= nil then Palier = tonumber(string.sub(line, pos1+1)) elseif string.find(line, 'update=') ~= nil then delais = string.sub(line, pos1+1) end end io.close(file) r = r:gsub("~", home):gsub("$HOME", home) repsauv = repsauv:gsub("~", home):gsub("$HOME", home) VilleAdresse=string.match(cmd1, ".com/%a*/%a*/([%w%p%s]*)/%d*/%a*") print("", "version = "..Version.."\n", "web = "..cmd1.."\n", "Pévision Nb jours = "..jours.."\n", "Pévision Matin = "..matin.."\n", "Pévision Après Midi = "..apresmidi.."\n", "Pévision Soirée = "..soiree.."\n", "Pévision Nuit = "..nuit.."\n","Prévision sur 8 heures = "..huit.."\n", "Délais = "..delais.."\n", "Chemin de travail = "..r.."\n","Palier = "..Palier.."\n", "Chemin de sauvegarde = "..repsauv) --Création répertoire de travail l = cmd1:match("/(%d+)") if string.find(cmd1, 'forecast') ~= nil then pos1 = string.find(cmd1, '/weather') cmd = string.sub(cmd1, 0, pos1-1) else pos1 = string.find(cmd1, '/current') cmd = string.sub(cmd1, 0, pos1-1) end 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.."&& mkdir "..Rep) end --initialisation compteurs t = os.time()-delais tc = t start = 1 --Vérification existence repsauv if os.execute("cd "..repsauv) ~= 0 then --création de repsauv si inexistant local pos1 = 1 local chemin = nil local cheminsup = nil while pos1 ~= nil do pos1 = string.find(repsauv, '/', pos1+1) if pos1 ~= nil then cheminsup = string.sub(repsauv, pos1) chemin = string.gsub(repsauv, cheminsup, "") else cheminsup = "" chemin = repsauv end if os.execute("cd "..chemin) ~= 0 then os.execute("mkdir "..chemin) end end end if not existe(repsauv.."/CondCour") then conky_Meteo_enligne() end MAJ ="0" end --Mise à jour météo function conky_Meteo_Maj() local s = '${if_gw}${lua conky_Meteo_enligne}${else}${lua conky_Meteo_horsligne}${endif}' conky_parse( s ) return " " end --hors ligne récupération de données function conky_Meteo_horsligne() if dermodif == nil or dermodif ~= conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}") then dermodif=conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}") --Récupération dernière condition courante local file = assert(io.open(repsauv.."/CondCour", "r") ) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"} for i = 1,23 do conditioncourante[t[i]] = donee[i] end time = donee[24] io.close(file) --Récupération prévision for j = 1,jours do local file = assert(io.open(repsauv.."/prevision"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local info = {} local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} conditionJour[j] = {} for i = 1, 21 do info[t[i]] = donee[i] end conditionJour[j] = info local info1 = {} t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} conditionNuit[j] = {} for i = 22, 41 do info1[t[i-21]] = donee[i] end conditionNuit[j] = info1 local info2 = {} t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"} InfoJour[j] = {} for i = 42, 48 do info2[t[i-41]] = donee[i] end InfoJour[j] = info2 io.close(file) if matin == "oui" then local file = assert(io.open(repsauv.."/matin"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionMatin[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionMatin[j] = info3 io.close(file) end if apresmidi == "oui" then local file = assert(io.open(repsauv.."/ApresMidi"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionAM[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionAM[j] = info3 io.close(file) end if soiree == "oui" then local file = assert(io.open(repsauv.."/Soiree"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionSoiree[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionSoiree[j] = info3 io.close(file) end if nuit == "oui" then local file = assert(io.open(repsauv.."/Nuit"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} conditionNoct[j] = {} local info3 = {} for i = 1, 21 do info3[t[i]] = donee[i] end conditionNoct[j] = info3 io.close(file) end end if huit == "oui" then for j = 1,8 do local file = assert(io.open(repsauv.."/huitHeures"..j, "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"} huitHeures[j] = {} local info3 = {} for i = 1, 15 do info3[t[i]] = donee[i] end huitHeures[j] = info3 io.close(file) end end --Récupération lunaison local file = assert(io.open(repsauv.."/lunaison", "r")) local line = file:read() local i = 0 local donee = {} for line in file:lines() do i = i+1 donee[i] = line end ephemerides = donee[1] ephemerides1 = donee[2] ephemerides2 = donee[3] Visibilite = donee[4] Phases = donee[5] Phases1 = donee[6] Phases2 = donee[7] Noeud_lunaire = donee[8] Apogee = donee[9] Perigee = donee[10] Distance = donee[11] Age = donee[12] Lever_LuneHeure = donee[13] Lever_LuneMinute = donee[14] Coucher_LuneHeure = donee[15] Coucher_LuneMinute = donee[16] Eclipse_partielle = donee[17] Eclipse_total = donee[18] io.close(file) if MAJ == "0" then MAJ = "1" else MAJ = "0" end collectgarbage() end return "" end --en ligne mise à jour function conky_Meteo_enligne() local i if tonumber(delais) <= os.difftime(os.time(), t) then t = os.time() time = t conditioncourante.Date = nil while conditioncourante.Date == nil do conditioncourante = current(cmd..'/current-weather/'..l) local y = {"Icone", "Cond", "Temp", "Tempr", "VentDir", "VentForce", "Humidite", "Pression", "CouvNuage", "Uv", "PointRosee", "QPrec", "Visibilite", "Ville", "latitude","Date", "longitude"} local donee = conditioncourante for i = 1,17 do if donee[y[i]] == nil then local file = assert(io.open(repsauv.."/Debug", "a+")) file:write ("\n", Debug, "conditioncourante ", y[i]) donee[y[i]]="N/A" end end conditioncourante=donee if conditioncourante.VentDir == "CLM" then conditioncourante.VentDir = "Calme" conditioncourante.VentForce = "0" end if conditioncourante.Ville == "" then conditioncourante.Ville = VilleAdresse 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) print("Condition courante Ok") if 14400 <= os.difftime(os.time(), tc) or start == 1 then start = 2 tc = t 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 --infos matin si demandée if matin == "oui" then addr_week = cmd..'/morning-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_Matin(addr_week, i, 0) end else for i = 1,jours do Prevision_Matin(addr_week, i, 1) end end end --infos Après Midi si demandée if apresmidi == "oui" then addr_week = cmd..'/afternoon-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_AM(addr_week, i, 0) end else for i = 1,jours do Prevision_AM(addr_week, i, 1) end end end --infos Soirée si demandée if soiree == "oui" then addr_week = cmd..'/evening-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_Soiree(addr_week, i, 0) end else for i = 1,jours do Prevision_Soiree(addr_week, i, 1) end end end --infos Nuit si demandée if nuit == "oui" then addr_week = cmd..'/overnight-weather-forecast/'..l if conditioncourante.Date == InfoJour[1].Jour then for i = 1,jours do Prevision_Nuit(addr_week, i, 0) end else for i = 1,jours do Prevision_Nuit(addr_week, i, 1) end end end end -- fin mise à jour compète end if huit == "oui" then addr_week = cmd..'/hourly-weather-forecast/'..l Prevision_Huit_Heures(addr_week) end lunaison(r) print("lunaison Ok") --lancement sauvegarde if repsauv ~= nil then sauvegarde() end if MAJ == "0" then MAJ = "1" else MAJ = "0" end collectgarbage() print(os.difftime(os.time(), t).." seconde(s)") 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.."/jour/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}" else return "${image "..r.."/nuit/"..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) format = string.gsub(format, "_", " ") return trad_date(os.date(format, conditioncourante.Date)) end function conky_Meteo_Ville() return conditioncourante.Ville end function conky_Meteo_CouvNuage() return tonumber(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", time) end function conky_Meteo_Minute() return os.date("%M", time) 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_ProbPrec(j) return tonumber(conditionJour[tonumber(j)].ProbPrec) 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_EVerglas(j) return tonumber(conditionJour[tonumber(j)].EVerglas) 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 function conky_Meteo_Jour_IconeR(r, p, s, f, j) return "${image "..r.."/"..conditionJour[tonumber(j)].RafalesIcone.." -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_ProbPrec(j) return tonumber(conditionNuit[tonumber(j)].ProbPrec) 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_EVerglas(j) return tonumber(conditionNuit[tonumber(j)].EVerglas) 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 function conky_Meteo_Nuit_IconeR(r, p, s, f, j) return "${image "..r.."/"..conditionNuit[tonumber(j)].RafalesIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Infos sur la journée function conky_Meteo_Jour(format, j) format = string.gsub(format, "_", " ") return trad_date(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_LeverSoleil(j) return tonumber((InfoJour[tonumber(j)].LeverSoleilH*60)+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 function conky_Meteo_CoucherSoleil(j) return tonumber((InfoJour[tonumber(j)].CoucherSoleilH*60)+InfoJour[tonumber(j)].CoucherSoleilM) end function conky_Meteo_HDureeJour(j) return InfoJour[tonumber(j)].CoucherSoleilH-InfoJour[tonumber(j)].LeverSoleilH end function conky_Meteo_MDureeJour(j) return os.date("%M", ((((InfoJour[tonumber(j)].CoucherSoleilH*3600)-3600)+(InfoJour[tonumber(j)].CoucherSoleilM*60))-(((InfoJour[tonumber(j)].LeverSoleilH*3600))+(InfoJour[tonumber(j)].LeverSoleilM*60)))) end function conky_Meteo_Histo_Min(j) return InfoJour[tonumber(j)].Histo_Min end function conky_Meteo_Histo_Max(j) return InfoJour[tonumber(j)].Histo_Max end --Matin function conky_Meteo_Matin_CondMeteo(j) return conditionMatin[tonumber(j)].CondMeteo end function conky_Meteo_Matin_CondMeteo1(j) return conditionMatin[tonumber(j)].CondMeteo1 end function conky_Meteo_Matin_CondMeteo2(j) return conditionMatin[tonumber(j)].CondMeteo2 end function conky_Meteo_Matin_CondMeteo1se(j) return conditionMatin[tonumber(j)].CondMeteo1se end function conky_Meteo_Matin_CondMeteo2se(j) return conditionMatin[tonumber(j)].CondMeteo2se end function conky_Meteo_Matin_TempMax(j) return tonumber(conditionMatin[tonumber(j)].TempMax) end function conky_Meteo_Matin_TempMin(j) return tonumber(conditionMatin[tonumber(j)].TempMin) end function conky_Meteo_Matin_TempMaxRes(j) return tonumber(conditionMatin[tonumber(j)].TempMaxR) end function conky_Meteo_Matin_TempMinRes(j) return tonumber(conditionMatin[tonumber(j)].TempMinR) end function conky_Meteo_Matin_ProbPrec(j) return tonumber(conditionMatin[tonumber(j)].ProbPrec) end function conky_Meteo_Matin_VentDir(j) return conditionMatin[tonumber(j)].VentDir end function conky_Meteo_Matin_VentDirP(j) return conditionMatin[tonumber(j)].VentP end function conky_Meteo_Matin_VentForce(j) return tonumber(conditionMatin[tonumber(j)].VentForce) end function conky_Meteo_Matin_QPluie(j) return tonumber(conditionMatin[tonumber(j)].QPluie) end function conky_Meteo_Matin_QNeige(j) return tonumber(conditionMatin[tonumber(j)].QNeige) end function conky_Meteo_Matin_Humidite(j) return tonumber(conditionMatin[tonumber(j)].Humidite) end function conky_Meteo_Matin_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionMatin[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_Matin_Rose(j) return tonumber(conditionMatin[tonumber(j)].PointRosee) end function conky_Meteo_Matin_Visibilite(j) return tonumber(conditionMatin[tonumber(j)].Visibilite) end function conky_Meteo_Matin_IconeM(r, p, s, f, j) return "${image "..r.."/jour/"..conditionMatin[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_Matin_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionMatin[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Après Midi function conky_Meteo_AM_CondMeteo(j) return conditionAM[tonumber(j)].CondMeteo end function conky_Meteo_AM_CondMeteo1(j) return conditionAM[tonumber(j)].CondMeteo1 end function conky_Meteo_AM_CondMeteo2(j) return conditionAM[tonumber(j)].CondMeteo2 end function conky_Meteo_AM_CondMeteo1se(j) return conditionAM[tonumber(j)].CondMeteo1se end function conky_Meteo_AM_CondMeteo2se(j) return conditionAM[tonumber(j)].CondMeteo2se end function conky_Meteo_AM_TempMax(j) return tonumber(conditionAM[tonumber(j)].TempMax) end function conky_Meteo_AM_TempMin(j) return tonumber(conditionAM[tonumber(j)].TempMin) end function conky_Meteo_AM_TempMaxRes(j) return tonumber(conditionAM[tonumber(j)].TempMaxR) end function conky_Meteo_AM_TempMinRes(j) return tonumber(conditionAM[tonumber(j)].TempMinR) end function conky_Meteo_AM_ProbPrec(j) return tonumber(conditionAM[tonumber(j)].ProbPrec) end function conky_Meteo_AM_VentDir(j) return conditionAM[tonumber(j)].VentDir end function conky_Meteo_AM_VentDirP(j) return conditionAM[tonumber(j)].VentP end function conky_Meteo_AM_VentForce(j) return tonumber(conditionAM[tonumber(j)].VentForce) end function conky_Meteo_AM_QPluie(j) return tonumber(conditionAM[tonumber(j)].QPluie) end function conky_Meteo_AM_QNeige(j) return tonumber(conditionAM[tonumber(j)].QNeige) end function conky_Meteo_AM_Humidite(j) return tonumber(conditionAM[tonumber(j)].Humidite) end function conky_Meteo_AM_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionAM[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_AM_Rose(j) return tonumber(conditionAM[tonumber(j)].PointRosee) end function conky_Meteo_AM_Visibilite(j) return tonumber(conditionAM[tonumber(j)].Visibilite) end function conky_Meteo_AM_IconeM(r, p, s, f, j) return "${image "..r.."/jour/"..conditionAM[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_AM_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionAM[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Soirée function conky_Meteo_Soiree_CondMeteo(j) return conditionSoiree[tonumber(j)].CondMeteo end function conky_Meteo_Soiree_CondMeteo1(j) return conditionSoiree[tonumber(j)].CondMeteo1 end function conky_Meteo_Soiree_CondMeteo2(j) return conditionSoiree[tonumber(j)].CondMeteo2 end function conky_Meteo_Soiree_CondMeteo1se(j) return conditionSoiree[tonumber(j)].CondMeteo1se end function conky_Meteo_Soiree_CondMeteo2se(j) return conditionSoiree[tonumber(j)].CondMeteo2se end function conky_Meteo_Soiree_TempMax(j) return tonumber(conditionSoiree[tonumber(j)].TempMax) end function conky_Meteo_Soiree_TempMin(j) return tonumber(conditionSoiree[tonumber(j)].TempMin) end function conky_Meteo_Soiree_TempMaxRes(j) return tonumber(conditionSoiree[tonumber(j)].TempMaxR) end function conky_Meteo_Soiree_TempMinRes(j) return tonumber(conditionSoiree[tonumber(j)].TempMinR) end function conky_Meteo_Soiree_ProbPrec(j) return tonumber(conditionSoiree[tonumber(j)].ProbPrec) end function conky_Meteo_Soiree_VentDir(j) return conditionSoiree[tonumber(j)].VentDir end function conky_Meteo_Soiree_VentDirP(j) return conditionSoiree[tonumber(j)].VentP end function conky_Meteo_Soiree_VentForce(j) return tonumber(conditionSoiree[tonumber(j)].VentForce) end function conky_Meteo_Soiree_QPluie(j) return tonumber(conditionSoiree[tonumber(j)].QPluie) end function conky_Meteo_Soiree_QNeige(j) return tonumber(conditionSoiree[tonumber(j)].QNeige) end function conky_Meteo_Soiree_Humidite(j) return tonumber(conditionSoiree[tonumber(j)].Humidite) end function conky_Meteo_Soiree_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionSoiree[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_Soiree_Rose(j) return tonumber(conditionSoiree[tonumber(j)].PointRosee) end function conky_Meteo_Soiree_Visibilite(j) return tonumber(conditionSoiree[tonumber(j)].Visibilite) end function conky_Meteo_Soiree_IconeM(r, p, s, f, j) return "${image "..r.."/jour/"..conditionSoiree[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_Soiree_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionSoiree[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Nuit function conky_Meteo_Noct_CondMeteo(j) return conditionNoct[tonumber(j)].CondMeteo end function conky_Meteo_Noct_CondMeteo1(j) return conditionNoct[tonumber(j)].CondMeteo1 end function conky_Meteo_Noct_CondMeteo2(j) return conditionNoct[tonumber(j)].CondMeteo2 end function conky_Meteo_Noct_CondMeteo1se(j) return conditionNoct[tonumber(j)].CondMeteo1se end function conky_Meteo_Noct_CondMeteo2se(j) return conditionNoct[tonumber(j)].CondMeteo2se end function conky_Meteo_Noct_TempMax(j) return tonumber(conditionNoct[tonumber(j)].TempMax) end function conky_Meteo_Noct_TempMin(j) return tonumber(conditionNoct[tonumber(j)].TempMin) end function conky_Meteo_Noct_TempMaxRes(j) return tonumber(conditionNoct[tonumber(j)].TempMaxR) end function conky_Meteo_Noct_TempMinRes(j) return tonumber(conditionNoct[tonumber(j)].TempMinR) end function conky_Meteo_Noct_ProbPrec(j) return tonumber(conditionNoct[tonumber(j)].ProbPrec) end function conky_Meteo_Noct_VentDir(j) return conditionNoct[tonumber(j)].VentDir end function conky_Meteo_Noct_VentDirP(j) return conditionNoct[tonumber(j)].VentP end function conky_Meteo_Noct_VentForce(j) return tonumber(conditionNoct[tonumber(j)].VentForce) end function conky_Meteo_Noct_QPluie(j) return tonumber(conditionNoct[tonumber(j)].QPluie) end function conky_Meteo_Noct_QNeige(j) return tonumber(conditionNoct[tonumber(j)].QNeige) end function conky_Meteo_Noct_Humidite(j) return tonumber(conditionNoct[tonumber(j)].Humidite) end function conky_Meteo_Noct_CouvNuage(j, r) if r == nil then r = 100 end local Couv = (tonumber(conditionNoct[tonumber(j)].CouvNuage) / 100) * r if Couv - math.floor(Couv) <= 0.5 then Couv = math.floor(Couv) else Couv = math.ceil(Couv) end return Couv end function conky_Meteo_Noct_Rose(j) return tonumber(conditionNoct[tonumber(j)].PointRosee) end function conky_Meteo_Noct_Visibilite(j) return tonumber(conditionNoct[tonumber(j)].Visibilite) end function conky_Meteo_Noct_IconeM(r, p, s, f, j) return "${image "..r.."/nuit/"..conditionNoct[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_Noct_IconeV(r, p, s, f, j) return "${image "..r.."/"..conditionNoct[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end --Huit prochaines heures function conky_Meteo_huitHeures_VentDirP(j) return huitHeures[tonumber(j)].VentP end function conky_Meteo_huitHeures_IconeV(r, p, s, f, j) return "${image "..r.."/"..huitHeures[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}" end function conky_Meteo_huitHeures_Heure(j) return tonumber(huitHeures[tonumber(j)].Heure) end function conky_Meteo_huitHeures_IconeM(r, p, s, f, j) if huitHeures[tonumber(j)].Heure <= InfoJour[1].CoucherSoleilH and huitHeures[tonumber(j)].Heure >= InfoJour[1].LeverSoleilH then return "${image "..r.."/jour/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" else return "${image "..r.."/nuit/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}" end end function conky_Meteo_huitHeures_Temp(j) return tonumber(huitHeures[tonumber(j)].TempMax) end function conky_Meteo_huitHeures_TempR(j) return tonumber(huitHeures[tonumber(j)].TempMaxR) end function conky_Meteo_huitHeures_VentDir(j) return huitHeures[tonumber(j)].VentDir end function conky_Meteo_huitHeures_VentForce(j) return tonumber(huitHeures[tonumber(j)].VentForce) end function conky_Meteo_huitHeures_Humidite(j) return tonumber(huitHeures[tonumber(j)].Humidite) end function conky_Meteo_huitHeures_CouvNuage(j) return tonumber(huitHeures[tonumber(j)].CouvNuage) end function conky_Meteo_huitHeures_Rose(j) return tonumber(huitHeures[tonumber(j)].PointRosee) end function conky_Meteo_huitHeures_ProbPluie(j) return tonumber(huitHeures[tonumber(j)].Pluie) end function conky_Meteo_huitHeures_ProbNeige(j) return tonumber(huitHeures[tonumber(j)].Neige) end function conky_Meteo_huitHeures_ProbVerglas(j) return tonumber(huitHeures[tonumber(j)].Verglas) end function conky_Meteo_huitHeures_Uv(j) return tonumber(huitHeures[tonumber(j)].UV) 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(format) if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end format = string.gsub(format, "_", " ") return trad_date(os.date(format, Eclipse_partielle)) end function conky_Lune_EclipseTotal() if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end format = string.gsub(format, "_", " ") return trad_date(os.date(format, Eclipse_total)) end --Informations sur le lua function conky_Version() return Version end function conky_Meteo_fichier_init() return fichier_init end function conky_Meteo_etat_MAJ() return MAJ end --Sauvegarde des données function sauvegarde() --sauvegarde prévision for j = 1,jours do local file = assert(io.open(repsauv.."/prevision"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} for i = 1, 21 do file:write (conditionJour[j][t[i]], "\n") end t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"} for i = 1, 20 do file:write (conditionNuit[j][t[i]], "\n") end t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"} for i = 1, 7 do file:write (InfoJour[j][t[i]], "\n") end io.close(file) if matin == "oui" then local file = assert(io.open(repsauv.."/matin"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionMatin[j][t[i]], "\n") end io.close(file) end if apresmidi == "oui" then local file = assert(io.open(repsauv.."/ApresMidi"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionAM[j][t[i]], "\n") end io.close(file) end if soiree == "oui" then local file = assert(io.open(repsauv.."/Soiree"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionSoiree[j][t[i]], "\n") end io.close(file) end if nuit == "oui" then local file = assert(io.open(repsauv.."/Nuit"..j, "w+")) file:write ("\n") local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"} for i = 1, 21 do file:write (conditionNoct[j][t[i]], "\n") end io.close(file) end end if huit == "oui" then for j = 1,8 do local file = assert(io.open(repsauv.."/huitHeures"..j, "w+")) file:write ("\n") local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"} for i = 1, 15 do file:write (huitHeures[j][t[i]], "\n") end io.close(file) end end --sauvegarde lunaison local file = assert(io.open(repsauv.."/lunaison", "w+")) file:write ("\n", ephemerides, "\n") file:write (ephemerides1, "\n") file:write (ephemerides2, "\n") file:write (Visibilite, "\n") file:write (Phases, "\n") file:write (Phases1, "\n") file:write (Phases2, "\n") file:write (Noeud_lunaire, "\n") file:write (Apogee, "\n") file:write (Perigee, "\n") file:write (Distance, "\n") file:write (Age, "\n") file:write (Lever_LuneHeure, "\n") file:write (Lever_LuneMinute, "\n") file:write (Coucher_LuneHeure, "\n") file:write (Coucher_LuneMinute, "\n") file:write (Eclipse_partielle, "\n") file:write (Eclipse_total, "\n") io.close(file) --Sauvegarde condition courante local file = assert(io.open(repsauv.."/CondCour", "w+") ) file:write ("\n") local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"} for i = 1,23 do file:write (conditioncourante[t[i]], "\n") end file:write (time, "\n") io.close(file) --modification des droits utilisateur os.execute('chmod o+rw- '..r..'/*lun*') os.execute('chmod -R o+rw- '..repsauv) os.execute('chmod -R o+rw- '..Rep) end
Didier ligne 1409
function conky_Meteo_CouvNuage() return tonumber(conditioncourante.CouvNuage end
manque ) return tonumber(conditioncourante.CouvNuage)
Arrrrggggg......
je modifie ça de suite, merci.
Hors ligne