====== Conky : météo ====== ===== Fichier conkyrc ===== background yes use_xft yes xftalpha 0.8 xftfont Bitstream Vera Sans Mono:size=8 own_window yes own_window_class conky own_window_argb_visual yes own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below own_window_transparent yes double_buffer yes no_buffers yes minimum_size 356 700 maximum_width 356 alignment tr override_utf8_locale yes default_color slategrey TEXT ${color lightgrey}Météo ${execi 120 ~/.conky/scripts/meteo.sh CODE-LIEU} ${color}Aujourd'hui: ${color lightgrey}${execi 120 ~/.conky/scripts/meteo2p.sh "Température aujourd'hui"}, ${execi 120 ~/.conky/scripts/meteo2p.sh "Conditions aujourd'hui"} ${color}Vent: ${color lightgrey}${execi 120 ~/.conky/scripts/meteo2p.sh "Vent aujourd'hui"} ${color}Demain: ${color lightgrey}${execi 120 ~/.conky/scripts/meteo2p.sh "Température demain"}, ${execi 120 ~/.conky/scripts/meteo2p.sh "Conditions demain"} ${color}Lever du soleil: ${color lightgrey}${execi 120 ~/.conky/scripts/meteo2p.sh "Lever du soleil"} ${color}Coucher du soleil: ${color lightgrey}${execi 120 ~/.conky/scripts/meteo2p.sh "Coucher du soleil"} ===== Script Shell 1 ===== #!/bin/bash # Répertoire de ce script et du XSLT RUNDIR=~/.conky # Emplacement du XSLT XSLT=$RUNDIR/meteo.xslt # Fichier de destination des informations DESTFILE=/tmp/conky_meteo.txt # Emplacement de xsltproc XSLTCMD=/usr/bin/xsltproc # Traitement URL="http://xml.weather.com/weather/local/$1?cc=*&unit=m&dayf=2" w3m -dump $URL | $XSLTCMD $XSLT - > $DESTFILE ===== Script Shell 2 ===== #!/bin/bash # Fichier où sont stockées les informations SRCFILE=/tmp/conky_meteo.txt # Traitement RESULTAT=$(grep "$1" $SRCFILE | awk -F " : " '{print $2}') # Transformation de la condition en lettre qui deviendra une icône if echo "$1" | grep -i -q 'condition'; then if echo "$RESULTAT" | grep -i -q 'partly cloudy'; then RESULTAT='ciel voilé' elif echo "$RESULTAT" | grep -i -q 'mostly cloudy'; then RESULTAT='plutôt nuageux' elif echo "$RESULTAT" | grep -i -q 'clear'; then RESULTAT='clair' elif echo "$RESULTAT" | grep -i -q 'fair'; then RESULTAT='beau' elif echo "$RESULTAT" | grep -i -q 'sunny'; then RESULTAT='ensoleillé' elif echo "$RESULTAT" | grep -i -q 'cloudy'; then RESULTAT='nuageux' elif echo "$RESULTAT" | grep -E -i -q 'storm|thunder'; then RESULTAT='tempête' elif echo "$RESULTAT" | grep -i -q 'snow'; then RESULTAT='neige' elif echo "$RESULTAT" | grep -i -q 'rain'; then RESULTAT='pluie' elif echo "$RESULTAT" | grep -i -q 'shower'; then RESULTAT='averses' fi # Transformation des heures à l'américaine (5:50 AM) en heures à la française (5h50) elif echo "$1" | grep -i -q 'soleil'; then RESULTAT=$(echo "$RESULTAT" | awk '{print $1}' | sed -e s/:/h/g) # Transformation des heures PM (9h38 PM) en heures françaises (21h38) if echo "$1" | grep -i -q 'coucher'; then HEURES=$(echo "$RESULTAT" | awk -F "h" '{print $1}') MINUTES=$(echo "$RESULTAT" | awk -F "h" '{print $2}') HEURES=$(($HEURES + 12)) RESULTAT="${HEURES}h${MINUTES}" fi # Transformation de "Ville, Pays" en "Ville" elif echo "$1" | grep -i -q 'ville'; then RESULTAT=$(echo "$RESULTAT" | awk -F "," '{print $1}') fi # Affichage du résultat echo $RESULTAT ===== Feuille de style XSLT ===== Ville : Lever du soleil : Coucher du soleil : Température aujourd'hui : ° ( ° ressenti) Conditions aujourd'hui : Vent aujourd'hui : 0 Température demain : de ° à ° Conditions demain :