From e2bfda47c0b7e34750dddef5e38b6746a7c9679f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 30 Jul 2026 04:36:29 +0300 Subject: [PATCH] feat(theming): widen the gtk4 template, theme GTK2 via gtkrc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.conf | 2 +- .config/qt6ct/qt6ct.conf | 2 +- .config/scripts/shared/theme_colors.sh | 94 +++++++-- .config/wallust/templates/gtk4.css | 267 +++++++++++++++++++++++-- 4 files changed, 331 insertions(+), 34 deletions(-) diff --git a/.config/qt5ct/qt5ct.conf b/.config/qt5ct/qt5ct.conf index f86d841..fd59f6e 100644 --- a/.config/qt5ct/qt5ct.conf +++ b/.config/qt5ct/qt5ct.conf @@ -24,7 +24,7 @@ underline_shortcut=1 wheel_scroll_lines=3 [SettingsWindow] -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) +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) [Troubleshooting] force_raster_widgets=1 diff --git a/.config/qt6ct/qt6ct.conf b/.config/qt6ct/qt6ct.conf index c716718..51dd939 100644 --- a/.config/qt6ct/qt6ct.conf +++ b/.config/qt6ct/qt6ct.conf @@ -24,7 +24,7 @@ underline_shortcut=1 wheel_scroll_lines=3 [SettingsWindow] -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) +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) [Troubleshooting] force_raster_widgets=1 diff --git a/.config/scripts/shared/theme_colors.sh b/.config/scripts/shared/theme_colors.sh index 2a4c375..3dbb492 100755 --- a/.config/scripts/shared/theme_colors.sh +++ b/.config/scripts/shared/theme_colors.sh @@ -3,8 +3,46 @@ # - GTK 3/4: resolve mix(#hex, #hex, ratio) to pre-computed hex values # - QT 5/6: convert colors and compute mixed surface colors -# Resolve mix() in GTK CSS files -for css in ~/.config/gtk-4.0/gtk.css ~/.config/gtk-4.0/gtk-dark.css ~/.config/gtk-3.0/gtk.css; do +# Configure ~/.gtkrc-2.0: +# - Force gtk-theme-name to Raleigh (minimal, no pixmap engine, lets our colors through) +# - Ensure our include is parsed LAST so our styles win +GTKRC="$HOME/.gtkrc-2.0" +MINE_INC='include "/home/tahinli/.gtkrc-2.0.mine"' +if [ -f "$GTKRC" ] && grep -qF "$MINE_INC" "$GTKRC"; then + grep -vF "$MINE_INC" "$GTKRC" | sed 's/^gtk-theme-name=.*/gtk-theme-name="Raleigh"/' > "$GTKRC.tmp" + echo "$MINE_INC" >> "$GTKRC.tmp" + mv "$GTKRC.tmp" "$GTKRC" +fi + +# Convert hex colors to KDE's R,G,B integer format in kdeglobals +KDEGLOBALS="$HOME/.config/kdeglobals" +if [ -f "$KDEGLOBALS" ]; then + python3 -c " +import re +def mix(c1, c2, f): + r = int(int(c1[1:3],16)*(1-f) + int(c2[1:3],16)*f) + g = int(int(c1[3:5],16)*(1-f) + int(c2[3:5],16)*f) + b = int(int(c1[5:7],16)*(1-f) + int(c2[5:7],16)*f) + return f'#{r:02x}{g:02x}{b:02x}' +with open('$KDEGLOBALS') as f: + content = f.read() +content = re.sub( + r'mix\(\s*(#[0-9A-Fa-f]{6})\s*,\s*(#[0-9A-Fa-f]{6})\s*,\s*([0-9.]+)\s*\)', + lambda m: mix(m.group(1), m.group(2), float(m.group(3))), + content +) +content = re.sub( + r'#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})', + lambda m: f'{int(m.group(1),16)},{int(m.group(2),16)},{int(m.group(3),16)}', + content +) +with open('$KDEGLOBALS', 'w') as f: + f.write(content) +" +fi + +# Resolve mix() in GTK CSS / gtkrc files +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 [ -f "$css" ] || continue python3 -c " import re @@ -29,35 +67,48 @@ done for conf in ~/.config/qt5ct/colors/wallust.conf ~/.config/qt6ct/colors/wallust.conf; do [ -f "$conf" ] || continue - # Convert #RRGGBB to #ffRRGGBB - sed -i 's/#\([0-9A-Fa-f]\{6\}\)/#ff\1/g' "$conf" + # Convert #RRGGBB to #ffRRGGBB (strip any existing ff first to avoid double-prefix) + sed -i 's/#ff\([0-9A-Fa-f]\{6\}\)/#\1/g; s/#\([0-9A-Fa-f]\{6\}\)/#ff\1/g' "$conf" - # Extract background (pos 4) and color1 (pos 1) from active_colors + # Extract foreground (pos 0), color1 (pos 1), background (pos 4), color4 (pos 12) IFS=',' read -ra COLS <<< "$(grep '^active_colors=' "$conf" | cut -d'=' -f2)" - BG="${COLS[4]// /}" # Dark role = background - C1="${COLS[1]// /}" # Button role = color1 + FG="${COLS[0]// /}" + C1="${COLS[1]// /}" + BG="${COLS[4]// /}" + C4="${COLS[12]// /}" - BG="${BG/#\#ff/}" + FG="${FG/#\#ff/}" C1="${C1/#\#ff/}" + BG="${BG/#\#ff/}" + C4="${C4/#\#ff/}" - # Compute mix(bg, c1, ratio) for surface colors - SURFACE=$(python3 -c " -bg='$BG'; c1='$C1' -for f in [0.35, 0.45]: - r=int(int(bg[0:2],16)*(1-f)+int(c1[0:2],16)*f) - g=int(int(bg[2:4],16)*(1-f)+int(c1[2:4],16)*f) - b=int(int(bg[4:6],16)*(1-f)+int(c1[4:6],16)*f) - print(f'{r:02X}{g:02X}{b:02X}') + # Compute mixed colors: + # surface = mix(bg, c1, 0.35) - window/base + # button = mix(bg, c1, 0.45) - button bg + # accent = mix(c4, fg, 0.3) - lightened selection + COMPUTED=$(python3 -c " +def m(a, b, f): + r = int(int(a[0:2],16)*(1-f) + int(b[0:2],16)*f) + g = int(int(a[2:4],16)*(1-f) + int(b[2:4],16)*f) + bl = int(int(a[4:6],16)*(1-f) + int(b[4:6],16)*f) + return f'{r:02X}{g:02X}{bl:02X}' +print(m('$BG', '$C1', 0.35)) +print(m('$BG', '$C1', 0.45)) +print(m('$C4', '$FG', 0.3)) ") - MIXED=$(echo "$SURFACE" | head -1) - MIXED_BTN=$(echo "$SURFACE" | tail -1) + MIXED=$(echo "$COMPUTED" | sed -n '1p') + MIXED_BTN=$(echo "$COMPUTED" | sed -n '2p') + MIXED_ACCENT=$(echo "$COMPUTED" | sed -n '3p') # Replace surface roles: Base(9), Window(10), AlternateBase(16), ToolTipBase(17) with MIXED # Replace Button(1) with MIXED_BTN + # Replace Highlight(12) and pos 20 with MIXED_ACCENT python3 -c " -import re -mixed, mixed_btn = '#ff$MIXED', '#ff$MIXED_BTN' +mixed = '#ff$MIXED' +mixed_btn = '#ff$MIXED_BTN' +mixed_accent = '#ff$MIXED_ACCENT' c1 = '#ff$C1' +c4 = '#ff$C4' with open('$conf') as f: lines = f.readlines() out = [] for line in lines: @@ -70,6 +121,9 @@ for line in lines: cols[i] = mixed if 1 < len(cols) and cols[1] == c1: cols[1] = mixed_btn + for i in [12, 20]: + if i < len(cols) and cols[i] == c4: + cols[i] = mixed_accent out.append(key + '=' + ', '.join(cols) + '\n') with open('$conf', 'w') as f: f.writelines(out) " diff --git a/.config/wallust/templates/gtk4.css b/.config/wallust/templates/gtk4.css index 6b3a113..cfa1b18 100644 --- a/.config/wallust/templates/gtk4.css +++ b/.config/wallust/templates/gtk4.css @@ -1,11 +1,11 @@ /* Generated by wallust */ -@define-color accent_bg_color {{color4}}; +@define-color accent_bg_color mix({{color4}}, {{foreground}}, 0.3); @define-color accent_fg_color {{color15}}; -@define-color accent_color {{color4}}; +@define-color accent_color mix({{color4}}, {{foreground}}, 0.3); -@define-color destructive_bg_color {{color1}}; +@define-color destructive_bg_color mix({{color1}}, {{foreground}}, 0.3); @define-color destructive_fg_color {{color15}}; -@define-color destructive_color {{color1}}; +@define-color destructive_color mix({{color1}}, {{foreground}}, 0.3); @define-color success_bg_color {{color2}}; @define-color success_fg_color {{color15}}; @@ -15,9 +15,9 @@ @define-color warning_fg_color {{background}}; @define-color warning_color {{color3}}; -@define-color error_bg_color {{color1}}; +@define-color error_bg_color mix({{color1}}, {{foreground}}, 0.3); @define-color error_fg_color {{color15}}; -@define-color error_color {{color1}}; +@define-color error_color mix({{color1}}, {{foreground}}, 0.3); @define-color window_bg_color mix({{background}}, {{color1}}, 0.35); @define-color window_fg_color {{foreground}}; @@ -76,22 +76,265 @@ popover contents { color: {{foreground}}; } +popover modelbutton:hover, +popover modelbutton:focus, +popover .menuitem:hover, +modelbutton:hover { + background-color: alpha({{foreground}}, 0.1); + color: {{foreground}}; +} + +popover modelbutton:active, +modelbutton:active { + background-color: alpha({{foreground}}, 0.15); +} + +.osd, +.toolbar, +box.toolbar, +.background.osd, +.flat-style-toolbar { + background-color: mix({{background}}, {{color1}}, 0.4); + color: {{foreground}}; + border-color: mix({{background}}, {{color1}}, 0.5); +} + +notebook header, +notebook tab, +notebook tabs, +viewswitcher, +viewswitcher button, +stackswitcher, +stackswitcher button, +.stack-switcher button, +columnview header, +columnview header button, +treeview.view header button, +header.view { + background-color: mix({{background}}, {{color1}}, 0.4); + background-image: none; + color: {{foreground}}; + border-color: mix({{background}}, {{color1}}, 0.5); + box-shadow: none; +} + +stackswitcher button:checked, +viewswitcher button:checked, +.stack-switcher button:checked { + background-color: mix({{color4}}, {{foreground}}, 0.3); + color: {{color15}}; +} + +notebook tab:checked { + background-color: mix({{background}}, {{color1}}, 0.7); + color: {{foreground}}; + box-shadow: inset 0 -3px 0 0 mix({{color4}}, {{foreground}}, 0.3); +} + +notebook tab:hover:not(:checked) { + background-color: mix({{background}}, {{color1}}, 0.55); +} + +.colorsetter:checked, +button.colorsetter:checked, +togglebutton.colorsetter:checked { + background-color: @colorsetter_color; + background-image: + linear-gradient(45deg, #0f0f0f55 25%, transparent 25%, transparent 75%, #0f0f0f55 75%, #0f0f0f55), + linear-gradient(45deg, #0f0f0f55 25%, transparent 25%, transparent 75%, #0f0f0f55 75%, #0f0f0f55); + color: @colorsetter_fg_color; + box-shadow: inset 0 -3px 0 0 @colorsetter_fg_color; +} + row:selected { - background-color: {{color4}}; + background-color: mix({{color4}}, {{foreground}}, 0.3); + color: {{color15}}; +} + +button.suggested-action, +.dialog-action-area button.suggested-action, +dialog button.suggested-action { + background-color: mix({{color4}}, {{foreground}}, 0.3); + background-image: none; color: {{color15}}; + box-shadow: none; + border: none; } -button.suggested-action { - background-color: {{color4}}; +button.destructive-action, +.dialog-action-area button.destructive-action, +dialog button.destructive-action { + background-color: mix({{color1}}, {{foreground}}, 0.3); + background-image: none; color: {{color15}}; + box-shadow: none; + border: none; } -button.destructive-action { - background-color: {{color1}}; +dialog button, +.dialog-action-area button, +messagedialog button { + background-color: mix({{background}}, {{color1}}, 0.45); + background-image: none; + color: {{foreground}}; + border-color: mix({{background}}, {{color1}}, 0.55); + box-shadow: none; +} + +dialog button.suggested-action, +.dialog-action-area button.suggested-action, +messagedialog button.suggested-action { + background-color: mix({{color4}}, {{foreground}}, 0.3); color: {{color15}}; } -entry { +dialog button.destructive-action, +.dialog-action-area button.destructive-action, +messagedialog button.destructive-action { + background-color: mix({{color1}}, {{foreground}}, 0.3); + color: {{color15}}; +} + +entry, +entry text, +spinbutton, +spinbutton entry, +spinbutton text, +combobox, +combobox button, +combobox entry, +dropdown, +dropdown button, +dropdown > button, +fontbutton, +fontbutton button, +filechooserbutton, +filechooserbutton button { background-color: mix({{background}}, {{color1}}, 0.3); + background-image: none; color: {{foreground}}; + border-color: mix({{background}}, {{color1}}, 0.5); + box-shadow: none; +} + +headerbar button, +headerbar button.flat, +windowhandle button, +windowhandle button.flat, +.toolbar button.flat, +.titlebar button, +.titlebar button.flat, +pathbar button, +pathbar button.flat, +button.image-button, +button.flat { + background-color: transparent; + background-image: none; + box-shadow: none; + border: none; + outline: none; + color: {{foreground}}; +} + +headerbar button.flat:hover, +windowhandle button.flat:hover, +.toolbar button.flat:hover, +.titlebar button.flat:hover, +.titlebar button:hover, +pathbar button:hover, +button.image-button:hover, +button.flat:hover { + background-color: alpha({{foreground}}, 0.12); + box-shadow: none; +} + +button:checked, +button.flat:checked, +button.toggle:checked, +togglebutton:checked, +headerbar button:checked, +windowhandle button:checked, +.toolbar button:checked { + background-color: mix({{color4}}, {{foreground}}, 0.3); + background-image: none; + color: {{color15}}; + box-shadow: none; + border: none; + outline: none; +} + +button:not(.color):not(.colorsetter):not(.flat):not(.image-button):not(.suggested-action):not(.destructive-action):not(:checked) { + background-color: mix({{background}}, {{color1}}, 0.45); + background-image: none; + color: {{foreground}}; + border-color: mix({{background}}, {{color1}}, 0.55); + box-shadow: none; +} + +button:not(.color):not(.colorsetter):not(.flat):not(.image-button):not(.suggested-action):not(.destructive-action):not(:checked):hover { + background-color: mix({{background}}, {{color1}}, 0.55); +} + +checkbutton check, +checkbutton radio, +check, +radio { + background-color: mix({{background}}, {{color1}}, 0.4); + background-image: none; + border-color: mix({{background}}, {{color1}}, 0.6); + color: {{foreground}}; +} + +checkbutton check:checked, +checkbutton radio:checked, +check:checked, +radio:checked, +checkbutton check:indeterminate, +check:indeterminate { + background-color: mix({{color4}}, {{foreground}}, 0.3); + background-image: none; + color: {{color15}}; + border-color: mix({{color4}}, {{foreground}}, 0.3); +} + +switch { + background-color: mix({{background}}, {{color1}}, 0.4); + background-image: none; +} + +switch:checked { + background-color: mix({{color4}}, {{foreground}}, 0.3); + background-image: none; +} + +switch slider { + background-color: {{foreground}}; + background-image: none; + border-color: mix({{background}}, {{color1}}, 0.5); +} + +scale trough { + background-color: mix({{background}}, {{color1}}, 0.4); + background-image: none; +} + +scale highlight { + background-color: mix({{color4}}, {{foreground}}, 0.3); + background-image: none; +} + +scale slider { + background-color: {{foreground}}; + background-image: none; + border-color: mix({{background}}, {{color1}}, 0.5); +} + +progressbar trough { + background-color: mix({{background}}, {{color1}}, 0.4); + background-image: none; +} + +progressbar progress { + background-color: mix({{color4}}, {{foreground}}, 0.3); + background-image: none; }