commit f4abc94afbe4b37e2643a4336c31ec5683c9a1a8
parent c69cc841e2e604a9175a1f1639ca3a8d6a9319df
Author: Friedel Schön <[email protected]>
Date:   Mon,  5 Aug 2024 22:31:20 +0200
colorschemes
Diffstat:
8 files changed, 324 insertions(+), 64 deletions(-)
diff --git a/common/suckless-pkg.nix b/common/suckless-pkg.nix
@@ -9,13 +9,14 @@ in
 stdenv.mkDerivation (
   (builtins.removeAttrs args [ "configHeader" "extraConfig" ]) // {
 
-  inherit configurePhase;
+    inherit configurePhase;
 
-  buildPhase = ''
-    make all
-  '';
+    buildPhase = ''
+      make all
+    '';
 
-  installPhase = ''
-    make PREFIX=$out install
-  '';
-})
-\ No newline at end of file
+    installPhase = ''
+      make PREFIX=$out install
+    '';
+  }
+)
diff --git a/configs/dwm.h b/configs/dwm.h
@@ -2,18 +2,7 @@
 
 #include <X11/XF86keysym.h>
 
-static const char black[] = "#282828";
-static const char blue[] = "#83a598";  // focused window border
-static const char gray2[] = "#282828"; // unfocused window border
-static const char gray3[] = "#3c3836";
-static const char gray4[] = "#282828";
-static const char green[] = "#8ec07c";
-static const char orange[] = "#fe8019";
-static const char pink[] = "#d3869b";
-static const char red[] = "#fb4934";
-static const char white[] = "#ebdbb2";
-static const char yellow[] = "#b8bb26";
-static const char col_borderbar[] = "#1e2122";
+#include "theme.h"
 
 /* appearance */
 static const unsigned int borderpx = 2; /* border pixel of windows */
@@ -33,20 +22,16 @@ static const int systraypinningfailfirst =
           display systray on the last monitor*/
 static const int showsystray = 1; /* 0 means no systray */
 static const char *fonts[] = {"Source Code Pro:size=9"};
-static const char *colors_[][3] = { // light
-    /*               fg         bg         border   */
-    [SchemeNorm] = {gray3, white, gray2},
-    [SchemeSel] = {gray3, blue, blue},
-    [SchemeUrg] = {gray3, orange, red},
-    [3] = {gray3, orange, gray2},
-    [4] = {gray3, green, gray2}};
 static const char *colors[][3] = { // dark
+
+// #104b51, #3b484d, #674448, #924144 and #bd3d3f.
     /*               fg         bg         border   */
-    [SchemeNorm] = {white, gray2, gray2},
-    [SchemeSel] = {blue, gray3, blue},
-    [SchemeUrg] = {orange, gray3, red},
+    [SchemeNorm] = {white, "#3b484d", "#3b484d"},
+    [SchemeSel] = {black, "#bd3d3f", "#bd3d3f"},
+    [SchemeUrg] = {orange, gray3, orange},
     [3] = {gray3, orange, gray2},
-    [4] = {gray3, green, gray2}};
+    [4] = {gray3, green, gray2}
+  };
 
 static const char dwmrc[] = ".dwmrc";
 
diff --git a/configs/tabbed.h b/configs/tabbed.h
@@ -1,26 +1,16 @@
 /* See LICENSE file for copyright and license details. */
 
-static const char black[] = "#282828";
-static const char blue[] = "#83a598";  // focused window border
-static const char gray2[] = "#282828"; // unfocused window border
-static const char gray3[] = "#3c3836";
-static const char gray4[] = "#282828";
-static const char green[] = "#8ec07c";
-static const char orange[] = "#fe8019";
-static const char pink[] = "#d3869b";
-static const char red[] = "#fb4934";
-static const char white[] = "#ebdbb2";
-static const char yellow[] = "#b8bb26";
-static const char col_borderbar[] = "#1e2122";
+#include "theme.h"
 
 /* appearance */
 static const char font[] = "Fira Code:size=10";
-static const char *normbgcolor = gray3;
-static const char *normfgcolor = white;
-static const char *selbgcolor = "#fff";
-static const char *selfgcolor = black;
-static const char *urgbgcolor = blue;
-static const char *urgfgcolor = red;
+static const char *colors[][3] = { // dark
+  /*               fg         bg         border   */
+    [SchemeNorm] = {white, "#3b484d", "#3b484d"},
+    [SchemeSel] = {black, "#bd3d3f", "#bd3d3f"},
+    [SchemeUrg] = {orange, gray3, orange},
+  };
+
 static const char before[] = "<";
 static const char after[] = ">";
 static const char titletrim[] = "...";
