astronomypotd.sh 982 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # This Script downloads National Geographic Photo of the day, and sets it as desktop background (gnome, unity)
  3. # Copyright (C) 2012 Saman Barghi - All Rights Reserved
  4. # Permission to copy, modify, and distribute is granted under GPLv3
  5. # Last Revised 22 May 2019
  6. #######################
  7. #Change directory to where the script resides.
  8. BASEDIR="$HOME/var/inbox/apod_photos"
  9. cd $BASEDIR
  10. #######################
  11. #getting the image URL
  12. img="$(curl https://api.nasa.gov/planetary/apod\?api_key=AdfgdnmmInYgpDMEq3ShMLKjJ7DZ7jyUcgLHWdgw | jq .hdurl | tr -d \")"
  13. #check to see if there is any wallpaper to download
  14. if [ -n "$img" ]
  15. then
  16. img_file=`echo $img | cut -d/ -f 7 | tr -d \"`
  17. curl $img > $img_file
  18. #set the current image as wallpaper
  19. #feh --bg-scale $BASEDIR/$img_file
  20. ##link slim background to new image
  21. #rm /usr/share/slim/themes/default/background.jpg
  22. #ln -s $BASEDIR/$img_file /usr/share/slim/themes/default/background.jpg
  23. else
  24. echo "No Wallpaper today"
  25. fi