Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Haskell support #541

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pywal/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ def template(colors, input_file, output_file=None):
# If the color was changed, replace with a unique identifier.
if new_color is not colors[cname]:
new_color = str(new_color)
new_color_clean = new_color.replace('[', '_').replace(']', '_').replace('.', '_')
new_color_clean = new_color.replace(
'[', '_').replace(']', '_').replace('.', '_')
template_data[i] = l.replace(replace_str,
"color" + new_color_clean)
colors["color" + new_color_clean] = new_color
try:
template_data = "".join(template_data).format(**colors)
except (ValueError, KeyError, AttributeError) as exc:
logging.error("Syntax error in template file '%s': %r.", input_file, exc)
logging.error("Syntax error in template file '%s': %r.",
input_file, exc)
return
util.save_file(template_data, output_file)

Expand Down Expand Up @@ -104,6 +106,7 @@ def get_export_type(export_type):
"vscode": "colors-vscode.json",
"waybar": "colors-waybar.css",
"xresources": "colors.Xresources",
"haskell": "Colors.hs",
"xmonad": "colors.hs",
"yaml": "colors.yml",
}.get(export_type, export_type)
Expand Down
37 changes: 37 additions & 0 deletions pywal/templates/Colors.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--Place this file in your .xmonad/lib directory and import module Colors into .xmonad/xmonad.hs config
--The easy way is to create a soft link from this file to the file in .xmonad/lib using ln -s
--Then recompile and restart xmonad.

module Colors
( wallpaper
, background, foreground, cursor
, color0, color1, color2, color3, color4, color5, color6, color7
, color8, color9, color10, color11, color12, color13, color14, color15
) where

-- Shell variables
-- Generated by 'wal'
wallpaper="{wallpaper}"

-- Special
background="{background}"
foreground="{foreground}"
cursor="{cursor}"

-- Colors
color0="{color0}"
color1="{color1}"
color2="{color2}"
color3="{color3}"
color4="{color4}"
color5="{color5}"
color6="{color6}"
color7="{color7}"
color8="{color8}"
color9="{color9}"
color10="{color10}"
color11="{color11}"
color12="{color12}"
color13="{color13}"
color14="{color14}"
color15="{color15}"
5 changes: 3 additions & 2 deletions pywal/wallpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,18 @@ def set_desktop_wallpaper(desktop, img):
elif "awesome" in desktop:
util.disown(["awesome-client",
"require('gears').wallpaper.maximized('{img}')"
.format(**locals())])
.format(**locals())])

elif "kde" in desktop:
string = """
var allDesktops = desktops();for (i=0;i<allDesktops.length;i++){
d = allDesktops[i];d.wallpaperPlugin = "org.kde.image";
d.currentConfigGroup = Array("Wallpaper", "org.kde.image",
"General");d.writeConfig("Image", "%s")};
"General"); d.writeConfig("Image", "%s")};
"""
util.disown(["qdbus", "org.kde.plasmashell", "/PlasmaShell",
"org.kde.PlasmaShell.evaluateScript", string % img])

else:
set_wm_wallpaper(img)

Expand Down