Skip to content

Commit

Permalink
Merge pull request dylanaraps#617 from scaryrawr/windows-path-json
Browse files Browse the repository at this point in the history
fix: Wallpaper path on Windows isn't JSON compliant
  • Loading branch information
dylanaraps authored Aug 12, 2021
2 parents 4997a49 + 63a6505 commit a32a987
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pywal/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ def list_backends():
os.scandir(os.path.join(MODULE_DIR, "backends"))
if "__" not in b.name]

def normalize_img_path(img: str):
"""Normalizes the image path for output."""
if os.name == 'nt':
# On Windows, the JSON.dump ends up outputting un-escaped backslash breaking
# the ability to read colors.json. Windows supports forward slash, so we can
# use that for now
return img.replace('\\', '/')
return img

def colors_to_dict(colors, img):
"""Convert list of colors to pywal format."""
return {
"wallpaper": img,
"wallpaper": normalize_img_path(img),
"alpha": util.Color.alpha_num,

"special": {
Expand Down

0 comments on commit a32a987

Please sign in to comment.