Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # -------------------------------------------------------------------------
- # R. Suinot <remi -at- suinot.org>
- # 05 Fev.2016
- # Rev. 10 Fev.2016
- # image satellite en fond d'écranr
- # renouvelable tous les jours
- # Utilisation:
- # placer le script dans /usr/local/bin/
- # chmod +x /usr/local/bin/meteo.sh
- # installer la crontab sans oublier l'export du DISPLAY:
- # 0 3 * * * export DISPLAY=:0.0 && /usr/local/bin/meteo.sh
- # -------------------------------------------------------------------------
- #
- # A faire: utiliser une notification avec notify-send ou zenity par la crontab
- #
- # -------------------------------------------------------------------------
- # toutes les trois heures, une image nouvelle!
- # curl -A "Mozilla/4.0" http://static.die.net/earth/mercator/1600.jpg -o 1600.jpg
- # curl envoi une requette sous le nom de mozilla sinon cela ne fonctionne pas!
- log="/tmp/mod-papier.txt"
- basenom=${0##*/}
- fichier_temporaire="1600.jpg"
- Dossier_images="/home/remi/Images/Wallpapers/meteo/"
- lien="/home/remi/Images/Wallpapers/desktop4.jpg"
- nom="meteo_actuelle"
- adresse="http://static.die.net/earth/mercator/1600.jpg"
- heure=$(date +%d)"-"$(date +%m)"-"$(date +%Y)
- heure=$heure"_"$(date +%H)"h"$(date +%M)"mn"
- nom_final=$nom"_"$heure".jpeg"
- nom_final=$Dossier_images$nom_final
- cd $Dossier_images
- rm 1600.jpg
- curl -A "Mozilla/4.0" http://static.die.net/earth/mercator/1600.jpg -o $fichier_temporaire
- temp=$(stat -c%s $fichier_temporaire)
- if [[ $temp > 1000 ]]
- then
- echo "[$basenom] $(date) -> $temp [$fichier_temporaire] [$nom_final]" >> $log
- # j'ai récupéré l'image, on fait une copie avec un nouveau nom
- cp $fichier_temporaire $nom_final
- # on insert la date et l'heure
- mogrify -fill white -pointsize 16 -annotate +15+820 "$heure" $nom_final
- # on change le lien du fond d'écran vers la nouvelle image
- if [[ -h $lien ]]
- then
- rm $lien
- echo "[$basenom] suppression du lien $lien " >> $log
- fi
- ln -s $nom_final $lien
- else
- echo "[$basenom] Pas de nouvelle image" >> $log
- fi
Advertisement
Add Comment
Please, Sign In to add comment