diff --git a/Daily-Wallpaper/README.md b/Daily-Wallpaper/README.md new file mode 100644 index 0000000..d2bd397 --- /dev/null +++ b/Daily-Wallpaper/README.md @@ -0,0 +1,48 @@ +# [Daily-Wallpaper](https://github.com/udit-001/daily-wallpaper) + +A python script to update desktop wallpaper on a Windows machine from a tumblr blog. For more info, [click here.](https://github.com/udit-001/daily-wallpaper) + +## Inspiration +I was tired of seeing the same boring wallpaper on my desktop everyday. After learning a little bit of Python, I decided to design a script that would update my wallpaper on it's own by fetching an image from a [Tumblr Blog](http://fuckinghomepage.com/). + +## Installation +Install the required dependencies/libraries by running : + +```bash +$ pip install -r requirements.txt +``` + +## Usage +This script can be scheduled to run daily by using the Task Scheduler utility present on Windows. You will require a BAT script to run the script from the task. + +```bat +@echo off +cd +pythonw wall.pyw +``` + +Now copy the above code and paste it into notepad, then modify the `` according to where you download the files from this repo, and save it as "dailywall.bat" + +If you want your script to work silently in the background without having a command prompt window opening up, then you'll also need to create a .VBS script. + +```vbs +Set WshShell = CreateObject("WScript.Shell") +WshShell.Run chr(34) & "" & Chr(34), 0 +Set WshShell = Nothing +``` +Copy the above code and paste it into notepad, then modify the `` and save it as "dailywall.vbs". +Now add the above script in the Windows Task that you'll schedule to run daily. + +## Features +It also displays a notification on your computer when the wallpaper gets updated. + +![Notifications Screenshot](https://raw.githubusercontent.com/udit-001/daily-wallpaper/master/img/notification.jpg) + +## License + +> You can check out the full license [here](https://github.com/udit-001/daily-wallpaper/blob/master/LICENSE) + +This project is licensed under the terms of the MIT license. + + + diff --git a/Daily-Wallpaper/wall.pyw b/Daily-Wallpaper/wall.pyw new file mode 100644 index 0000000..6156be8 --- /dev/null +++ b/Daily-Wallpaper/wall.pyw @@ -0,0 +1,58 @@ +#!python2 +"""This script can be set to run daily on your computer using utilities like Windows Task Scheduler +on Windows, and it would download a wallpaper +from a blog and set it up as your wallpaper on it's own""" +import urllib +import os +import ctypes +import imghdr +from datetime import datetime +from bs4 import BeautifulSoup +import requests +from win10toast import ToastNotifier + +url = 'http://fuckinghomepage.com/rss' +sourceCode = requests.get(url) +plainText = sourceCode.text +soup = BeautifulSoup(plainText, 'lxml') + +data = soup.item.description.text +href = data.split('PICTURE OF THE DAY:')[1].split('href=')[1].split('target=')[0] +href = href.replace('\"', ' ').strip() + +today = datetime.now() +files = os.listdir(os.getcwd()) + +dateString = str(today.day)+'-'+str(today.month)+'-'+str(today.year) +prev = str(today.day-1)+'-'+str(today.month)+'-'+str(today.year) + +check = 0 +for item in files: + if dateString in item: + fileName = item + check = 1 + else: + continue + +for item in files: + if prev in item: + os.remove(item) + else: + continue + +if check == 0: + urllib.urlretrieve(href, dateString) + ext = imghdr.what(dateString) + path = dateString+'.'+ext + os.rename(dateString, path) + abspath = os.path.abspath(path) + ctypes.windll.user32.SystemParametersInfoA(20, 0, abspath, 3) + +elif check == 1: + abspath = os.path.abspath(fileName) + ctypes.windll.user32.SystemParametersInfoA(20, 0, abspath, 3) + +print "Wallpaper set successfully." +toaster = ToastNotifier() +toaster.show_toast('Wallpaper Set!', 'Wallpaper was successfully downloaded.', \ + duration=5, icon_path='wall.ico')