summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-06 19:48:14 -0500
committerJune McEnroe <june@causal.agency>2021-02-06 19:48:14 -0500
commit34894724b0a85f7d047f31dcdc893dbd47b8f9c3 (patch)
tree4020c018703c84bc9e9153aee34bde72d41e0ef6 /bin
parentAdd wsconsctl.conf (diff)
downloadsrc-34894724b0a85f7d047f31dcdc893dbd47b8f9c3.tar.gz
src-34894724b0a85f7d047f31dcdc893dbd47b8f9c3.zip
Add xterm output to scheme
Diffstat (limited to '')
-rw-r--r--bin/man1/scheme.17
-rw-r--r--bin/scheme.c24
2 files changed, 28 insertions, 3 deletions
diff --git a/bin/man1/scheme.1 b/bin/man1/scheme.1
index 9aa4f054..9f72d945 100644
--- a/bin/man1/scheme.1
+++ b/bin/man1/scheme.1
@@ -1,4 +1,4 @@
-.Dd July 6, 2019
+.Dd February  6, 2021
 .Dt SCHEME 1
 .Os
 .
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl acghilmstx
+.Op Fl Xacghilmstx
 .Op Fl p Ar n
 .
 .Sh DESCRIPTION
@@ -19,6 +19,9 @@ and outputs it in a number of formats.
 .Pp
 The arguments are as follows:
 .Bl -tag -width Ds
+.It Fl X
+Output Xresources for
+.Xr xterm 1 .
 .It Fl a
 Generate the 16 ANSI colors.
 This is the default.
diff --git a/bin/scheme.c b/bin/scheme.c
index b921a77e..2bae8f82 100644
--- a/bin/scheme.c
+++ b/bin/scheme.c
@@ -156,6 +156,27 @@ static void outputEnum(const struct HSV *hsv, uint len) {
 	printf("};\n");
 }
 
+#define FORMAT_X "rgb:%02hhX/%02hhX/%02hhX"
+
+static const char *Resources[SchemeLen] = {
+	[Background] = "background",
+	[Foreground] = "foreground",
+	[Bold] = "colorBD",
+	[Selection] = "highlightColor",
+	[Cursor] = "cursorColor",
+};
+
+static void outputXTerm(const struct HSV *hsv, uint len) {
+	for (uint i = 0; i < len; ++i) {
+		struct RGB rgb = convert(hsv[i]);
+		if (Resources[i]) {
+			printf("XTerm*%s: " FORMAT_X "\n", Resources[i], rgb.r, rgb.g, rgb.b);
+		} else {
+			printf("XTerm*color%u: " FORMAT_X "\n", i, rgb.r, rgb.g, rgb.b);
+		}
+	}
+}
+
 static const char *Mintty[SchemeLen] = {
 	"Black", "Red", "Green", "Yellow",
 	"Blue", "Magenta", "Cyan", "White",
@@ -230,8 +251,9 @@ int main(int argc, char *argv[]) {
 	uint len = 16;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "acghilmp:stx"))) {
+	while (0 < (opt = getopt(argc, argv, "Xacghilmp:stx"))) {
 		switch (opt) {
+			break; case 'X': output = outputXTerm;
 			break; case 'a': len = 16;
 			break; case 'c': output = outputEnum;
 			break; case 'g': output = outputPNG;