changepaper.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. export DISPLAY=:0.0
  9. BASEDIR="$HOME/var/inbox/ng_photos"
  10. cd $BASEDIR
  11. #######################
  12. #getting the image URL
  13. img="$(curl https://www.nationalgeographic.com/photography/photo-of-the-day/ -s | grep -oP '(?<="twitter:image:src" content=")\K[^"]*')"
  14. #check to see if there is any wallpaper to download
  15. if [ -n "$img" ]
  16. then
  17. img_base=`echo $img | cut -d/ -f 5`
  18. img_md5=`echo -n $img_base | md5sum | cut -f1 -d" "`
  19. img_file="$img_md5.jpg"
  20. curl "$img" > $img_file
  21. #set the current image as wallpaper
  22. # feh --bg-scale $BASEDIR/$img_md5.jpg
  23. # #link slim background to new image
  24. # rm /usr/share/slim/themes/default/background.jpg
  25. # ln -s $BASEDIR/$img_md5.jpg /usr/share/slim/themes/default/background.jpg
  26. else
  27. echo "No Wallpaper today"
  28. fi
  29. # Then grab our APOD image and store it for now
  30. #Change directory to where the script resides.
  31. BASEDIR="$HOME/var/inbox/apod_photos"
  32. cd $BASEDIR
  33. #######################
  34. #getting the image URL
  35. img="$(curl https://api.nasa.gov/planetary/apod\?api_key=AdfgdnmmInYgpDMEq3ShMLKjJ7DZ7jyUcgLHWdgw | jq .hdurl | tr -d \")"
  36. #check to see if there is any wallpaper to download
  37. if [ -n "$img" ]
  38. then
  39. img_file=`echo $img | cut -d/ -f 7 | tr -d \"`
  40. curl $img > $img_file
  41. #set the current image as wallpaper
  42. #feh --bg-scale $BASEDIR/$img_file
  43. ##link slim background to new image
  44. #rm /usr/share/slim/themes/default/background.jpg
  45. #ln -s $BASEDIR/$img_file /usr/share/slim/themes/default/background.jpg
  46. else
  47. echo "No Wallpaper today"
  48. fi
  49. BASEDIR="$HOME/var/inbox/astrobin/"
  50. # use python script to get astrobin iotd
  51. python3 ~/.bin/get_astrobin_potd.py
  52. date=$(date '+%Y-%m-%d')
  53. #set the current image as wallpaper
  54. feh --bg-scale $BASEDIR/$date.jpg
  55. #link slim background to new image
  56. rm /usr/share/slim/themes/default/background.jpg
  57. ln -s $BASEDIR/$date.jpg /usr/share/slim/themes/default/background.jpg