qutebrowser profile manager

make desktop file application name configurable

+5
CHANGELOG.md
··· 1 + # 2.1 2 + - `config.toml` supports `application_name` for generated XDG desktop files 3 + - defaults to `{profile_name} (qutebrowser profile)`, you may want just `{profile_name}` 4 + - `qbpm desktop` can be used to replace existing desktop files 5 + 1 6 # 2.0 2 7 ## config 3 8 qbpm now reads configuration options from `$XDG_CONFIG_HOME/qbpm/config.toml`!
+1
src/qbpm/config.py
··· 20 20 qutebrowser_config_directory: Path | None = None 21 21 profile_directory: Path = field(default_factory=paths.default_profile_dir) 22 22 generate_desktop_file: bool = platform.system() == "Linux" 23 + application_name: str = "{profile_name} (qutebrowser profile)" 23 24 desktop_file_directory: Path = field( 24 25 default_factory=paths.default_qbpm_application_dir 25 26 )
+5 -1
src/qbpm/config.toml
··· 17 17 # location of the qutebrowser config to inherit from 18 18 # qutebrowser_config_directory = "~/.config/qutebrowser" 19 19 20 - # when creating a profile also generate an XDG desktop entry that launches the profile 20 + # when creating a profile also generate an XDG desktop file that launches the profile 21 21 # defaults to true on linux 22 22 # generate_desktop_file = false 23 23 # desktop_file_directory = "~/.local/share/applications/qbpm" 24 + 25 + # application name in XDG desktop file (replace existing with `qbpm desktop PROFILE_NAME`) 26 + # supported placeholders: {profile_name} 27 + # application_name = "{profile_name} (qutebrowser profile)" 24 28 25 29 # profile selection menu for `qbpm choose` 26 30 # when not set, qbpm will try to find a menu program on your $PATH
+5 -2
src/qbpm/desktop.py
··· 18 18 ] 19 19 20 20 21 - def create_desktop_file(profile: Profile, application_dir: Path) -> None: 21 + def create_desktop_file( 22 + profile: Profile, application_dir: Path, application_name: str 23 + ) -> None: 24 + application_name = application_name.format(profile_name=profile.name) 22 25 text = textwrap.dedent(f"""\ 23 26 [Desktop Entry] 24 - Name={profile.name} (qutebrowser profile) 27 + Name={application_name} 25 28 StartupWMClass=qutebrowser 26 29 GenericName={profile.name} 27 30 Icon=qutebrowser
+3 -1
src/qbpm/main.py
··· 284 284 profile = Profile(profile_name, config.profile_directory) 285 285 exists = profiles.check(profile) 286 286 if exists: 287 - create_desktop_file(profile, config.desktop_file_directory) 287 + create_desktop_file( 288 + profile, config.desktop_file_directory, config.application_name 289 + ) 288 290 exit_with(exists) 289 291 290 292
+3 -1
src/qbpm/profiles.py
··· 123 123 if config.symlink_autoconfig: 124 124 link_autoconfig(profile, qb_config_dir, overwrite) 125 125 if config.generate_desktop_file: 126 - create_desktop_file(profile, config.desktop_file_directory) 126 + create_desktop_file( 127 + profile, config.desktop_file_directory, config.application_name 128 + ) 127 129 print(profile.root) 128 130 return True 129 131 return False
+10 -1
tests/test_desktop.py
··· 1 1 from pathlib import Path 2 2 3 3 from qbpm import Profile 4 + from qbpm.config import Config 4 5 from qbpm.desktop import create_desktop_file 5 6 6 7 TEST_DIR = Path(__file__).resolve().parent ··· 10 11 application_path = tmp_path / "applications" 11 12 application_path.mkdir() 12 13 profile = Profile("test", tmp_path) 13 - create_desktop_file(profile, application_path) 14 + create_desktop_file(profile, application_path, Config.load(None).application_name) 14 15 assert (application_path / "test.desktop").read_text() == ( 15 16 TEST_DIR / "test.desktop" 16 17 ).read_text().replace("{qbpm}", " ".join(profile.cmdline())) 18 + 19 + 20 + def test_custom_name(tmp_path: Path): 21 + application_path = tmp_path / "applications" 22 + application_path.mkdir() 23 + profile = Profile("test", tmp_path) 24 + create_desktop_file(profile, application_path, "test") 25 + assert "Name=test\n" in (application_path / "test.desktop").read_text()