mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-02-10 07:19:31 +01:00
wallpaper: Add support for macOS
This commit is contained in:
parent
b3596e65dd
commit
9f1d8bffe0
@ -3,7 +3,7 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from .settings import CACHE_DIR
|
||||
from .settings import CACHE_DIR, OS
|
||||
from . import util
|
||||
|
||||
|
||||
@ -81,6 +81,13 @@ def set_desktop_wallpaper(desktop, img):
|
||||
set_wm_wallpaper(img)
|
||||
|
||||
|
||||
def set_mac_wallpaper(img):
|
||||
"""Set the wallpaper on macOS."""
|
||||
subprocess.call(["osascript", "tell", "application", "\"Finder\"",
|
||||
"set", "desktop", "picture", "to", "POSIX", "file",
|
||||
f"\"{img}\""])
|
||||
|
||||
|
||||
def change(img):
|
||||
"""Set the wallpaper."""
|
||||
if not os.path.isfile(img):
|
||||
@ -88,7 +95,10 @@ def change(img):
|
||||
|
||||
desktop = get_desktop_env()
|
||||
|
||||
if desktop:
|
||||
if OS == "Darwin":
|
||||
set_mac_wallpaper(img)
|
||||
|
||||
elif desktop:
|
||||
set_desktop_wallpaper(desktop, img)
|
||||
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user