diff --git a/home.nix b/home.nix
@@ -23,6 +23,8 @@ rec {
     # use nix' nix, it is more up-to-date
     pkgs.nix
 
+    pkgs.nixpkgs-fmt
+
     (pkgs.nerdfonts.override { fonts = [ "CascadiaCode" "FiraCode" ]; })
   ];
 
@@ -119,6 +121,7 @@ rec {
     extraConfig = builtins.readFile dotfiles/vimrc;
   };
 
+  targets.genericLinux.enable = true;
 
   home.stateVersion = "24.05"; # Please read the comment before changing.
 }
diff --git a/patches/dmenu-dynamicoptions-5.2.diff b/patches/dmenu-dynamicoptions-5.2.diff
@@ -0,0 +1,174 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..035b877 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -7,6 +7,7 @@ static const char *fonts[] = {
+ 	"monospace:size=10"
+ };
+ static const char *prompt      = NULL;      /* -p  option; prompt to the left of input field */
++static const char *dynamic     = NULL;      /* -dy option; dynamic command to run on input change */
+ static const char *colors[SchemeLast][2] = {
+ 	/*     fg         bg       */
+ 	[SchemeNorm] = { "#bbbbbb", "#222222" },
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..1ae3fe3 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -22,6 +22,8 @@ dmenu \- dynamic menu
+ .IR color ]
+ .RB [ \-w
+ .IR windowid ]
++.RB [ \-dy
++.IR command ]
+ .P
+ .BR dmenu_run " ..."
+ .SH DESCRIPTION
+@@ -80,6 +82,9 @@ prints version information to stdout, then exits.
+ .TP
+ .BI \-w " windowid"
+ embed into windowid.
++.TP
++.BI \-dy " command"
++runs command whenever input changes to update menu items.
+ .SH USAGE
+ dmenu is completely controlled by the keyboard.  Items are selected using the
+ arrow keys, page up, page down, home, and end.
+diff --git a/dmenu.c b/dmenu.c
+index 7cf253b..e7731ae 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -44,6 +44,7 @@ static struct item *items = NULL;
+ static struct item *matches, *matchend;
+ static struct item *prev, *curr, *next, *sel;
+ static int mon = -1, screen;
++static unsigned int max_lines = 0;
+ 
+ static Atom clip, utf8;
+ static Display *dpy;
+@@ -227,6 +228,47 @@ grabkeyboard(void)
+ 	die("cannot grab keyboard");
+ }
+ 
++static void readstdin(FILE* stream);
++
++static void
++refreshoptions()
++{
++	int dynlen = strlen(dynamic);
++	int cmdlen = dynlen + 4;
++	char *cmd;
++	char *c;
++	char *t = text;
++	while (*t)
++		cmdlen += *t++ == '\'' ? 4 : 1;
++	cmd = malloc(cmdlen);
++	if (cmd == NULL)
++		die("cannot malloc %u bytes:", cmdlen);
++	strcpy(cmd, dynamic);
++	t = text;
++	c = cmd + dynlen;
++	*(c++) = ' ';
++	*(c++) = '\'';
++	while (*t) {
++		// prefix ' with '\'
++		if (*t == '\'') {
++			*(c++) = '\'';
++			*(c++) = '\\';
++			*(c++) = '\'';
++		}
++		*(c++) = *(t++);
++	}
++	*(c++) = '\'';
++	*(c++) = 0;
++	FILE *stream = popen(cmd, "r");
++	if (!stream)
++		die("could not popen dynamic command (%s):", cmd);
++	readstdin(stream);
++	int r = pclose(stream);
++	if (r == -1)
++		die("could not pclose dynamic command");
++	free(cmd);
++}
++
+ static void
+ match(void)
+ {
+@@ -238,6 +280,16 @@ match(void)
+ 	size_t len, textsize;
+ 	struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
+ 
++	if (dynamic) {
++		refreshoptions();
++		matches = matchend = NULL;
++		for (item = items; item && item->text; item++)
++			appenditem(item, &matches, &matchend);
++		curr = sel = matches;
++		calcoffsets();
++		return;
++	}
++
+ 	strcpy(buf, text);
+ 	/* separate input text into tokens to be matched individually */
+ 	for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " "))
+@@ -547,14 +599,14 @@ paste(void)
+ }
+ 
+ static void
+-readstdin(void)
++readstdin(FILE* stream)
+ {
+ 	char *line = NULL;
+ 	size_t i, junk, size = 0;
+ 	ssize_t len;
+ 
+ 	/* read each line from stdin and add it to the item list */
+-	for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) {
++	for (i = 0; (len = getline(&line, &junk, stream)) != -1; i++, line = NULL) {
+ 		if (i + 1 >= size / sizeof *items)
+ 			if (!(items = realloc(items, (size += BUFSIZ))))
+ 				die("cannot realloc %zu bytes:", size);
+@@ -565,7 +617,7 @@ readstdin(void)
+ 	}
+ 	if (items)
+ 		items[i].text = NULL;
+-	lines = MIN(lines, i);
++	lines = MIN(max_lines, i);
+ }
+ 
+ static void
+@@ -711,7 +763,8 @@ static void
+ usage(void)
+ {
+ 	die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+-	    "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
++	    "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n"
++		"             [-dy command]\n");
+ }
+ 
+ int
+@@ -753,6 +806,8 @@ main(int argc, char *argv[])
+ 			colors[SchemeSel][ColFg] = argv[++i];
+ 		else if (!strcmp(argv[i], "-w"))   /* embedding window id */
+ 			embed = argv[++i];
++		else if (!strcmp(argv[i], "-dy"))  /* dynamic command to run */
++			dynamic = argv[++i] && *argv[i] ? argv[i] : NULL;
+ 		else
+ 			usage();
+ 
+@@ -777,11 +832,14 @@ main(int argc, char *argv[])
+ 		die("pledge");
+ #endif
+ 
++	max_lines = lines;
+ 	if (fast && !isatty(0)) {
+ 		grabkeyboard();
+-		readstdin();
++		if (!dynamic)
++			readstdin(stdin);
+ 	} else {
+-		readstdin();
++		if (!dynamic)
++			readstdin(stdin);
+ 		grabkeyboard();
+ 	}
+ 	setup();
diff --git a/patches/tabbed-colorscheme.diff b/patches/tabbed-colorscheme.diff
@@ -0,0 +1,89 @@
+diff --git a/config.def.h b/config.def.h
+index 51bb13d..d84a2ba 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,12 +2,13 @@
+ 
+ /* appearance */
+ static const char font[]        = "monospace:size=9";
+-static const char* normbgcolor  = "#222222";
+-static const char* normfgcolor  = "#cccccc";
+-static const char* selbgcolor   = "#555555";
+-static const char* selfgcolor   = "#ffffff";
+-static const char* urgbgcolor   = "#111111";
+-static const char* urgfgcolor   = "#cc0000";
++static const char *colors[][3] = { // dark
++    /*               fg         bg         border   */
++    [SchemeNorm] = {"#222222", "#222222", 0},
++    [SchemeSel] = {"#ffffff", "#555555", 0},
++    [SchemeUrg] = {"#cc0000", "#111111", 0},
++};
++
+ static const char before[]      = "<";
+ static const char after[]       = ">";
+ static const char titletrim[]   = "...";
+diff --git a/tabbed.c b/tabbed.c
+index 81be5e4..6a15001 100644
+--- a/tabbed.c
++++ b/tabbed.c
+@@ -51,6 +51,7 @@
+ enum { ColFG, ColBG, ColLast };       /* color */
+ enum { WMProtocols, WMDelete, WMName, WMState, WMFullscreen,
+        XEmbed, WMSelectTab, WMLast }; /* default atoms */
++enum { SchemeNorm, SchemeSel, SchemeUrg }; /* schemes */
+ 
+ typedef union {
+ 	int i;
+@@ -1037,12 +1038,12 @@ setup(void)
+ 			wy = dh + wy - wh - 1;
+ 	}
+ 
+-	dc.norm[ColBG] = getcolor(normbgcolor);
+-	dc.norm[ColFG] = getcolor(normfgcolor);
+-	dc.sel[ColBG] = getcolor(selbgcolor);
+-	dc.sel[ColFG] = getcolor(selfgcolor);
+-	dc.urg[ColBG] = getcolor(urgbgcolor);
+-	dc.urg[ColFG] = getcolor(urgfgcolor);
++	dc.norm[ColBG] = getcolor(colors[SchemeNorm][1]);
++	dc.norm[ColFG] = getcolor(colors[SchemeNorm][0]);
++	dc.sel[ColBG] = getcolor(colors[SchemeSel][1]);
++	dc.sel[ColFG] = getcolor(colors[SchemeSel][0]);
++	dc.urg[ColBG] = getcolor(colors[SchemeUrg][1]);
++	dc.urg[ColFG] = getcolor(colors[SchemeUrg][0]);
+ 	dc.drawable = XCreatePixmap(dpy, root, ww, wh,
+ 	                            DefaultDepth(dpy, screen));
+ 	dc.gc = XCreateGC(dpy, root, 0, 0);
+@@ -1307,10 +1308,10 @@ main(int argc, char *argv[])
+ 		wmname = EARGF(usage());
+ 		break;
+ 	case 'O':
+-		normfgcolor = EARGF(usage());
++		colors[SchemeNorm][0] = EARGF(usage());
+ 		break;
+ 	case 'o':
+-		normbgcolor = EARGF(usage());
++		colors[SchemeNorm][1] = EARGF(usage());
+ 		break;
+ 	case 'p':
+ 		pstr = EARGF(usage());
+@@ -1328,16 +1329,16 @@ main(int argc, char *argv[])
+ 		doinitspawn = False;
+ 		break;
+ 	case 'T':
+-		selfgcolor = EARGF(usage());
++		colors[SchemeSel][0] = EARGF(usage());
+ 		break;
+ 	case 't':
+-		selbgcolor = EARGF(usage());
++		colors[SchemeSel][1] = EARGF(usage());
+ 		break;
+ 	case 'U':
+-		urgfgcolor = EARGF(usage());
++		colors[SchemeUrg][0] = EARGF(usage());
+ 		break;
+ 	case 'u':
+-		urgbgcolor = EARGF(usage());
++		colors[SchemeUrg][1] = EARGF(usage());
+ 		break;
+ 	case 'v':
+ 		die("tabbed-"VERSION", © 2009-2016 tabbed engineers, "
diff --git a/pkgs/tabbed.nix b/pkgs/tabbed.nix
@@ -16,4 +16,7 @@ mkSucklessPackage {
     xorg.libXft
   ];
 
+  patches = [
+    ../patches/tabbed-colorscheme.diff
+  ];
 }
