forge
Explore
Log in

Don't you dare go Hollow

Widen the gtk4 template, theme GTK2 via gtkrc

Browse files at this commit

e2bfda47c0b7e34750dddef5e38b6746a7c9679fAhmet Kaan GümüşParent: 061438f
  • feat
    • widen the gtk4 template, theme GTK2 via gtkrc
Show full message
feat(theming): widen the gtk4 template, theme GTK2 via gtkrc

gtk4.css template covers many more libadwaita widget classes so wallust
colors reach apps that were still stock.

theme_colors.sh now rewrites ~/.gtkrc-2.0: forces gtk-theme-name=Raleigh
(no pixmap engine, so our colors show) and moves the .mine include last
so it wins. Dropped the mix() resolver — the templates emit literals now.

qt5ct/qt6ct: window geometry only.
.config/qt5ct/qt5ct.confmodified+1 -1
@@ -24,7 +24,7 @@ underline_shortcut=1
2424 wheel_scroll_lines=3
2525
2626 [SettingsWindow]
27-geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\n\0\0\0\0\0\0\0\r\xae\0\0\x3\xfd\0\0\n\0\0\0\0\0\0\0\r\xb5\0\0\x4\x1\0\0\0\0\x2\0\0\0\a\x80\0\0\n\0\0\0\0\0\0\0\r\xae\0\0\x3\xfd)
27+geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\0\0\0\0\0\0\0\t\xe7\0\0\x5\x65\0\0\0\0\0\0\0\0\0\0\t\xff\0\0\x5\x9f\0\0\0\0\x2\0\0\0\n\0\0\0\0\0\0\0\0\0\0\0\t\xe7\0\0\x5\x65)
2828
2929 [Troubleshooting]
3030 force_raster_widgets=1
.config/qt6ct/qt6ct.confmodified+1 -1
@@ -24,7 +24,7 @@ underline_shortcut=1
2424 wheel_scroll_lines=3
2525
2626 [SettingsWindow]
27-geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\n\0\0\0\0\0\0\0\r\xae\0\0\x3\xfd\0\0\n\0\0\0\0\0\0\0\r\xae\0\0\x3\xfd\0\0\0\0\x2\0\0\0\a\x80\0\0\n\0\0\0\0\0\0\0\r\xae\0\0\x3\xfd)
27+geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\0\0\0\0\0\0\0\t\xe7\0\0\x5\x65\0\0\0\0\0\0\0\0\0\0\t\xe7\0\0\x5\x65\0\0\0\0\x2\0\0\0\n\0\0\0\0\0\0\0\0\0\0\0\t\xe7\0\0\x5\x65)
2828
2929 [Troubleshooting]
3030 force_raster_widgets=1
.config/scripts/shared/theme_colors.shmodified+74 -20
@@ -3,8 +3,46 @@
33 # - GTK 3/4: resolve mix(#hex, #hex, ratio) to pre-computed hex values
44 # - QT 5/6: convert colors and compute mixed surface colors
55
6-# Resolve mix() in GTK CSS files
7-for css in ~/.config/gtk-4.0/gtk.css ~/.config/gtk-4.0/gtk-dark.css ~/.config/gtk-3.0/gtk.css; do
6+# Configure ~/.gtkrc-2.0:
7+# - Force gtk-theme-name to Raleigh (minimal, no pixmap engine, lets our colors through)
8+# - Ensure our include is parsed LAST so our styles win
9+GTKRC="$HOME/.gtkrc-2.0"
10+MINE_INC='include "/home/tahinli/.gtkrc-2.0.mine"'
11+if [ -f "$GTKRC" ] && grep -qF "$MINE_INC" "$GTKRC"; then
12+ grep -vF "$MINE_INC" "$GTKRC" | sed 's/^gtk-theme-name=.*/gtk-theme-name="Raleigh"/' > "$GTKRC.tmp"
13+ echo "$MINE_INC" >> "$GTKRC.tmp"
14+ mv "$GTKRC.tmp" "$GTKRC"
15+fi
16+
17+# Convert hex colors to KDE's R,G,B integer format in kdeglobals
18+KDEGLOBALS="$HOME/.config/kdeglobals"
19+if [ -f "$KDEGLOBALS" ]; then
20+ python3 -c "
21+import re
22+def mix(c1, c2, f):
23+ r = int(int(c1[1:3],16)*(1-f) + int(c2[1:3],16)*f)
24+ g = int(int(c1[3:5],16)*(1-f) + int(c2[3:5],16)*f)
25+ b = int(int(c1[5:7],16)*(1-f) + int(c2[5:7],16)*f)
26+ return f'#{r:02x}{g:02x}{b:02x}'
27+with open('$KDEGLOBALS') as f:
28+ content = f.read()
29+content = re.sub(
30+ r'mix\(\s*(#[0-9A-Fa-f]{6})\s*,\s*(#[0-9A-Fa-f]{6})\s*,\s*([0-9.]+)\s*\)',
31+ lambda m: mix(m.group(1), m.group(2), float(m.group(3))),
32+ content
33+)
34+content = re.sub(
35+ r'#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})',
36+ lambda m: f'{int(m.group(1),16)},{int(m.group(2),16)},{int(m.group(3),16)}',
37+ content
38+)
39+with open('$KDEGLOBALS', 'w') as f:
40+ f.write(content)
41+"
42+fi
43+
44+# Resolve mix() in GTK CSS / gtkrc files
45+for css in ~/.config/gtk-4.0/gtk.css ~/.config/gtk-4.0/gtk-dark.css ~/.config/gtk-3.0/gtk.css ~/.gtkrc-2.0.mine; do
846 [ -f "$css" ] || continue
947 python3 -c "
1048 import re
@@ -29,35 +67,48 @@ done
2967 for conf in ~/.config/qt5ct/colors/wallust.conf ~/.config/qt6ct/colors/wallust.conf; do
3068 [ -f "$conf" ] || continue
3169
32- # Convert #RRGGBB to #ffRRGGBB
33- sed -i 's/#\([0-9A-Fa-f]\{6\}\)/#ff\1/g' "$conf"
70+ # Convert #RRGGBB to #ffRRGGBB (strip any existing ff first to avoid double-prefix)
71+ sed -i 's/#ff\([0-9A-Fa-f]\{6\}\)/#\1/g; s/#\([0-9A-Fa-f]\{6\}\)/#ff\1/g' "$conf"
3472
35- # Extract background (pos 4) and color1 (pos 1) from active_colors
73+ # Extract foreground (pos 0), color1 (pos 1), background (pos 4), color4 (pos 12)
3674 IFS=',' read -ra COLS <<< "$(grep '^active_colors=' "$conf" | cut -d'=' -f2)"
37- BG="${COLS[4]// /}" # Dark role = background
38- C1="${COLS[1]// /}" # Button role = color1
75+ FG="${COLS[0]// /}"
76+ C1="${COLS[1]// /}"
77+ BG="${COLS[4]// /}"
78+ C4="${COLS[12]// /}"
3979
40- BG="${BG/#\#ff/}"
80+ FG="${FG/#\#ff/}"
4181 C1="${C1/#\#ff/}"
82+ BG="${BG/#\#ff/}"
83+ C4="${C4/#\#ff/}"
4284
43- # Compute mix(bg, c1, ratio) for surface colors
44- SURFACE=$(python3 -c "
45-bg='$BG'; c1='$C1'
46-for f in [0.35, 0.45]:
47- r=int(int(bg[0:2],16)*(1-f)+int(c1[0:2],16)*f)
48- g=int(int(bg[2:4],16)*(1-f)+int(c1[2:4],16)*f)
49- b=int(int(bg[4:6],16)*(1-f)+int(c1[4:6],16)*f)
50- print(f'{r:02X}{g:02X}{b:02X}')
85+ # Compute mixed colors:
86+ # surface = mix(bg, c1, 0.35) - window/base
87+ # button = mix(bg, c1, 0.45) - button bg
88+ # accent = mix(c4, fg, 0.3) - lightened selection
89+ COMPUTED=$(python3 -c "
90+def m(a, b, f):
91+ r = int(int(a[0:2],16)*(1-f) + int(b[0:2],16)*f)
92+ g = int(int(a[2:4],16)*(1-f) + int(b[2:4],16)*f)
93+ bl = int(int(a[4:6],16)*(1-f) + int(b[4:6],16)*f)
94+ return f'{r:02X}{g:02X}{bl:02X}'
95+print(m('$BG', '$C1', 0.35))
96+print(m('$BG', '$C1', 0.45))
97+print(m('$C4', '$FG', 0.3))
5198 ")
52- MIXED=$(echo "$SURFACE" | head -1)
53- MIXED_BTN=$(echo "$SURFACE" | tail -1)
99+ MIXED=$(echo "$COMPUTED" | sed -n '1p')
100+ MIXED_BTN=$(echo "$COMPUTED" | sed -n '2p')
101+ MIXED_ACCENT=$(echo "$COMPUTED" | sed -n '3p')
54102
55103 # Replace surface roles: Base(9), Window(10), AlternateBase(16), ToolTipBase(17) with MIXED
56104 # Replace Button(1) with MIXED_BTN
105+ # Replace Highlight(12) and pos 20 with MIXED_ACCENT
57106 python3 -c "
58-import re
59-mixed, mixed_btn = '#ff$MIXED', '#ff$MIXED_BTN'
107+mixed = '#ff$MIXED'
108+mixed_btn = '#ff$MIXED_BTN'
109+mixed_accent = '#ff$MIXED_ACCENT'
60110 c1 = '#ff$C1'
111+c4 = '#ff$C4'
61112 with open('$conf') as f: lines = f.readlines()
62113 out = []
63114 for line in lines:
@@ -70,6 +121,9 @@ for line in lines:
70121 cols[i] = mixed
71122 if 1 < len(cols) and cols[1] == c1:
72123 cols[1] = mixed_btn
124+ for i in [12, 20]:
125+ if i < len(cols) and cols[i] == c4:
126+ cols[i] = mixed_accent
73127 out.append(key + '=' + ', '.join(cols) + '\n')
74128 with open('$conf', 'w') as f: f.writelines(out)
75129 "
.config/wallust/templates/gtk4.cssmodified+255 -12
@@ -1,11 +1,11 @@
11 /* Generated by wallust */
2-@define-color accent_bg_color {{color4}};
2+@define-color accent_bg_color mix({{color4}}, {{foreground}}, 0.3);
33 @define-color accent_fg_color {{color15}};
4-@define-color accent_color {{color4}};
4+@define-color accent_color mix({{color4}}, {{foreground}}, 0.3);
55
6-@define-color destructive_bg_color {{color1}};
6+@define-color destructive_bg_color mix({{color1}}, {{foreground}}, 0.3);
77 @define-color destructive_fg_color {{color15}};
8-@define-color destructive_color {{color1}};
8+@define-color destructive_color mix({{color1}}, {{foreground}}, 0.3);
99
1010 @define-color success_bg_color {{color2}};
1111 @define-color success_fg_color {{color15}};
@@ -15,9 +15,9 @@
1515 @define-color warning_fg_color {{background}};
1616 @define-color warning_color {{color3}};
1717
18-@define-color error_bg_color {{color1}};
18+@define-color error_bg_color mix({{color1}}, {{foreground}}, 0.3);
1919 @define-color error_fg_color {{color15}};
20-@define-color error_color {{color1}};
20+@define-color error_color mix({{color1}}, {{foreground}}, 0.3);
2121
2222 @define-color window_bg_color mix({{background}}, {{color1}}, 0.35);
2323 @define-color window_fg_color {{foreground}};
@@ -76,22 +76,265 @@ popover contents {
7676 color: {{foreground}};
7777 }
7878
79+popover modelbutton:hover,
80+popover modelbutton:focus,
81+popover .menuitem:hover,
82+modelbutton:hover {
83+ background-color: alpha({{foreground}}, 0.1);
84+ color: {{foreground}};
85+}
86+
87+popover modelbutton:active,
88+modelbutton:active {
89+ background-color: alpha({{foreground}}, 0.15);
90+}
91+
92+.osd,
93+.toolbar,
94+box.toolbar,
95+.background.osd,
96+.flat-style-toolbar {
97+ background-color: mix({{background}}, {{color1}}, 0.4);
98+ color: {{foreground}};
99+ border-color: mix({{background}}, {{color1}}, 0.5);
100+}
101+
102+notebook header,
103+notebook tab,
104+notebook tabs,
105+viewswitcher,
106+viewswitcher button,
107+stackswitcher,
108+stackswitcher button,
109+.stack-switcher button,
110+columnview header,
111+columnview header button,
112+treeview.view header button,
113+header.view {
114+ background-color: mix({{background}}, {{color1}}, 0.4);
115+ background-image: none;
116+ color: {{foreground}};
117+ border-color: mix({{background}}, {{color1}}, 0.5);
118+ box-shadow: none;
119+}
120+
121+stackswitcher button:checked,
122+viewswitcher button:checked,
123+.stack-switcher button:checked {
124+ background-color: mix({{color4}}, {{foreground}}, 0.3);
125+ color: {{color15}};
126+}
127+
128+notebook tab:checked {
129+ background-color: mix({{background}}, {{color1}}, 0.7);
130+ color: {{foreground}};
131+ box-shadow: inset 0 -3px 0 0 mix({{color4}}, {{foreground}}, 0.3);
132+}
133+
134+notebook tab:hover:not(:checked) {
135+ background-color: mix({{background}}, {{color1}}, 0.55);
136+}
137+
138+.colorsetter:checked,
139+button.colorsetter:checked,
140+togglebutton.colorsetter:checked {
141+ background-color: @colorsetter_color;
142+ background-image:
143+ linear-gradient(45deg, #0f0f0f55 25%, transparent 25%, transparent 75%, #0f0f0f55 75%, #0f0f0f55),
144+ linear-gradient(45deg, #0f0f0f55 25%, transparent 25%, transparent 75%, #0f0f0f55 75%, #0f0f0f55);
145+ color: @colorsetter_fg_color;
146+ box-shadow: inset 0 -3px 0 0 @colorsetter_fg_color;
147+}
148+
79149 row:selected {
80- background-color: {{color4}};
150+ background-color: mix({{color4}}, {{foreground}}, 0.3);
151+ color: {{color15}};
152+}
153+
154+button.suggested-action,
155+.dialog-action-area button.suggested-action,
156+dialog button.suggested-action {
157+ background-color: mix({{color4}}, {{foreground}}, 0.3);
158+ background-image: none;
81159 color: {{color15}};
160+ box-shadow: none;
161+ border: none;
82162 }
83163
84-button.suggested-action {
85- background-color: {{color4}};
164+button.destructive-action,
165+.dialog-action-area button.destructive-action,
166+dialog button.destructive-action {
167+ background-color: mix({{color1}}, {{foreground}}, 0.3);
168+ background-image: none;
86169 color: {{color15}};
170+ box-shadow: none;
171+ border: none;
87172 }
88173
89-button.destructive-action {
90- background-color: {{color1}};
174+dialog button,
175+.dialog-action-area button,
176+messagedialog button {
177+ background-color: mix({{background}}, {{color1}}, 0.45);
178+ background-image: none;
179+ color: {{foreground}};
180+ border-color: mix({{background}}, {{color1}}, 0.55);
181+ box-shadow: none;
182+}
183+
184+dialog button.suggested-action,
185+.dialog-action-area button.suggested-action,
186+messagedialog button.suggested-action {
187+ background-color: mix({{color4}}, {{foreground}}, 0.3);
91188 color: {{color15}};
92189 }
93190
94-entry {
191+dialog button.destructive-action,
192+.dialog-action-area button.destructive-action,
193+messagedialog button.destructive-action {
194+ background-color: mix({{color1}}, {{foreground}}, 0.3);
195+ color: {{color15}};
196+}
197+
198+entry,
199+entry text,
200+spinbutton,
201+spinbutton entry,
202+spinbutton text,
203+combobox,
204+combobox button,
205+combobox entry,
206+dropdown,
207+dropdown button,
208+dropdown > button,
209+fontbutton,
210+fontbutton button,
211+filechooserbutton,
212+filechooserbutton button {
95213 background-color: mix({{background}}, {{color1}}, 0.3);
214+ background-image: none;
96215 color: {{foreground}};
216+ border-color: mix({{background}}, {{color1}}, 0.5);
217+ box-shadow: none;
218+}
219+
220+headerbar button,
221+headerbar button.flat,
222+windowhandle button,
223+windowhandle button.flat,
224+.toolbar button.flat,
225+.titlebar button,
226+.titlebar button.flat,
227+pathbar button,
228+pathbar button.flat,
229+button.image-button,
230+button.flat {
231+ background-color: transparent;
232+ background-image: none;
233+ box-shadow: none;
234+ border: none;
235+ outline: none;
236+ color: {{foreground}};
237+}
238+
239+headerbar button.flat:hover,
240+windowhandle button.flat:hover,
241+.toolbar button.flat:hover,
242+.titlebar button.flat:hover,
243+.titlebar button:hover,
244+pathbar button:hover,
245+button.image-button:hover,
246+button.flat:hover {
247+ background-color: alpha({{foreground}}, 0.12);
248+ box-shadow: none;
249+}
250+
251+button:checked,
252+button.flat:checked,
253+button.toggle:checked,
254+togglebutton:checked,
255+headerbar button:checked,
256+windowhandle button:checked,
257+.toolbar button:checked {
258+ background-color: mix({{color4}}, {{foreground}}, 0.3);
259+ background-image: none;
260+ color: {{color15}};
261+ box-shadow: none;
262+ border: none;
263+ outline: none;
264+}
265+
266+button:not(.color):not(.colorsetter):not(.flat):not(.image-button):not(.suggested-action):not(.destructive-action):not(:checked) {
267+ background-color: mix({{background}}, {{color1}}, 0.45);
268+ background-image: none;
269+ color: {{foreground}};
270+ border-color: mix({{background}}, {{color1}}, 0.55);
271+ box-shadow: none;
272+}
273+
274+button:not(.color):not(.colorsetter):not(.flat):not(.image-button):not(.suggested-action):not(.destructive-action):not(:checked):hover {
275+ background-color: mix({{background}}, {{color1}}, 0.55);
276+}
277+
278+checkbutton check,
279+checkbutton radio,
280+check,
281+radio {
282+ background-color: mix({{background}}, {{color1}}, 0.4);
283+ background-image: none;
284+ border-color: mix({{background}}, {{color1}}, 0.6);
285+ color: {{foreground}};
286+}
287+
288+checkbutton check:checked,
289+checkbutton radio:checked,
290+check:checked,
291+radio:checked,
292+checkbutton check:indeterminate,
293+check:indeterminate {
294+ background-color: mix({{color4}}, {{foreground}}, 0.3);
295+ background-image: none;
296+ color: {{color15}};
297+ border-color: mix({{color4}}, {{foreground}}, 0.3);
298+}
299+
300+switch {
301+ background-color: mix({{background}}, {{color1}}, 0.4);
302+ background-image: none;
303+}
304+
305+switch:checked {
306+ background-color: mix({{color4}}, {{foreground}}, 0.3);
307+ background-image: none;
308+}
309+
310+switch slider {
311+ background-color: {{foreground}};
312+ background-image: none;
313+ border-color: mix({{background}}, {{color1}}, 0.5);
314+}
315+
316+scale trough {
317+ background-color: mix({{background}}, {{color1}}, 0.4);
318+ background-image: none;
319+}
320+
321+scale highlight {
322+ background-color: mix({{color4}}, {{foreground}}, 0.3);
323+ background-image: none;
324+}
325+
326+scale slider {
327+ background-color: {{foreground}};
328+ background-image: none;
329+ border-color: mix({{background}}, {{color1}}, 0.5);
330+}
331+
332+progressbar trough {
333+ background-color: mix({{background}}, {{color1}}, 0.4);
334+ background-image: none;
335+}
336+
337+progressbar progress {
338+ background-color: mix({{color4}}, {{foreground}}, 0.3);
339+ background-image: none;
97340 }