mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-20 17:47:44 +02:00
Merge pull request #66 from dylanaraps/macos3
wallpaper: Add support for macOS
This commit is contained in:
commit
f3806a0831
@ -3,7 +3,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .settings import CACHE_DIR
|
from .settings import CACHE_DIR, HOME, OS
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +81,15 @@ def set_desktop_wallpaper(desktop, img):
|
|||||||
set_wm_wallpaper(img)
|
set_wm_wallpaper(img)
|
||||||
|
|
||||||
|
|
||||||
|
def set_mac_wallpaper(img):
|
||||||
|
"""Set the wallpaper on macOS."""
|
||||||
|
db_file = HOME / "Library/Application Support/Dock/desktoppicture.db"
|
||||||
|
subprocess.call(["sqlite3", db_file, f"update data set value = '{img}'"])
|
||||||
|
|
||||||
|
# Kill the dock to fix issues with wallpapers sharing names.
|
||||||
|
util.disown("killall", "Dock")
|
||||||
|
|
||||||
|
|
||||||
def change(img):
|
def change(img):
|
||||||
"""Set the wallpaper."""
|
"""Set the wallpaper."""
|
||||||
if not os.path.isfile(img):
|
if not os.path.isfile(img):
|
||||||
@ -88,7 +97,10 @@ def change(img):
|
|||||||
|
|
||||||
desktop = get_desktop_env()
|
desktop = get_desktop_env()
|
||||||
|
|
||||||
if desktop:
|
if OS == "Darwin":
|
||||||
|
set_mac_wallpaper(img)
|
||||||
|
|
||||||
|
elif desktop:
|
||||||
set_desktop_wallpaper(desktop, img)
|
set_desktop_wallpaper(desktop, img)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user