changepaper.sh 2.3 KB

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