-
Notifications
You must be signed in to change notification settings - Fork 3
/
wallpapers.py
45 lines (36 loc) · 1.04 KB
/
wallpapers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Get the wallpaper from the internet
# Save it to a temp directory
# Set the wallpaper
# Automate the calls to this script
import os
import requests
import wget
import subprocess
import time
import ctypes
SPI_SETDESKWALLPAPER = 20
def get_wallpaper():
access_key = '' # add your unspash api key here
url = 'https://api.unsplash.com/photos/random?client_id=' + access_key
params = {
'query': 'HD wallpapers',
'orientation': 'landscape'
}
response = requests.get(url, params=params).json()
image_source = response['urls']['full']
image = wget.download(image_source, 'C:/Users/projects/wallpaper.jpg') # add the path here
return image
def change_wallpaper():
wallpaper = get_wallpaper()
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, "C:\\Users\\projects\\wallpaper.jpg" , 0) # add the path here as well
def main():
try:
while True:
change_wallpaper()
time.sleep(10)
except KeyboardInterrupt:
print("\nHope you like this one! Quitting.")
except Exception as e:
pass
if __name__ == "__main__":
main()