Skip to content

Commit e5a01db

Browse files
Merge pull request #433 from ArunVenkata/master
Added Wallpaper Script to obtain Beautiful Wallpapers.
2 parents 3a6f255 + 111a6a8 commit e5a01db

9 files changed

+133
-0
lines changed

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Windows_Wallpaper_Script/ReadMe.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
##Windows Wallpaper Script
2+
Ever seen those amazing windows wallpapers on your windows lock screen? This Python Script will Import all of those amazing wallpapers into the current folder that the script is in.
3+
The wallpapers keep changing with time when connected to the internet so you can run the script after you notice new wallpapers on your lockscreen in order to obtain them.
4+
5+
***Optional:*** You can also use the windows task scheduler and schedule
6+
the script to run in a set time interval and also set the desktop wallpaper folder as default wallpaper folder. For more Info on task scheduling in Windows 10,
7+
Look Here: [Task Scheduling in windows](https://www.digitalcitizen.life/how-create-task-basic-task-wizard)
8+
9+
# Requirements
10+
* A Windows 10 PC
11+
* Python 3x
12+
* PIL Module For Python 3x
13+
14+
# Procedure
15+
* Run the script and enjoy!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import os
2+
import shutil
3+
import time
4+
from PIL import Image
5+
6+
7+
class Wallpaper:
8+
# Set Environment Variables
9+
username = os.environ['USERNAME']
10+
11+
# All file urls
12+
file_urls = {
13+
"wall_src": "C:\\Users\\" + username
14+
+ "\\AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\"
15+
+ "LocalState\\Assets\\",
16+
"wall_dst": os.path.dirname(os.path.abspath(__file__)) + "\\Wallpapers\\",
17+
"wall_mobile": os.path.dirname(os.path.abspath(__file__)) + "\\Wallpapers\\mobile\\",
18+
"wall_desktop": os.path.dirname(os.path.abspath(__file__)) + "\\Wallpapers\\desktop\\"
19+
}
20+
msg = '''
21+
DDDDD OOOOO NN N EEEEEEE
22+
D D O O N N N E
23+
D D O O N N N E
24+
D D O O N N N EEEE
25+
D D O O N N N E
26+
D D O O N N N E
27+
DDDDD OOOOO N NN EEEEEEE
28+
'''
29+
30+
# A method to showcase time effect
31+
@staticmethod
32+
def time_gap(string):
33+
print(string, end='')
34+
time.sleep(1)
35+
print(".", end='')
36+
time.sleep(1)
37+
print(".")
38+
39+
# A method to import the wallpapers from src folder(dir_src)
40+
@staticmethod
41+
def copy_wallpapers():
42+
w = Wallpaper
43+
w.time_gap("Copying Wallpapers")
44+
# Copy All Wallpapers From Src Folder To Dest Folder
45+
for filename in os.listdir(w.file_urls["wall_src"]):
46+
shutil.copy(w.file_urls["wall_src"] + filename, w.file_urls["wall_dst"])
47+
48+
# A method to Change all the Extensions
49+
@staticmethod
50+
def change_ext():
51+
w = Wallpaper
52+
w.time_gap("Changing Extensions")
53+
# Look into all the files in the executing folder and change extension
54+
for filename in os.listdir(w.file_urls["wall_dst"]):
55+
base_file, ext = os.path.splitext(filename)
56+
if ext == "":
57+
if not os.path.isdir(w.file_urls["wall_dst"] + filename):
58+
os.rename(w.file_urls["wall_dst"] + filename,
59+
w.file_urls["wall_dst"] + filename + ".jpg")
60+
61+
# Remove all files Not having Wallpaper Resolution
62+
@staticmethod
63+
def extract_wall():
64+
w = Wallpaper
65+
w.time_gap("Extracting Wallpapers")
66+
for filename in os.listdir(w.file_urls["wall_dst"]):
67+
base_file, ext = os.path.splitext(filename)
68+
if ext == ".jpg":
69+
im = Image.open(w.file_urls["wall_dst"] + filename)
70+
if list(im.size)[0] != 1920 and list(im.size)[0] != 1080:
71+
im.close()
72+
os.remove(w.file_urls["wall_dst"] + filename)
73+
else:
74+
im.close()
75+
# Arrange the wallpapers into the corresponding folders
76+
@staticmethod
77+
def arr_desk_wallpapers():
78+
w = Wallpaper
79+
w.time_gap("Arranging Desktop wallpapers")
80+
for filename in os.listdir(w.file_urls["wall_dst"]):
81+
base_file, ext = os.path.splitext(filename)
82+
if ext == ".jpg":
83+
try:
84+
im = Image.open(w.file_urls["wall_dst"] + filename)
85+
86+
if list(im.size)[0] == 1920:
87+
im.close()
88+
os.rename(w.file_urls["wall_dst"] + filename,
89+
w.file_urls["wall_desktop"] + filename)
90+
if list(im.size)[0] == 1080:
91+
im.close()
92+
os.rename(w.file_urls["wall_dst"] + filename,
93+
w.file_urls["wall_mobile"] + filename)
94+
else:
95+
im.close()
96+
except FileExistsError:
97+
print("File Already Exists!")
98+
os.remove(w.file_urls["wall_dst"] + filename)
99+
100+
@staticmethod
101+
def exec_all():
102+
w = Wallpaper
103+
w.copy_wallpapers()
104+
w.change_ext()
105+
w.extract_wall()
106+
w.arr_desk_wallpapers()
107+
print(w.msg)
108+
time.sleep(3)
109+
110+
111+
wall = Wallpaper()
112+
wall.exec_all()

0 commit comments

Comments
 (0)