Add files
This commit is contained in:
parent
6bbedececb
commit
6db6561bd6
4 changed files with 107 additions and 2 deletions
51
change-wallpaper.py
Executable file
51
change-wallpaper.py
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import random
|
||||
|
||||
# Specify the directory
|
||||
directory_path = '/path/to/your/wallpapers'
|
||||
|
||||
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 random_file_path[-8:-4] == "blue":
|
||||
accent_color = "blue"
|
||||
elif random_file_path[-8:-4] == "teal":
|
||||
accent_color = "teal"
|
||||
elif random_file_path[-8:-4] == "gree":
|
||||
accent_color = "green"
|
||||
elif random_file_path[-8:-4] == "yell":
|
||||
accent_color = "yellow"
|
||||
elif random_file_path[-8:-4] == "oran":
|
||||
accent_color = "orange"
|
||||
elif random_file_path[-8:-4] == "redd":
|
||||
accent_color = "red"
|
||||
elif random_file_path[-8:-4] == "pink":
|
||||
accent_color = "pink"
|
||||
elif random_file_path[-8:-4] == "purp":
|
||||
accent_color = "purple"
|
||||
else:
|
||||
accent_color = "slate"
|
||||
|
||||
# print(f'DEBUG: Using background picture {random_file_path}')
|
||||
# print(f'DEBUG: 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}')
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue