diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-08-25 20:07:09 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-08-25 20:07:09 +1000 |
| commit | 6b5e65fc429ba7173cab7f1862c63c853d80411d (patch) | |
| tree | 6bf00851e1f7d29560d12976e5a8693eb385b794 | |
| parent | 8d0e3d4ed4685d68be501461cf8b687a654996da (diff) | |
wallpaper: Added support for Windows.
| -rw-r--r-- | pywal/wallpaper.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pywal/wallpaper.py b/pywal/wallpaper.py index 06dde63..6d407cd 100644 --- a/pywal/wallpaper.py +++ b/pywal/wallpaper.py @@ -1,4 +1,5 @@ """Set the wallpaper.""" +import ctypes import os import shutil import subprocess @@ -95,6 +96,17 @@ def set_mac_wallpaper(img): subprocess.call(["killall", "Dock"]) +def set_win_wallpaper(img): + """Set the wallpaper on Windows.""" + # There's a different command depending on the architecture + # of Windows. We check the PROGRAMFILES envar since using + # platform is unreliable. + if "x86" in os.environ["PROGRAMFILES"]: + ctypes.windll.user32.SystemParametersInfoW(20, 0, img, 3) + else: + ctypes.windll.user32.SystemParametersInfoA(20, 0, img, 3) + + def change(img): """Set the wallpaper.""" if not os.path.isfile(img): @@ -105,6 +117,9 @@ def change(img): if OS == "Darwin": set_mac_wallpaper(img) + elif OS == "Windows": + set_win_wallpaper(img) + elif desktop: set_desktop_wallpaper(desktop, img) |