diff --git a/theme.nix b/theme.nix
@@ -1,20 +1,37 @@
 { lib }:
 let
+
+  # Black        | rgb(40, 44, 52)    | #282c34 |
+  # " | White        | rgb(171, 178, 191) | #abb2bf |
+  # " | Light Red    | rgb(224, 108, 117) | #e06c75 |
+  # " | Dark Red     | rgb(190, 80, 70)   | #be5046 |
+  # " | Green        | rgb(152, 195, 121) | #98c379 |
+  # " | Light Yellow | rgb(229, 192, 123) | #e5c07b |
+  # " | Dark Yellow  | rgb(209, 154, 102) | #d19a66 |
+  # " | Blue         | rgb(97, 175, 239)  | #61afef |
+  # " | Magenta      | rgb(198, 120, 221) | #c678dd |
+  # " | Cyan         | rgb(86, 182, 194)  | #56b6c2 |
+  # " | Gutter Grey  | rgb(76, 82, 99)    | #4b5263 |
+  # " | Comment Grey | rgb(92, 99, 112)   | #5c6370 |
+
   colors = {
-    black = "#282828";
-    blue = "#83a598";
-    gray2 = "#282828";
-    gray3 = "#3c3836";
-    gray4 = "#282828";
-    green = "#8ec07c";
-    orange = "#fe8019";
-    pink = "#d3869b";
-    red = "#fb4934";
-    white = "#ebdbb2";
-    yellow = "#b8bb26";
-    col_borderbar = "#1e2122";
+    black = "#282c34";
+    blue = "#61afef";
+    gray2 = "#4b5263";
+    gray3 = "#5c6370";
+    gray4 = "#4b5263";
+    green = "#98c379";
+    orange = "#d19a66";
+    pink = "#e06c75";
+    red = "#be5046";
+    white = "#abb2bf";
+    yellow = "#e5c07b";
+    magenta = "#c678dd";
+    cyan = "#56b6c2";
   };
 
+  #251d3a, #2a2550, #e04d01 and #ff7700.
+
   header = lib.concatStrings (lib.mapAttrsToList (name: value: "static const char ${name}[] = \"${value}\";\n") colors);
 in
-builtins.toFile "theme.h" header
-\ No newline at end of file
+builtins.toFile "theme.h" header