2025-02-04 01:51:58 +07:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import random
|
2025-05-16 02:00:49 +07:00
|
|
|
import sys
|
2025-02-04 01:51:58 +07:00
|
|
|
|
2025-05-16 02:00:49 +07:00
|
|
|
if len(sys.argv) < 2 or sys.argv[1] == "":
|
|
|
|
print("Please specify a directory")
|
|
|
|
sys.exit()
|
|
|
|
|
2025-02-04 01:51:58 +07:00
|
|
|
# Specify the directory
|
2025-05-16 02:00:49 +07:00
|
|
|
directory_path = sys.argv[1]
|
2025-02-04 01:51:58 +07:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2025-05-16 02:00:49 +07:00
|
|
|
if "blue" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "blue"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "teal" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "teal"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "green" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "green"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "yellow" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "yellow"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "orange" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "orange"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "red" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "red"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "pink" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "pink"
|
2025-05-16 02:00:49 +07:00
|
|
|
elif "purple" in random_file_path:
|
2025-02-04 01:51:58 +07:00
|
|
|
accent_color = "purple"
|
|
|
|
else:
|
|
|
|
accent_color = "slate"
|
|
|
|
|
2025-05-16 02:00:49 +07:00
|
|
|
print(f'INFO: Using background picture {random_file_path}')
|
|
|
|
print(f'INFO: Using accent color {accent_color}')
|
2025-02-04 01:51:58 +07:00
|
|
|
|
|
|
|
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}')
|
|
|
|
|