fix: regenerate gtk.css/vicinae.toml on every theme switch - #56
Open
Krixam wants to merge 1 commit into
Open
Conversation
theme-set runs each theme-set.d/*.sh script twice: once through the theme-set wrapper (which exports the color vars) and once again directly by omarchy-hook's own loop, without those vars set. 10-gtk.sh and 10-vicinae.sh guarded against that double-run by only generating output "if [ ! -f "$output_file" ]" (skip if it already exists). That avoided the var-less second pass clobbering the first, but as a side effect also permanently blocked regeneration on every subsequent theme switch, since the output path is a fixed, reused location. If either script's first-ever run happened before real color vars were available (e.g. before colors.toml existed at its current Omarchy 3.3+ path), it baked in empty colors and never updated again for any theme afterwards - producing invalid CSS like "@define-color window_bg_color #;", which makes GTK paint no background at all, so GTK4/libadwaita apps (Nautilus, GNOME Disks, etc.) render fully transparent. Guard on `-n "$primary_background"` instead: regenerate whenever real color data is present (every proper pass, every theme switch), and no-op on the var-less second pass, leaving the good output from the first pass untouched. Verified by switching themes back and forth and confirming gtk.css and vicinae.toml pick up the new theme's colors every time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
omarchy-hookruns every script in a hook's.d/directory twice:once through the
theme-setwrapper (which exports the color vars like$primary_background,$normal_red, etc.), and once again directly byits own loop, without those vars set (see
/usr/share/omarchy/bin/omarchy-hook).10-gtk.shand10-vicinae.shguarded against that double-run by onlywriting their output
if [ ! -f "$output_file" ](skip if it alreadyexists). That avoids the var-less second pass clobbering the good first
pass, but as a side effect it also permanently blocks regeneration on
every subsequent theme switch, since the output path
(
~/.config/omarchy/current/theme/...) is fixed and reused across themes.Worse: if either script's very first run ever happened before real color
vars were available (e.g. before
colors.tomlexisted at its currentOmarchy 3.3+ path), it bakes in empty colors permanently — producing
invalid CSS like
@define-color window_bg_color #;. GTK treats that as"no background", so GTK4/libadwaita apps (Nautilus, GNOME Disks, etc.)
render fully transparent, showing the desktop through them — and no
later theme switch ever fixes it, because the file already exists.
Fix
Guard on
[ -n "$primary_background" ]instead of file existence:regenerate whenever real color data is actually present (every proper
pass, every theme switch), and no-op on the var-less second pass so it
leaves the good output from the first pass alone.
Testing
Reproduced on a live Omarchy install where
gtk.css/vicinae.tomlhadbeen stuck with empty colors since a very early hook run, surviving many
theme switches. Applied this fix, then switched themes back and forth
(e.g. Nord → Ristretto) and confirmed
gtk.cssandvicinae.tomlcorrectly picked up each theme's real colors every time, with no
regression from the double-invocation.