File tree Expand file tree Collapse file tree 7 files changed +32
-6
lines changed Expand file tree Collapse file tree 7 files changed +32
-6
lines changed Original file line number Diff line number Diff line change 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+
16# 2.0
27## config
38qbpm now reads configuration options from ` $XDG_CONFIG_HOME/qbpm/config.toml ` !
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class Config:
2020 qutebrowser_config_directory : Path | None = None
2121 profile_directory : Path = field (default_factory = paths .default_profile_dir )
2222 generate_desktop_file : bool = platform .system () == "Linux"
23+ application_name : str = "{profile_name} (qutebrowser profile)"
2324 desktop_file_directory : Path = field (
2425 default_factory = paths .default_qbpm_application_dir
2526 )
Original file line number Diff line number Diff line change @@ -17,11 +17,15 @@ config.load_autoconfig()
1717# location of the qutebrowser config to inherit from
1818# qutebrowser_config_directory = "~/.config/qutebrowser"
1919
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
2121# defaults to true on linux
2222# generate_desktop_file = false
2323# desktop_file_directory = "~/.local/share/applications/qbpm"
2424
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)"
28+
2529# profile selection menu for `qbpm choose`
2630# when not set, qbpm will try to find a menu program on your $PATH
2731# run `qbpm choose --help` for a list of known menu programs
Original file line number Diff line number Diff line change 1818]
1919
2020
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 )
2225 text = textwrap .dedent (f"""\
2326 [Desktop Entry]
24- Name={ profile . name } (qutebrowser profile)
27+ Name={ application_name }
2528 StartupWMClass=qutebrowser
2629 GenericName={ profile .name }
2730 Icon=qutebrowser
Original file line number Diff line number Diff line change @@ -284,7 +284,9 @@ def desktop(
284284 profile = Profile (profile_name , config .profile_directory )
285285 exists = profiles .check (profile )
286286 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+ )
288290 exit_with (exists )
289291
290292
Original file line number Diff line number Diff line change @@ -123,7 +123,9 @@ def new_profile(
123123 if config .symlink_autoconfig :
124124 link_autoconfig (profile , qb_config_dir , overwrite )
125125 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+ )
127129 print (profile .root )
128130 return True
129131 return False
Original file line number Diff line number Diff line change 11from pathlib import Path
22
33from qbpm import Profile
4+ from qbpm .config import Config
45from qbpm .desktop import create_desktop_file
56
67TEST_DIR = Path (__file__ ).resolve ().parent
@@ -10,7 +11,15 @@ def test_create_desktop_file(tmp_path: Path):
1011 application_path = tmp_path / "applications"
1112 application_path .mkdir ()
1213 profile = Profile ("test" , tmp_path )
13- create_desktop_file (profile , application_path )
14+ create_desktop_file (profile , application_path , Config . load ( None ). application_name )
1415 assert (application_path / "test.desktop" ).read_text () == (
1516 TEST_DIR / "test.desktop"
1617 ).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 ()
You can’t perform that action at this time.
0 commit comments