diff --git a/change-wallpaper.py b/change-wallpaper.py index dc2a285..64db5c3 100755 --- a/change-wallpaper.py +++ b/change-wallpaper.py @@ -2,9 +2,14 @@ import os import random +import sys +if len(sys.argv) < 2 or sys.argv[1] == "": + print("Please specify a directory") + sys.exit() + # Specify the directory -directory_path = '/path/to/your/wallpapers' +directory_path = sys.argv[1] def pick_random_file(directory): # List all files in the specified directory @@ -23,27 +28,27 @@ def pick_random_file(directory): # Pick a random file random_file_path = pick_random_file(directory_path) -if random_file_path[-8:-4] == "blue": +if "blue" in random_file_path: accent_color = "blue" -elif random_file_path[-8:-4] == "teal": +elif "teal" in random_file_path: accent_color = "teal" -elif random_file_path[-8:-4] == "gree": +elif "green" in random_file_path: accent_color = "green" -elif random_file_path[-8:-4] == "yell": +elif "yellow" in random_file_path: accent_color = "yellow" -elif random_file_path[-8:-4] == "oran": +elif "orange" in random_file_path: accent_color = "orange" -elif random_file_path[-8:-4] == "redd": +elif "red" in random_file_path: accent_color = "red" -elif random_file_path[-8:-4] == "pink": +elif "pink" in random_file_path: accent_color = "pink" -elif random_file_path[-8:-4] == "purp": +elif "purple" in random_file_path: accent_color = "purple" else: accent_color = "slate" -# print(f'DEBUG: Using background picture {random_file_path}') -# print(f'DEBUG: Using accent color {accent_color}') +print(f'INFO: Using background picture {random_file_path}') +print(f'INFO: Using accent color {accent_color}') os.system(f'gsettings set org.gnome.desktop.background picture-uri "file://{random_file_path}"') os.system(f'gsettings set org.gnome.desktop.background picture-uri-dark "file://{random_file_path}"')