diff --git a/CHANGELOG.md b/CHANGELOG.md index bfb200c..12dcbab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.4 + - `config_py_template` is no longer required to be set if `config.toml` exists + - if `config_py_template` is set to an empty string, no `config.py` will be generated + # 2.3 - new profiles will have a symlink to `$XDG_DATA_HOME/qutebrowser/qtwebengine_dictionaries` and thus have access to any spellchecking dictionaries have been installed for the main qutebrowser profile - `qbpm config` now has a `--help` flag diff --git a/src/qbpm/config.py b/src/qbpm/config.py index de3d14e..9b36933 100644 --- a/src/qbpm/config.py +++ b/src/qbpm/config.py @@ -15,7 +15,13 @@ DEFAULT_CONFIG_FILE = Path(__file__).parent / "config.toml" @dataclass(kw_only=True) class Config: - config_py_template: str | None = None + config_py_template: str = """ +config.source(r'{source_config_py}') + +c.window.title_format += ' ({profile_name})' + +config.load_autoconfig() +""" symlink_autoconfig: bool = False qutebrowser_config_directory: Path | None = None profile_directory: Path = field(default_factory=paths.default_profile_dir) diff --git a/src/qbpm/profiles.py b/src/qbpm/profiles.py index 26084a0..3fbb530 100644 --- a/src/qbpm/profiles.py +++ b/src/qbpm/profiles.py @@ -127,13 +127,11 @@ def new_profile( ) if not qb_config_dir: return False - if not config.config_py_template: - error("no value for config_py_template in config.toml") - return False if create_profile(profile, overwrite): - create_config( - profile, qb_config_dir, config.config_py_template, home_page, overwrite - ) + if config.config_py_template: + create_config( + profile, qb_config_dir, config.config_py_template, home_page, overwrite + ) if config.symlink_autoconfig: link_autoconfig(profile, qb_config_dir, overwrite) if config.generate_desktop_file: diff --git a/tests/test_main.py b/tests/test_main.py index e3d543b..9a38d13 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -72,7 +72,7 @@ def test_from_session_name(tmp_path: Path): assert (tmp_path / "test/data/sessions/_autosave.yml").read_text() == ("windows:\n") -def test_config_file(tmp_path: Path): +def test_custom_template(tmp_path: Path): environ["QBPM_PROFILE_DIR"] = str(tmp_path) (tmp_path / "config.py").touch() config_file = tmp_path / "config.toml" @@ -83,6 +83,35 @@ def test_config_file(tmp_path: Path): assert "# Custom template test" in profile_config.read_text() +def test_no_template(tmp_path: Path): + environ["QBPM_PROFILE_DIR"] = str(tmp_path) + (tmp_path / "config.py").touch() + config_file = tmp_path / "config.toml" + config_file.write_text("application_name = 'qbpm'") + result = run("-c", str(config_file), "new", "test") + assert result.exit_code == 0 + profile_config = tmp_path / "test" / "config" / "config.py" + assert str(tmp_path) in profile_config.read_text() + + +def test_autoconfig_only(tmp_path: Path): + environ["QBPM_PROFILE_DIR"] = str(tmp_path) + (tmp_path / "config.py").touch() + config_file = tmp_path / "config.toml" + config_file.write_text(""" + config_py_template = '' + symlink_autoconfig = true + """) + autoconfig_file = tmp_path / "autoconfig.yml" + autoconfig_file.touch() + result = run("-c", str(config_file), "new", "test") + assert result.exit_code == 0 + profile_config = tmp_path / "test" / "config" / "config.py" + profile_autoconfig = tmp_path / "test" / "config" / "autoconfig.yml" + assert not profile_config.exists() + assert profile_autoconfig.readlink() == autoconfig_file + + def test_bad_config_file(): result = run("-c", "/nonexistent/config.toml", "list") assert result.exit_code == 1