File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
import platform
2
+ import shlex
2
3
import sys
3
4
from collections .abc import Iterator
4
5
from dataclasses import dataclass , replace
@@ -57,13 +58,13 @@ def find_menu(menu: str | None) -> Dmenu | ApplescriptMenu | None:
57
58
58
59
59
60
def custom_dmenu (command : str ) -> Dmenu :
60
- split = command .split (" " , maxsplit = 1 )
61
+ split = shlex .split (command )
61
62
if len (split ) == 1 or not split [1 ]:
62
63
name = Path (command ).name
63
64
for menu in supported_menus ():
64
65
if isinstance (menu , Dmenu ) and menu .name == name :
65
66
return menu if menu .name == command else replace (menu , name = command )
66
- return Dmenu (split [0 ], split [1 ] if len ( split ) == 2 else "" )
67
+ return Dmenu (split [0 ], " " . join ( split [1 ::]) )
67
68
68
69
69
70
def supported_menus () -> Iterator [Dmenu | ApplescriptMenu ]:
Original file line number Diff line number Diff line change @@ -64,6 +64,15 @@ def test_invalid_custom_menu():
64
64
assert find_menu ("fake_command" ) is None
65
65
66
66
67
+ def test_custom_menu_space_in_name (tmp_path : Path ):
68
+ write_script (tmp_path / "bin" , name = "my menu" )
69
+ environ ["PATH" ] = str (tmp_path / "bin" )
70
+ environ ["DISPLAY" ] = ":1"
71
+ dmenu = find_menu ("my\\ menu" )
72
+ assert dmenu is not None
73
+ assert dmenu .installed ()
74
+
75
+
67
76
def test_custom_menu_default_args (tmp_path : Path ):
68
77
menu = write_script (tmp_path / "bin" , name = "rofi" )
69
78
environ ["PATH" ] = str (tmp_path / "bin" )
You can’t perform that action at this time.
0 commit comments