mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-24 19:41:25 +02:00
Merge pull request #93 from dylanaraps/windows
OS: Added support for Windows
This commit is contained in:
commit
7b86945775
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ subprocess
|
|||||||
re
|
re
|
||||||
build/*
|
build/*
|
||||||
.coverage
|
.coverage
|
||||||
|
.vscode/*
|
||||||
|
@ -13,7 +13,12 @@ from . import util
|
|||||||
|
|
||||||
def imagemagick(color_count, img):
|
def imagemagick(color_count, img):
|
||||||
"""Call Imagemagick to generate a scheme."""
|
"""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),
|
"+dither", "-colors", str(color_count),
|
||||||
"-unique-colors", "txt:-"],
|
"-unique-colors", "txt:-"],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
@ -84,7 +89,7 @@ def get(img, cache_dir=CACHE_DIR,
|
|||||||
color_count=COLOR_COUNT, notify=False):
|
color_count=COLOR_COUNT, notify=False):
|
||||||
"""Get the colorscheme."""
|
"""Get the colorscheme."""
|
||||||
# _home_dylan_img_jpg.json
|
# _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")
|
cache_file = os.path.join(cache_dir, "schemes", cache_file + ".json")
|
||||||
|
|
||||||
if os.path.isfile(cache_file):
|
if os.path.isfile(cache_file):
|
||||||
|
@ -15,7 +15,7 @@ def xrdb(xrdb_file=None):
|
|||||||
"""Merge the colors into the X db so new terminals use them."""
|
"""Merge the colors into the X db so new terminals use them."""
|
||||||
xrdb_file = xrdb_file or os.path.join(CACHE_DIR, "colors.Xresources")
|
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],
|
subprocess.Popen(["xrdb", "-merge", xrdb_file],
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL).wait()
|
stderr=subprocess.DEVNULL).wait()
|
||||||
|
@ -16,8 +16,8 @@ import platform
|
|||||||
__version__ = "0.6.6"
|
__version__ = "0.6.6"
|
||||||
|
|
||||||
|
|
||||||
HOME = os.environ["HOME"]
|
HOME = os.getenv("HOME", os.getenv("USERPROFILE"))
|
||||||
CACHE_DIR = os.path.join(HOME, ".cache/wal/")
|
CACHE_DIR = os.path.join(HOME, ".cache", "wal")
|
||||||
MODULE_DIR = os.path.dirname(__file__)
|
MODULE_DIR = os.path.dirname(__file__)
|
||||||
COLOR_COUNT = 16
|
COLOR_COUNT = 16
|
||||||
OS = platform.uname()[0]
|
OS = platform.uname()[0]
|
||||||
|
@ -113,8 +113,7 @@ def disown(cmd):
|
|||||||
disown it and hide it's output."""
|
disown it and hide it's output."""
|
||||||
subprocess.Popen(["nohup", *cmd],
|
subprocess.Popen(["nohup", *cmd],
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL)
|
||||||
preexec_fn=os.setpgrp)
|
|
||||||
|
|
||||||
|
|
||||||
def msg(input_msg, notify):
|
def msg(input_msg, notify):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Set the wallpaper."""
|
"""Set the wallpaper."""
|
||||||
|
import ctypes
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -95,6 +96,17 @@ def set_mac_wallpaper(img):
|
|||||||
subprocess.call(["killall", "Dock"])
|
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):
|
def change(img):
|
||||||
"""Set the wallpaper."""
|
"""Set the wallpaper."""
|
||||||
if not os.path.isfile(img):
|
if not os.path.isfile(img):
|
||||||
@ -105,6 +117,9 @@ def change(img):
|
|||||||
if OS == "Darwin":
|
if OS == "Darwin":
|
||||||
set_mac_wallpaper(img)
|
set_mac_wallpaper(img)
|
||||||
|
|
||||||
|
elif OS == "Windows":
|
||||||
|
set_win_wallpaper(img)
|
||||||
|
|
||||||
elif desktop:
|
elif desktop:
|
||||||
set_desktop_wallpaper(desktop, img)
|
set_desktop_wallpaper(desktop, img)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user