#!/usr/bin/python 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 = sys.argv[1] def pick_random_file(directory): # List all files in the specified directory files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))] # Check if the directory is empty if not files: return None # Pick a random file from the list random_file = random.choice(files) # Return the full path of the randomly picked file return os.path.join(directory, random_file) # Pick a random file random_file_path = pick_random_file(directory_path) if "blue" in random_file_path: accent_color = "blue" elif "teal" in random_file_path: accent_color = "teal" elif "green" in random_file_path: accent_color = "green" elif "yellow" in random_file_path: accent_color = "yellow" elif "orange" in random_file_path: accent_color = "orange" elif "red" in random_file_path: accent_color = "red" elif "pink" in random_file_path: accent_color = "pink" elif "purple" in random_file_path: accent_color = "purple" else: accent_color = "slate" 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}"') os.system(f'gsettings set org.gnome.desktop.interface accent-color {accent_color}')