mirror of
https://github.com/kittywitch/konawall-py.git
synced 2026-02-09 12:29:19 -08:00
Initial commit, win32 and darwin support only
This commit is contained in:
commit
40df439299
14 changed files with 527 additions and 0 deletions
13
environments/darwin.py
Normal file
13
environments/darwin.py
Normal 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
28
environments/win32.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue