Skip to content

Fall back to built-in default config - #213

Open
giri256 wants to merge 1 commit into
abba23:mainfrom
giri256:builtin-default-config
Open

giri256 wants to merge 1 commit into
abba23:mainfrom
giri256:builtin-default-config

Conversation

@giri256

@giri256 giri256 commented Oct 9, 2026

Copy link
Copy Markdown

Right now, if no config file is found, the library panics with Failed to find config. and Spotify crashes on startup. This comes up every now and then, mostly with Flatpak, where the config has to go into ~/.var/app/com.spotify.Client/config/ instead of ~/.config/ (see #185).

With this change, config.toml from the repository is embedded at build time with include_str! and used when no config file exists. A config file in /etc/spotify-adblock/ or $XDG_CONFIG_HOME/spotify-adblock/ still takes precedence. A config file that exists but can't be read or parsed still panics as before, so mistakes in a custom config don't go unnoticed.

I also updated the Configuration section in the README. It still mentioned the allowlist, which was removed in 45747b6.

Tested by hiding /etc/spotify-adblock with no user config present. The log shows No config found, using default config., ad URLs are blocked, and everything else goes through. With a user config present, that config is used.

If no config file is found, use the config.toml from the repository,
which is embedded at build time, instead of panicking. A config file in
any of the existing locations still takes precedence.

This mostly helps Flatpak users, where the config file ends up in a
different directory than expected and Spotify crashes on startup.
@giri256

giri256 commented Oct 9, 2026

Copy link
Copy Markdown
Author

One small follow-up, depending on which of this and #212 gets merged first: since config.toml is now compiled into the library, the Makefile should also rebuild when only config.toml changes. Otherwise the built-in fallback can end up older than the installed config. The installed config in /etc/spotify-adblock/ still takes precedence, so it only matters when that file is missing.

The fix is just adding config.toml to the build rule's dependencies:

$(BINARY_SOURCE): $(wildcard src/*.rs) Cargo.toml config.toml

I left it out of both PRs so they don't conflict with each other. Happy to add it to whichever one ends up merged second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant