Why ?
I believe automation is an integral part of technology, and scripts are a great way to automate your tasks.
What
I like my wallpaper to be dynamic, unexpected, natural and beautiful at the same time. All this come together in National Geographic Channel’s photo of the day. I knew it will be the perfect wallpaper. But to download and apply the wallpaper daily is just unethical for a coder. So I decided to write a script to do exactly that.
Research
The first thing to do was to find out where to get the NGC’s photo of the day.
A simple Google search revealed that it resides at the address http://photography.nationalgeographic.co.in/photography/photo-of-the-day/
Steps
- Download the webpage at the above address.
- Extract the url for the image.
- Download the image.
- Set the wallpaper
Downloading the page
Ok, so I have the url of the page. Using this, I can get the whole page using wget and save it in a file in the /tmp folder.
Extracting the url
After having a look at the source code, I could see a pattern and write a grep command
Now the url to the image is saved in the bash variable “url”.
Downloading the photo
wget comes handy again.
Setting the wallpaper
Finally, set the downloaded wallpaper (in Ubuntu)
That’s it! I encourage you to view, download and contribute to the script on Github.
Thanks for reading. Do comment!