Initial commit, win32 and darwin support only

This commit is contained in:
Kat Inskip 2023-09-08 17:07:20 -07:00 committed by Kat Inskip
commit 40df439299
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
14 changed files with 527 additions and 0 deletions

13
environments/darwin.py Normal file
View file

@ -0,0 +1,13 @@
import subprocess
from module_loader import add_environment
"""
This sets wallpapers on Darwin.
:param files: A list of files to set as wallpapers
"""
@add_environment("darwin_setter")
def set_wallpapers(files: list, displays: list):
for i, file in enumerate(files):
# Run osascript to set the wallpaper for each monitor
subprocess.run(["osascript", "-e", f'tell application "System Events" to set picture of desktop {i} file "{file}"'])

28
environments/win32.py Normal file
View file

@ -0,0 +1,28 @@
import os
import ctypes
import logging
from imager import combine_to_viewport
from module_loader import add_environment
"""
Pre-setting on Windows
"""
@add_environment("win32_init")
def init():
os.system("color")
logging.info("Initialized for a Windows environment")
"""
This sets wallpapers on Windows.
:param files: A list of files to set as wallpapers
"""
@add_environment("win32_setter")
def set_wallpapers(files: list, displays: list):
if len(files) > 1:
logging.info("Several monitors detected, going the hard route")
file = combine_to_viewport(displays, files)
ctypes.windll.user32.SystemParametersInfoW(20, 0, file, 0)
else:
logging.info("Detected only one monitor, setting wallpaper simply")
ctypes.windll.user32.SystemParametersInfoW(20, 0, files[0] , 0)