tabbed-xtheme-20220325-005500.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
tabbed-xtheme-20220325-005500.diff (4180B)
---
1 diff --git a/Makefile b/Makefile
2 index 1b95d15..1191145 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -8,6 +8,7 @@ OBJ = ${SRC:.c=.o}
6 BIN = ${OBJ:.o=}
7
8 all: options ${BIN}
9 + rm -f theme_{beg,end}.h
10
11 options:
12 @echo tabbed build options:
13 @@ -19,11 +20,17 @@ options:
14 @echo CC $<
15 @${CC} -c ${CFLAGS} $<
16
17 -${OBJ}: config.h config.mk
18 +${OBJ}: config.h theme_beg.h config.mk
19
20 -config.h:
21 +theme.h:
22 + ./xtheme
23 +
24 +theme_beg.h:
25 + ./themesetup
26 +
27 +config.h: theme.h
28 @echo creating $@ from config.def.h
29 - @cp config.def.h $@
30 + @cp -n config.def.h $@
31
32 .o:
33 @echo CC -o $@
34 @@ -31,7 +38,7 @@ config.h:
35
36 clean:
37 @echo cleaning
38 - @rm -f ${BIN} ${OBJ} tabbed-${VERSION}.tar.gz
39 + @rm -f ${BIN} ${OBJ} theme_{beg,end}.h tabbed-${VERSION}.tar.gz
40
41 dist: clean
42 @echo creating dist tarball
43 diff --git a/config.def.h b/config.def.h
44 index defa426..7c1126e 100644
45 --- a/config.def.h
46 +++ b/config.def.h
47 @@ -1,13 +1,17 @@
48 /* See LICENSE file for copyright and license details. */
49
50 +/* theme management */
51 +# include "theme_beg.h" /* this is a compile-time generated header file */
52 +# include "theme.h"
53 +
54 /* appearance */
55 -static const char font[] = "monospace:size=9";
56 -static const char* normbgcolor = "#222222";
57 -static const char* normfgcolor = "#cccccc";
58 -static const char* selbgcolor = "#555555";
59 -static const char* selfgcolor = "#ffffff";
60 -static const char* urgbgcolor = "#111111";
61 -static const char* urgfgcolor = "#cc0000";
62 +static const char font[] = TABBED_FONT;
63 +static const char* normbgcolor = TABBED_BACKGROUND;
64 +static const char* normfgcolor = TABBED_FOREGROUND;
65 +static const char* selbgcolor = TABBED_SELBACKGROUND;
66 +static const char* selfgcolor = TABBED_SELFOREGROUND;
67 +static const char* urgbgcolor = TABBED_URGBACKGROUND;
68 +static const char* urgfgcolor = TABBED_URGFOREGROUND;
69 static const char before[] = "<";
70 static const char after[] = ">";
71 static const char titletrim[] = "...";
72 @@ -23,6 +27,9 @@ static Bool urgentswitch = False;
73 static int newposition = 0;
74 static Bool npisrelative = False;
75
76 +/* theme management */
77 +# include "theme_end.h" /* this is a compile-time generated header file */
78 +
79 #define SETPROP(p) { \
80 .v = (char *[]){ "/bin/sh", "-c", \
81 "prop=\"`xwininfo -children -id $1 | grep '^ 0x' |" \
82 diff --git a/themesetup b/themesetup
83 new file mode 100755
84 index 0000000..e8710c1
85 --- /dev/null
86 +++ b/themesetup
87 @@ -0,0 +1,5 @@
88 +#!/bin/sh
89 +
90 +echo \# if $(cat theme.h | cut -d' ' -f3 | sed "s/^/defined /;s/$/ ||/" | tr "\n" " ") 0 > theme_beg.h
91 +echo -e "# error (conflicting macro names)\n# endif" >> theme_beg.h
92 +cat theme.h | cut -d' ' -f3 | sed "s/^/# undef /;" > theme_end.h
93 diff --git a/xtable.md b/xtable.md
94 new file mode 100644
95 index 0000000..e05753a
96 --- /dev/null
97 +++ b/xtable.md
98 @@ -0,0 +1,9 @@
99 +| TYPE | RESOURCE | DEFAULT VALUE | [ALTERNATIVE RESOURCE] |
100 +|:---------:|:---------------------:|:-------------------------:|:-------------------------:|
101 +| SA | font | monospace:size=9 | |
102 +| S | background | #222222 | |
103 +| S | foreground | #cccccc | |
104 +| S | selbackground | #555555 | foreground |
105 +| S | selforeground | #ffffff | background |
106 +| S | urgbackground | #111111 | |
107 +| S | urgforeground | #cc0000 | |
108 diff --git a/xtheme b/xtheme
109 new file mode 100755
110 index 0000000..6396cdd
111 --- /dev/null
112 +++ b/xtheme
113 @@ -0,0 +1,51 @@
114 +#!/bin/sh
115 +
116 +prefix=tabbed
117 +themeout=theme.h
118 +xtable=xtable.md
119 +
120 +rm -f $themeout
121 +
122 +set_resource ()
123 +{
124 + T=$1
125 + M=$2
126 + V=$3
127 +
128 + case $T in
129 + S)
130 + V=\"$V\"
131 + ;;
132 + SA)
133 + V="{\"$(echo $V | sed 's/, /", "/g')\"}"
134 + esac
135 +
136 + [[ $V == '{""}' ]] && V="{}"
137 +
138 + echo "# define $M $V" >> $themeout
139 +}
140 +
141 +cat "$xtable" |
142 + sed '1,2d;s/\t*|\t*/|/g;s/\(^|\)\|\(|$\)//g' |
143 + while IFS='|' read T R D A
144 + do
145 + m=$(echo "$prefix"'_'"$R" | tr '[:lower:]' '[:upper:]')
146 +
147 + l=''
148 +
149 + for r in "$R" "$A"
150 + do
151 + [[ "$r" == '' ]] && continue
152 +
153 + l=$(xgetres "$prefix.$r")
154 +
155 + if [[ "$l" != '' ]]
156 + then
157 + set_resource $T $m "$l"
158 + break
159 + fi
160 + done
161 +
162 + [[ "$l" == '' ]] &&
163 + set_resource $T $m "$D"
164 + done