Bonjour Didier-T et merci.
Je veux utiliser le template1 Jour_XXX ou Nuit_XXX en fonction de l'heure effective, car
conky_Meteo_VentRafales() n'existe pas (en fait la donnée conditioncourante.rafales).
meteo.cfg
# Créé par jpdipsy (forum.ubuntu-fr.org)
#Répertoire de sauvegarde
repsauv=/home/user/conky/meteo
#Répertoire temporaire
TempShell=/tmp
#Copier votre adresse Accuweather ici
web=http://www.accuweather.com/fr/fr/nice/132561/weather-forecast/132561
#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=200
#Alertes
rafale=15
neige=1
verglas=1
pluie=50
visibilité=5
meteo.lua
les variables de comparaison sont déclarées ainsi :
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)
elseif string.find(line, 'lune=') ~= nil then
afflune = string.sub(line, pos1+1)
elseif string.find(line, 'rafale=') ~= nil then
rafale = string.sub(line, pos1+1)
elseif string.find(line, 'neige=') ~= nil then
neige = string.sub(line, pos1+1)
elseif string.find(line, 'verglas=') ~= nil then
verglas = string.sub(line, pos1+1)
elseif string.find(line, 'pluie=') ~= nil then
pluie = string.sub(line, pos1+1)
elseif string.find(line, 'visibilité=') ~= nil then
visibilite = string.sub(line, pos1+1)
end
end
print(afflune)
print(rafale)
cette fonction a été ajouté avec l'ensemble des fonctions conky_Meteo_ courantes :
(testé aussi avec les conditions Jour)
function conky_Meteo_Alerte(j)
local n = 0
local j = 1
if conky_Meteo_Jour_VentRafales(j) >= rafale then n = 1
end
if conky_Meteo_Jour_QNeige(j) >= neige then n = 2
end
if conky_Meteo_Jour_EVerglas(j) >= verglas then n = 3
end
if conky_Meteo_Jour_Visibilite(j) >= visibilite then n = 4
end
if n > 0 then Alerte = "Alerte/n" else Alerte = "Il n'y pas d'alerte pour le moment"
end
print (Alerte)
print (n)
print ("Alerte Ok")
return Alerte
end
.conkyrc
# -- Conky settings -- #
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
# Window specifications
own_window no
own_window_type desktop
own_window_transparent yes
# own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
minimum_size 1000 1500
maximum_width 400
alignment tm
gap_x 0
gap_y 10
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# -- Text settings -- #
use_xft yes
xftfont MaiandraGD:size=10
xftalpha 0.4
uppercase no
default_color 8b8b8b
# -- Déclaration template -- #
#template0 ${image Repscripts/images/\1 -p \2 -s \3}
template0 ${image /home/user/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 \8}
# -- 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/user/conky/script/meteo.lua
lua_startup_hook init /home/user/conky/script/meteo.cfg
${template1 Maj}
#${template1 horsligne}
TEXT
9e9e00
#### Lancement du script récupérant les données météo ####
${font LED_mono :style=Medium:size=10}
${template1 Maj}
${template1 horsligne}
#Date du jour selon le format définit
${voffset -24}${goto 600}${color yellow}En ce ${template1 Date %A}
${color 9e9e00}${template1 Ville} ${color 858400}${hr}${color 8b8b8b}
${voffset -4}${goto 807}${color 272b26}${lua conky_Version}bis${color 8b8b8b}
#Condition courante
#T° Actuelle:
${voffset -0}${goto 573}${font LED_mono :style=Medium:size=50}${if_match ${template1 TempAct}<5}${color 0496ff}${blink ${template1 TempAct}°}$else${if_match ${template1 TempAct}<7}${color 0496ff}${template1 TempAct}°$else${if_match ${template1 TempAct}<13}${color 04d9ff}${template1 TempAct}°$else${if_match ${template1 TempAct}<17}${color white}${template1 TempAct}°$else${if_match ${template1 TempAct}<22}${color orange}${template1 TempAct}°$else${if_match ${template1 TempAct}<25}${color yellow}${template1 TempAct°}$else${if_match ${template1 TempAct}<32}${color red}${template1 TempAct}°$else${color red}${blink ${template1 TempAct}°}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${color 8b8b8b}
${voffset -120}${goto 668} ${color 8b8b8b}${font LED_mono :style=Medium:size=10}- T° Ressentie: ${if_match ${template1 TempRes}<5}${color 0496ff}${blink ${template1 TempRes}}$else${if_match ${template1 TempRes}<7}${color 0496ff}${template1 TempRes}$else${if_match ${template1 TempRes}<13}${color 04d9ff}${template1 TempRes}$else${if_match ${template1 TempRes}<17}${color white}${template1 TempRes}$else${if_match ${template1 TempAct}<22}${color orange}${template1 TempRes}$else${if_match ${template1 TempRes}<25}${color yellow}${template1 TempRes}$else${if_match ${template1 TempRes}<32}${color red}${template1 TempRes}$else${color red}${blink ${template1 TempRes}}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${color 8b8b8b}${goto 800}°C
${goto 685} - Humidité: ${if_match ${template1 Humidite}<90}${color 6b8aff}${template1 Humidite}$else${color yellow}${blink ${template1 Humidite}}${endif}${color 8b8b8b}${goto 785}%
#Condition météo sur une ligne #Icone metéo
${template2 IconeM /home/user/conky/meteo/icones 1,80 132x79}
${color white}${voffset 30}${goto 500}${template1 CondMeteo1}
${voffset -58}${goto 689}- Visibilité: ${if_match ${template1 Visibilite}<5}${color red}${blink ${template1 Visibilite}}$else${if_match ${template1 Visibilite}<10}${color yellow}${blink ${template1 Visibilite}}$else${if_match ${template1 Visibilite}<20}${color orange}${blink ${template1 Visibilite}}$else${color white}${template1 Visibilite}${endif}${endif}${endif}${color 8b8b8b}${goto 780}m
${goto 689}- Indice UV: ${template1 Uv}
${voffset -0}${goto 689}- P. atmos: ${template1 Pression} Pas.
${goto 689}- Point de rosée: ${template1 Rose}°C
${goto 470}*Risque de pluie: ${template1 Jour_ProbPrec} % * ${goto 640}*Risque d'orage: ${template1 Jour_ProbOrage} % *
${voffset -7}${hr}
${voffset -3}${goto 550}Durée du jour: ${template1 HDureeJour}h${template1 MDureeJour}mn${if_match ${template1 DiffDureeJour}>0} ${color green}(+${template1 DiffDureeJour}mn)$else ${color red}(${template1 DiffDureeJour}mn)${endif}${color 8b8b8b}
${goto 535}* Lever : ${template1 HLeverSoleil}:${template1 MLeverSoleil} * * Coucher : ${template1 HCoucherSoleil}:${template1 MCoucherSoleil} *
${voffset -7}${color 858400}Vent ${hr}${color 8b8b8b}
${voffset 1}${goto 475} ${template1 VentForce} km/h
${template2 IconeV /home/user/conky/meteo/icones/vent 20,255 90x35}
${voffset 22}${goto 487}${color white}${template1 VentDirP}
${voffset -62}${goto 650}- Risque de Rafales : ${template1 Jour_VentRafales} Km/h
${goto 600}- Vitesse moyenne du vent : ${template1 Jour_VentForce} Km/h
${template1 Alerte}lol
Enfin, pour les templates, effectivement. J'aurais du mieux lire mon .conkrc.
Merci Didier-T.
J'aimerais également savoir comment tester l'existence d'un fichier.