diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ea1145..bfb200c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -# next - - add `--help` flag to `qbpm config` +# 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 # ~2.1~ 2.2 - `config.toml` supports `application_name` for generated XDG desktop files diff --git a/pyproject.toml b/pyproject.toml index 97e42ed..25a03e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "qbpm" -version = "2.2" +version = "2.3" description = "qutebrowser profile manager" license = "GPL-3.0-or-later" license-files = ["LICENSE"] diff --git a/src/qbpm/profiles.py b/src/qbpm/profiles.py index 1316ace..26084a0 100644 --- a/src/qbpm/profiles.py +++ b/src/qbpm/profiles.py @@ -5,6 +5,7 @@ from . import Profile from .config import Config, find_qutebrowser_config_dir from .desktop import create_desktop_file from .log import error, info +from .paths import qutebrowser_data_dir MIME_TYPES = [ "text/html", @@ -76,6 +77,19 @@ def link_autoconfig( dest.symlink_to(source) +def link_dictionaries(profile: Profile, overwrite: bool) -> None: + if not hasattr(Path, "symlink_to"): + return + source = qutebrowser_data_dir() / "qtwebengine_dictionaries" + dest = profile.root / "data" / "qtwebengine_dictionaries" + dest.parent.mkdir(exist_ok=True) + if dest.resolve() == source.resolve(): + return + if overwrite and dest.exists(): + back_up(dest) + dest.symlink_to(source, target_is_directory=True) + + def back_up(dest: Path) -> None: backup = Path(str(dest) + ".bak") info(f"backing up existing {dest.name} to {backup}") @@ -126,6 +140,7 @@ def new_profile( create_desktop_file( profile, config.desktop_file_directory, config.application_name ) + link_dictionaries(profile, overwrite) print(profile.root) return True return False diff --git a/tests/test_profiles.py b/tests/test_profiles.py index cc10a61..244be73 100644 --- a/tests/test_profiles.py +++ b/tests/test_profiles.py @@ -21,8 +21,13 @@ def check_empty_profile(profile: Profile | None): def check_new_profile(profile: Profile): assert profile config_dir = profile.root / "config" - assert list(profile.root.iterdir()) == [config_dir] - assert list(config_dir.iterdir()) == [config_dir / "config.py"] + data_dir = profile.root / "data" + assert set(profile.root.iterdir()) == {config_dir, data_dir} + assert set(config_dir.iterdir()) == {config_dir / "config.py"} + dicts_dir = data_dir / "qtwebengine_dictionaries" + assert set(data_dir.iterdir()) == {dicts_dir} + assert dicts_dir.is_symlink() + assert dicts_dir.resolve().name == "qtwebengine_dictionaries" def test_set_profile(tmp_path: Path):