sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-xtheme-20220216-044040-dwm-6.3.diff (5081B)


      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..830a8a5 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 unsigned int borderpx  = DWM_BORDERPX;        /* border pixel of windows */
     51 +static const unsigned int snap      = DWM_SNAP;            /* snap pixel */
     52 +static const int showbar            = DWM_SHOWBAR;         /* 0 means no bar */
     53 +static const int topbar             = DWM_TOPBAR;          /* 0 means bottom bar */
     54 +static const char *fonts[]          = { DWM_FONT };
     55  static const char dmenufont[]       = "monospace:size=10";
     56  static const char col_gray1[]       = "#222222";
     57  static const char col_gray2[]       = "#444444";
     58 @@ -13,9 +17,9 @@ static const char col_gray3[]       = "#bbbbbb";
     59  static const char col_gray4[]       = "#eeeeee";
     60  static const char col_cyan[]        = "#005577";
     61  static const char *colors[][3]      = {
     62 -	/*               fg         bg         border   */
     63 -	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
     64 -	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
     65 +	/*               fg                 bg                 border   */
     66 +	[SchemeNorm] = { DWM_FOREGROUND,    DWM_BACKGROUND,    DWM_BORDER },
     67 +	[SchemeSel]  = { DWM_SELFOREGROUND, DWM_SELBACKGROUND, DWM_SELBORDER },
     68  };
     69  
     70  /* tagging */
     71 @@ -60,6 +64,9 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
     72  static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
     73  static const char *termcmd[]  = { "st", NULL };
     74  
     75 +/* theme management */
     76 +# include "theme_end.h" /* this is a compile-time generated header file */
     77 +
     78  static Key keys[] = {
     79  	/* modifier                     key        function        argument */
     80  	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
     81 diff --git a/themesetup b/themesetup
     82 new file mode 100755
     83 index 0000000..e8710c1
     84 --- /dev/null
     85 +++ b/themesetup
     86 @@ -0,0 +1,5 @@
     87 +#!/bin/sh
     88 +
     89 +echo \# if $(cat theme.h | cut -d' ' -f3 | sed "s/^/defined /;s/$/ ||/" | tr "\n" " ") 0 > theme_beg.h
     90 +echo -e "# error (conflicting macro names)\n# endif" >> theme_beg.h
     91 +cat theme.h | cut -d' ' -f3 | sed "s/^/# undef /;" > theme_end.h
     92 diff --git a/xtable.md b/xtable.md
     93 new file mode 100644
     94 index 0000000..6beae36
     95 --- /dev/null
     96 +++ b/xtable.md
     97 @@ -0,0 +1,13 @@
     98 +|	TYPE	|	RESOURCE		|	DEFAULT VALUE		|	[ALTERNATIVE RESOURCE]	|
     99 +|:---------:|:-----------------:|:---------------------:|:-------------------------:|
    100 +|	U		|	borderpx		|	1					|							|
    101 +|	U		|	snap			|	32					|							|
    102 +|	I		|	showbar			|	1					|							|
    103 +|	I		|	topbar			|	1					|							|
    104 +|	S		|	font			|	monospace:size=10	|							|
    105 +|	S		|	foreground		|	#93a1a1				|							|
    106 +|	S		|	background		|	#002b36				|							|
    107 +|	S		|	border			|	#93a1a1				|	background				|
    108 +|	S		|	selforeground	|	#073642				|	background				|
    109 +|	S		|	selbackground	|	#2aa198				|	foreground				|
    110 +|	S		|	selborder		|	#cb4b16				|	foreground				|
    111 diff --git a/xtheme b/xtheme
    112 new file mode 100755
    113 index 0000000..c7dee63
    114 --- /dev/null
    115 +++ b/xtheme
    116 @@ -0,0 +1,49 @@
    117 +#!/bin/sh
    118 +
    119 +prefix=dwm
    120 +themeout=theme.h
    121 +xtable=xtable.md
    122 +
    123 +rm -f $themeout
    124 +
    125 +cat "$xtable"												|
    126 +	sed '1,2d;s/\(^|\t*\)\|\(|$\)//g;s/\t\+|\t\+/|/g'		|
    127 +	while IFS='|' read T R D A
    128 +	do
    129 +		m=$(echo "$prefix"'_'"$R" | tr '[:lower:]' '[:upper:]')
    130 +
    131 +		s=''
    132 +		[[ "$T" == "S" ]] && s=\"
    133 +
    134 +		l=''
    135 +
    136 +		for r in "$R" "$A"
    137 +		do
    138 +			[[ "$r" == '' ]] && continue
    139 +
    140 +			e=0
    141 +
    142 +			for p in "$prefix" ''
    143 +			do
    144 +				l="$(																\
    145 +					xrdb -query														\
    146 +						| grep -P "^$p\*?\.?$r:\s*\S*$" -m 1						\
    147 +						| sed "s/^$p\*\?\.\?$r:\s*\(\S*\)$/# define $m $s\1$s/"		\
    148 +				)"
    149 +
    150 +				if [[ "$l" != '' ]]
    151 +				then
    152 +					e=1
    153 +					echo "$l" >> $themeout
    154 +					break
    155 +				fi
    156 +			done
    157 +
    158 +			[[ $e == 1 ]] && break
    159 +		done
    160 +
    161 +		if [[ "$l" == '' ]]
    162 +		then
    163 +			echo "# define $m $s$D$s" >> $themeout
    164 +		fi
    165 +	done