mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2025-03-16 18:49:47 +00:00
added main script
A project that can change your desktop wallpaper automatically.
This commit is contained in:
parent
4f56c75775
commit
6e7e9f2588
44
Auto_Wallpaper_Changer/main_changer.py
Normal file
44
Auto_Wallpaper_Changer/main_changer.py
Normal file
@ -0,0 +1,44 @@
|
||||
import os
|
||||
import requests
|
||||
import wget
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
def get_wallpaper():
|
||||
url = 'https://api.unsplash.com/photos/random?client_id=ZQfcb7DPk5z8ZH5W7Zaij6xG33M9U9BJ8ddfYifV6_E'
|
||||
params = {
|
||||
'query': 'HD wallpapers',
|
||||
'orientation': 'landscape'
|
||||
}
|
||||
|
||||
response = requests.get(url, params=params).json()
|
||||
image_source = response['urls']['full']
|
||||
|
||||
image = wget.download(image_source, 'D:\\Abdul Rehman\\AI Automations\\Unsplash_Images_API\\Images')
|
||||
return image
|
||||
|
||||
def change_wallpaper():
|
||||
wallpaper = get_wallpaper()
|
||||
cmd = """/usr/bin/osascript<<END
|
||||
tell application "Finder"
|
||||
set desktop picture to POSIX file "%s"
|
||||
end tell
|
||||
END"""
|
||||
|
||||
subprocess.Popen(cmd%wallpaper, shell=True)
|
||||
subprocess.call(["killall Dock"], shell=True)
|
||||
|
||||
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()
|
Loading…
x
Reference in New Issue
Block a user