sites

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

dmenu-xtheme-20220325-005000.diff (4586B)


      1 diff --git a/Makefile b/Makefile
      2 index a03a95c..4ccdf8d 100644
      3 --- a/Makefile
      4 +++ b/Makefile
      5 @@ -17,19 +17,26 @@ options:
      6  .c.o:
      7  	$(CC) -c $(CFLAGS) $<
      8  
      9 -config.h:
     10 -	cp config.def.h $@
     11 +theme.h:
     12 +	./xtheme
     13  
     14 -$(OBJ): arg.h config.h config.mk drw.h
     15 +theme_beg.h:
     16 +	./themesetup
     17 +
     18 +config.h: theme.h
     19 +	cp -n config.def.h $@
     20 +
     21 +$(OBJ): arg.h config.h config.mk drw.h theme_beg.h
     22  
     23  dmenu: dmenu.o drw.o util.o
     24  	$(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS)
     25 +	rm -f theme_{beg,end}.h
     26  
     27  stest: stest.o
     28  	$(CC) -o $@ stest.o $(LDFLAGS)
     29  
     30  clean:
     31 -	rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
     32 +	rm -f dmenu stest $(OBJ) theme_{beg,end}.h dmenu-$(VERSION).tar.gz
     33  
     34  dist: clean
     35  	mkdir -p dmenu-$(VERSION)
     36 diff --git a/config.def.h b/config.def.h
     37 index 1edb647..c072c86 100644
     38 --- a/config.def.h
     39 +++ b/config.def.h
     40 @@ -1,17 +1,19 @@
     41  /* See LICENSE file for copyright and license details. */
     42  /* Default settings; can be overriden by command line. */
     43  
     44 -static int topbar = 1;                      /* -b  option; if 0, dmenu appears at bottom     */
     45 +/* theme management */
     46 +# include "theme_beg.h" /* this is a compile-time generated header file */
     47 +# include "theme.h"
     48 +
     49 +static int topbar = DMENU_TOPBAR;                      /* -b  option; if 0, dmenu appears at bottom     */
     50  /* -fn option overrides fonts[0]; default X11 font or font set */
     51 -static const char *fonts[] = {
     52 -	"monospace:size=10"
     53 -};
     54 +static const char *fonts[] = DMENU_FONTS;
     55  static const char *prompt      = NULL;      /* -p  option; prompt to the left of input field */
     56  static const char *colors[SchemeLast][2] = {
     57  	/*     fg         bg       */
     58 -	[SchemeNorm] = { "#bbbbbb", "#222222" },
     59 -	[SchemeSel] = { "#eeeeee", "#005577" },
     60 -	[SchemeOut] = { "#000000", "#00ffff" },
     61 +	[SchemeNorm] = { DMENU_FOREGROUND, DMENU_BACKGROUND },
     62 +	[SchemeSel] = { DMENU_SELFOREGROUND, DMENU_SELBACKGROUND },
     63 +	[SchemeOut] = { DMENU_OUTFOREGROUND, DMENU_OUTBACKGROUND },
     64  };
     65  /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
     66  static unsigned int lines      = 0;
     67 @@ -21,3 +23,6 @@ static unsigned int lines      = 0;
     68   * for example: " /?\"&[]"
     69   */
     70  static const char worddelimiters[] = " ";
     71 +
     72 +/* theme management */
     73 +# include "theme_end.h" /* this is a compile-time generated header file */
     74 diff --git a/theme.h b/theme.h
     75 new file mode 100644
     76 index 0000000..e25c106
     77 --- /dev/null
     78 +++ b/theme.h
     79 @@ -0,0 +1,8 @@
     80 +# define DMENU_TOPBAR 1
     81 +# define DMENU_FONTS {"monospace:size=10"}
     82 +# define DMENU_FOREGROUND "#839496"
     83 +# define DMENU_BACKGROUND "#002b36"
     84 +# define DMENU_SELFOREGROUND "#002b36"
     85 +# define DMENU_SELBACKGROUND "#839496"
     86 +# define DMENU_OUTFOREGROUND "#000000"
     87 +# define DMENU_OUTBACKGROUND "#00ffff"
     88 diff --git a/themesetup b/themesetup
     89 new file mode 100755
     90 index 0000000..e8710c1
     91 --- /dev/null
     92 +++ b/themesetup
     93 @@ -0,0 +1,5 @@
     94 +#!/bin/sh
     95 +
     96 +echo \# if $(cat theme.h | cut -d' ' -f3 | sed "s/^/defined /;s/$/ ||/" | tr "\n" " ") 0 > theme_beg.h
     97 +echo -e "# error (conflicting macro names)\n# endif" >> theme_beg.h
     98 +cat theme.h | cut -d' ' -f3 | sed "s/^/# undef /;" > theme_end.h
     99 diff --git a/xtable.md b/xtable.md
    100 new file mode 100644
    101 index 0000000..cda7c05
    102 --- /dev/null
    103 +++ b/xtable.md
    104 @@ -0,0 +1,10 @@
    105 +|	TYPE	|	RESOURCE		|	DEFAULT VALUE			|	[ALTERNATIVE RESOURCE]	|
    106 +|:---------:|:-----------------:|:-------------------------:|:-------------------------:|
    107 +|	I		|	topbar			|	1						|							|
    108 +|	SA		|	fonts			|	monospace:size=10		|							|
    109 +|	S		|	foreground		|	#bbbbbb					|							|
    110 +|	S		|	background		|	#222222					|							|
    111 +|	S		|	selforeground	|	#eeeeee					|	background				|
    112 +|	S		|	selbackground	|	#005577					|	foreground				|
    113 +|	S		|	outforeground	|	#000000					|							|
    114 +|	S		|	outbackground	|	#00ffff					|							|
    115 diff --git a/xtheme b/xtheme
    116 new file mode 100755
    117 index 0000000..4cc3067
    118 --- /dev/null
    119 +++ b/xtheme
    120 @@ -0,0 +1,51 @@
    121 +#!/bin/sh
    122 +
    123 +prefix=dmenu
    124 +themeout=theme.h
    125 +xtable=xtable.md
    126 +
    127 +rm -f $themeout
    128 +
    129 +set_resource ()
    130 +{
    131 +	T=$1
    132 +	M=$2
    133 +	V=$3
    134 +
    135 +	case $T in
    136 +		S)
    137 +			V=\"$V\"
    138 +			;;
    139 +		SA)
    140 +			V="{\"$(echo $V | sed 's/, /", "/g')\"}"
    141 +	esac
    142 +
    143 +	[[ $V == '{""}' ]] && V="{}"
    144 +
    145 +	echo "# define $M $V" >> $themeout
    146 +}
    147 +
    148 +cat "$xtable"											|
    149 +	sed '1,2d;s/\t*|\t*/|/g;s/\(^|\)\|\(|$\)//g'		|
    150 +	while IFS='|' read T R D A
    151 +	do
    152 +		m=$(echo "$prefix"'_'"$R" | tr '[:lower:]' '[:upper:]')
    153 +
    154 +		l=''
    155 +
    156 +		for r in "$R" "$A"
    157 +		do
    158 +			[[ "$r" == '' ]] && continue
    159 +
    160 +			l=$(xgetres "$prefix.$r")
    161 +
    162 +			if [[ "$l" != '' ]]
    163 +			then
    164 +				set_resource $T $m "$l"
    165 +				break
    166 +			fi
    167 +		done
    168 +
    169 +		[[ "$l" == '' ]] &&
    170 +			set_resource $T $m "$D"
    171 +	done