dwm-xtheme-20220214-135624-dwm-6.3.diff (4683B)
1 diff --git a/Makefile b/Makefile 2 index 77bcbc0..fadb218 100644 3 --- a/Makefile 4 +++ b/Makefile 5 @@ -17,16 +17,23 @@ options: 6 .c.o: 7 ${CC} -c ${CFLAGS} $< 8 9 -${OBJ}: config.h config.mk 10 +${OBJ}: config.h theme_beg.h config.mk 11 12 -config.h: 13 - cp config.def.h $@ 14 +theme.h: 15 + ./xtheme 16 + 17 +theme_beg.h: 18 + ./themesetup 19 + 20 +config.h: theme.h 21 + cp -n config.def.h $@ 22 23 dwm: ${OBJ} 24 ${CC} -o $@ ${OBJ} ${LDFLAGS} 25 + rm -f theme_{beg,end}.h 26 27 clean: 28 - rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz 29 + rm -f dwm ${OBJ} theme_{beg,end}.h dwm-${VERSION}.tar.gz 30 31 dist: clean 32 mkdir -p dwm-${VERSION} 33 diff --git a/config.def.h b/config.def.h 34 index a2ac963..daf66b3 100644 35 --- a/config.def.h 36 +++ b/config.def.h 37 @@ -1,11 +1,15 @@ 38 /* See LICENSE file for copyright and license details. */ 39 40 +/* theme management */ 41 +# include "theme_beg.h" /* this is a compile-time generated header file */ 42 +# include "theme.h" 43 + 44 /* appearance */ 45 static const unsigned int borderpx = 1; /* border pixel of windows */ 46 static const unsigned int snap = 32; /* snap pixel */ 47 static const int showbar = 1; /* 0 means no bar */ 48 static const int topbar = 1; /* 0 means bottom bar */ 49 -static const char *fonts[] = { "monospace:size=10" }; 50 +static const char *fonts[] = { DWM_FONT }; 51 static const char dmenufont[] = "monospace:size=10"; 52 static const char col_gray1[] = "#222222"; 53 static const char col_gray2[] = "#444444"; 54 @@ -13,9 +17,9 @@ static const char col_gray3[] = "#bbbbbb"; 55 static const char col_gray4[] = "#eeeeee"; 56 static const char col_cyan[] = "#005577"; 57 static const char *colors[][3] = { 58 - /* fg bg border */ 59 - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, 60 - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, 61 + /* fg bg border */ 62 + [SchemeNorm] = { DWM_FOREGROUND, DWM_BACKGROUND, DWM_BORDER }, 63 + [SchemeSel] = { DWM_SELFOREGROUND, DWM_SELBACKGROUND, DWM_SELBORDER }, 64 }; 65 66 /* tagging */ 67 @@ -60,6 +64,9 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() 68 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; 69 static const char *termcmd[] = { "st", NULL }; 70 71 +/* theme management */ 72 +# include "theme_end.h" /* this is a compile-time generated header file */ 73 + 74 static Key keys[] = { 75 /* modifier key function argument */ 76 { MODKEY, XK_p, spawn, {.v = dmenucmd } }, 77 diff --git a/themesetup b/themesetup 78 new file mode 100755 79 index 0000000..e8710c1 80 --- /dev/null 81 +++ b/themesetup 82 @@ -0,0 +1,5 @@ 83 +#!/bin/sh 84 + 85 +echo \# if $(cat theme.h | cut -d' ' -f3 | sed "s/^/defined /;s/$/ ||/" | tr "\n" " ") 0 > theme_beg.h 86 +echo -e "# error (conflicting macro names)\n# endif" >> theme_beg.h 87 +cat theme.h | cut -d' ' -f3 | sed "s/^/# undef /;" > theme_end.h 88 diff --git a/xresources.defaults b/xresources.defaults 89 new file mode 100644 90 index 0000000..7f1d86a 91 --- /dev/null 92 +++ b/xresources.defaults 93 @@ -0,0 +1,7 @@ 94 +# define DWM_FONT "monospace" 95 +# define DWM_FOREGROUND "#93a1a1" 96 +# define DWM_BACKGROUND "#002b36" 97 +# define DWM_BORDER "#93a1a1" 98 +# define DWM_SELFOREGROUND "#073642" 99 +# define DWM_SELBACKGROUND "#2aa198" 100 +# define DWM_SELBORDER "#cb4b16" 101 diff --git a/xresources.list b/xresources.list 102 new file mode 100644 103 index 0000000..2b8421f 104 --- /dev/null 105 +++ b/xresources.list 106 @@ -0,0 +1,7 @@ 107 +S font 108 +S foreground 109 +S background 110 +S border background 111 +S selforeground background 112 +S selbackground foreground 113 +S selborder foreground 114 diff --git a/xtheme b/xtheme 115 new file mode 100755 116 index 0000000..8fa5f08 117 --- /dev/null 118 +++ b/xtheme 119 @@ -0,0 +1,49 @@ 120 +#!/bin/sh 121 + 122 +prefix=dwm 123 +resfile=xresources.list 124 +themeout=theme.h 125 +# themedefaults=themes/$prefix-defaults.h 126 +themedefaults=xresources.defaults 127 + 128 +rm -f $themeout 129 + 130 +cat "$resfile" | while read T R A 131 +do 132 + m=$(echo "$prefix"'_'"$R" | tr '[:lower:]' '[:upper:]') 133 + 134 + s='' 135 + [[ "$T" == "S" ]] && s=\" 136 + 137 + l='' 138 + 139 + for r in "$R" "$A" 140 + do 141 + [[ "$r" == '' ]] && continue 142 + 143 + e=0 144 + 145 + for p in "$prefix" '' 146 + do 147 + l="$( \ 148 + xrdb -query \ 149 + | grep -P "^$p\*?\.?$r:\s*\S*$" -m 1 \ 150 + | sed "s/^$p\*\?\.\?$r:\s*\(\S*\)$/# define $m $s\1$s/" \ 151 + )" 152 + 153 + if [[ "$l" != '' ]] 154 + then 155 + e=1 156 + echo "$l" >> $themeout 157 + break 158 + fi 159 + done 160 + 161 + [[ $e == 1 ]] && break 162 + done 163 + 164 + if [[ "$l" == '' ]] 165 + then 166 + cat "$themedefaults" | grep -P "^# define $m " -m 1 >> $themeout 167 + fi 168 +done