summaryrefslogtreecommitdiff
path: root/pywal
diff options
context:
space:
mode:
authorDylan Araps <dylanaraps@users.noreply.github.com>2017-08-26 09:15:58 +1000
committerGitHub <noreply@github.com>2017-08-26 09:15:58 +1000
commit7b869457750daa318c416eddae401e97b920241e (patch)
treeaa8dbf3f9995ce7a1e7520beb7f2000fe6a8b9f6 /pywal
parent4744eee3394d0b1ee71d1d1fc81b99be51785fef (diff)
parentb4b3c4ca4c975a93eab2e4da9fb50456b6bed77b (diff)
Merge pull request #93 from dylanaraps/windows
OS: Added support for Windows
Diffstat (limited to 'pywal')
-rw-r--r--pywal/colors.py9
-rw-r--r--pywal/reload.py2
-rw-r--r--pywal/settings.py4
-rw-r--r--pywal/util.py3
-rw-r--r--pywal/wallpaper.py15
5 files changed, 26 insertions, 7 deletions
diff --git a/pywal/colors.py b/pywal/colors.py
index fd233c5..9984b6e 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -13,7 +13,12 @@ from . import util
def imagemagick(color_count, img):
"""Call Imagemagick to generate a scheme."""
- colors = subprocess.Popen(["convert", img, "-resize", "25%",
+ if shutil.which("magick"):
+ magick_command = ["magick", "convert"]
+ else:
+ magick_command = ["convert"]
+
+ colors = subprocess.Popen([*magick_command, img, "-resize", "25%",
"+dither", "-colors", str(color_count),
"-unique-colors", "txt:-"],
stdout=subprocess.PIPE)
@@ -84,7 +89,7 @@ def get(img, cache_dir=CACHE_DIR,
color_count=COLOR_COUNT, notify=False):
"""Get the colorscheme."""
# _home_dylan_img_jpg.json
- cache_file = img.replace("/", "_").replace(".", "_")
+ cache_file = img.replace("/", "_").replace("\\", "_").replace(".", "_")
cache_file = os.path.join(cache_dir, "schemes", cache_file + ".json")
if os.path.isfile(cache_file):
diff --git a/pywal/reload.py b/pywal/reload.py
index b16aec1..41283eb 100644
--- a/pywal/reload.py
+++ b/pywal/reload.py
@@ -15,7 +15,7 @@ def xrdb(xrdb_file=None):
"""Merge the colors into the X db so new terminals use them."""
xrdb_file = xrdb_file or os.path.join(CACHE_DIR, "colors.Xresources")
- if shutil.which("xrdb") or OS != "Darwin":
+ if shutil.which("xrdb") and OS != "Darwin":
subprocess.Popen(["xrdb", "-merge", xrdb_file],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL).wait()
diff --git a/pywal/settings.py b/pywal/settings.py
index ce06347..4aec9a7 100644
--- a/pywal/settings.py
+++ b/pywal/settings.py
@@ -16,8 +16,8 @@ import platform
__version__ = "0.6.6"
-HOME = os.environ["HOME"]
-CACHE_DIR = os.path.join(HOME, ".cache/wal/")
+HOME = os.getenv("HOME", os.getenv("USERPROFILE"))
+CACHE_DIR = os.path.join(HOME, ".cache", "wal")
MODULE_DIR = os.path.dirname(__file__)
COLOR_COUNT = 16
OS = platform.uname()[0]
diff --git a/pywal/util.py b/pywal/util.py
index 55be6c2..894c049 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -113,8 +113,7 @@ def disown(cmd):
disown it and hide it's output."""
subprocess.Popen(["nohup", *cmd],
stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- preexec_fn=os.setpgrp)
+ stderr=subprocess.DEVNULL)
def msg(input_msg, notify):
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)