diff options
| author | Dylan Araps <dylanaraps@users.noreply.github.com> | 2017-07-31 16:11:01 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-31 16:11:01 +1000 |
| commit | f3806a0831e5de82935def7c50400c797e97ab6a (patch) | |
| tree | 375bc37b73f3b21cd4e42485de76ca269607926d | |
| parent | b3596e65ddc37daccb28d6d133e8c1cdb1c476b3 (diff) | |
| parent | d8293b20de34cb7c36bc39438cb574554af2b361 (diff) | |
Merge pull request #66 from dylanaraps/macos3
wallpaper: Add support for macOS
| -rw-r--r-- | pywal/wallpaper.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pywal/wallpaper.py b/pywal/wallpaper.py index 1c6b485..05f5d08 100644 --- a/pywal/wallpaper.py +++ b/pywal/wallpaper.py @@ -3,7 +3,7 @@ import os import shutil import subprocess -from .settings import CACHE_DIR +from .settings import CACHE_DIR, HOME, OS from . import util @@ -81,6 +81,15 @@ def set_desktop_wallpaper(desktop, 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): """Set the wallpaper.""" if not os.path.isfile(img): @@ -88,7 +97,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: |
