From 61f0aa7f1e1fafa4216936a24caafb0d3366d689 Mon Sep 17 00:00:00 2001 From: lomna-dev Date: Fri, 12 May 2023 16:47:33 +0530 Subject: [PATCH] Emacs script The emacs colorscheme script now reads the JSON file at root of the directory to get bg, fg and colors. --- python-xresources-emacs/convert.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/python-xresources-emacs/convert.py b/python-xresources-emacs/convert.py index 656adef..7dce3e2 100644 --- a/python-xresources-emacs/convert.py +++ b/python-xresources-emacs/convert.py @@ -1,3 +1,25 @@ +import json + +""" This file reads the JSON file in root directory and converts it to emacs color theme. The theme is written on stdout and can be copied into a file and loaded in emacs without any modifications. """ + +background = "" +foreground = "" +colors = [] + +with open("../JSON", 'r') as f: + d = json.loads(f.read()) + background = d['background'] + foreground = d['foreground'] + colors = d['color'] + +print(";; foreground : " + foreground) +print(";; background : " + background) + +i = 0 +for c in colors: + print(";; color" + str(i) + " " + c) + i += 1 + print(""" (deftheme {theme_name} "Add some description here") @@ -91,4 +113,4 @@ print(""" `(message-separator ((,class (:foreground "{white}" :weight bold)))))) (provide-theme '{theme_name}) -""".format(theme_name="anmol-test",bg="#100f1f", fg="#fcffdc", black="#212125", red="#c24949", green="#3eca3e", yellow="#dcdc0f", blue="#6d6df3", magenta="#d068d0", cyan="#00cbcb", white="#e2e2e2", bright_black="#80776f", bright_red="#c25959", bright_green="#3eca3e", bright_yellow="#dcdc00", bright_blue="#915bf3", bright_magenta="#d040d0", bright_cyan="#78dada", bright_white="#f5f5f5")) +""".format(theme_name="anmol-test",bg=background, fg=foreground, black=colors[0], red=colors[1], green=colors[2], yellow=colors[3], blue=colors[4], magenta=colors[5], cyan=colors[6], white=colors[7], bright_black=colors[8], bright_red=colors[9], bright_green=colors[10], bright_yellow=colors[11], bright_blue=colors[12], bright_magenta=colors[13], bright_cyan=colors[14], bright_white=colors[15]))