rsuinux

changement d'image fond d'écran lxde par image meteo terre

Feb 5th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.01 KB | None | 0 0
  1. #!/bin/bash
  2. # -------------------------------------------------------------------------
  3. # R. Suinot <remi -at- suinot.org>
  4. # 05 Fev.2016
  5. # Rev. 10 Fev.2016
  6. # image satellite en fond d'écranr
  7. # renouvelable tous les jours
  8. # Utilisation:
  9. # placer le script dans /usr/local/bin/
  10. # chmod +x /usr/local/bin/meteo.sh
  11. # installer la crontab sans oublier l'export du DISPLAY:
  12. # 0 3 * * * export DISPLAY=:0.0 && /usr/local/bin/meteo.sh
  13. # -------------------------------------------------------------------------
  14. #
  15. # A faire: utiliser une notification avec notify-send ou zenity par la crontab
  16. #
  17. # -------------------------------------------------------------------------
  18. # toutes les trois heures, une image nouvelle!
  19. # curl -A "Mozilla/4.0" http://static.die.net/earth/mercator/1600.jpg -o 1600.jpg
  20. # curl envoi une requette sous le nom de mozilla sinon cela ne fonctionne pas!
  21.  
  22. log="/tmp/mod-papier.txt"
  23. basenom=${0##*/}
  24. fichier_temporaire="1600.jpg"
  25. Dossier_images="/home/remi/Images/Wallpapers/meteo/"
  26. lien="/home/remi/Images/Wallpapers/desktop4.jpg"
  27. nom="meteo_actuelle"
  28. adresse="http://static.die.net/earth/mercator/1600.jpg"
  29. heure=$(date +%d)"-"$(date +%m)"-"$(date +%Y)
  30. heure=$heure"_"$(date +%H)"h"$(date +%M)"mn"
  31. nom_final=$nom"_"$heure".jpeg"
  32. nom_final=$Dossier_images$nom_final
  33.  
  34.  
  35. cd $Dossier_images
  36. rm 1600.jpg
  37. curl -A "Mozilla/4.0" http://static.die.net/earth/mercator/1600.jpg -o $fichier_temporaire
  38. temp=$(stat -c%s $fichier_temporaire)
  39. if [[ $temp > 1000 ]]
  40. then
  41.   echo "[$basenom] $(date) -> $temp [$fichier_temporaire] [$nom_final]" >> $log
  42.   # j'ai récupéré l'image, on fait une copie avec un nouveau nom
  43.   cp $fichier_temporaire $nom_final
  44.   # on insert la date et l'heure
  45.   mogrify -fill white -pointsize 16 -annotate +15+820 "$heure" $nom_final
  46.   # on change le lien du fond d'écran vers la nouvelle image
  47.   if [[ -h $lien ]]
  48.   then
  49.     rm $lien
  50.     echo "[$basenom] suppression du lien $lien " >> $log
  51.   fi
  52.   ln -s $nom_final $lien
  53. else
  54.   echo "[$basenom] Pas de nouvelle image" >> $log
  55. fi
Advertisement
Add Comment
Please, Sign In to add comment