File tree Expand file tree Collapse file tree 2 files changed +16
-18
lines changed
Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 1010
1111from . import profiles
1212from .profiles import Profile
13- from .utils import AUTO_MENUS , error , get_default_menu , user_data_dir
13+ from .utils import AUTO_MENUS , error , installed_menus , user_data_dir
1414
1515
1616def from_session (
@@ -85,7 +85,7 @@ def list_(args: argparse.Namespace) -> bool:
8585
8686
8787def choose (args : argparse .Namespace ) -> bool :
88- menu = args .menu or get_default_menu ( )
88+ menu = args .menu or next ( installed_menus () )
8989 if not menu :
9090 error (f"No menu program found, please install one of: { AUTO_MENUS } " )
9191 return False
@@ -137,9 +137,9 @@ def menu_command(
137137 command = f"{ menu } -dmenu -no-custom { prompt } -mesg { arg_string } "
138138 elif program == "wofi" :
139139 command = f"{ menu } --dmenu { prompt } "
140- elif program in [ "dmenu" , "dmenu-wl" ] :
140+ elif program . startswith ( "dmenu" ) :
141141 command = f"{ menu } { prompt } "
142- elif program == "fzf" :
142+ elif program . startswith ( "fzf" ) :
143143 command = f"{ menu } --prompt 'qutebrowser '"
144144 elif program == "fuzzel" :
145145 command = f"{ menu } -d"
Original file line number Diff line number Diff line change 11import platform
2+ from collections .abc import Generator
23from os import environ
34from pathlib import Path
45from shutil import which
@@ -36,23 +37,20 @@ def user_config_dir() -> Path:
3637 return Path (BaseDirectory .xdg_config_home ) / "qutebrowser"
3738
3839
39- def get_default_menu () -> Optional [str ]:
40+ def installed_menus () -> Generator [str , None , None ]:
4041 if platform .system () == "Darwin" :
41- return "applescript"
42+ yield "applescript"
4243 if environ .get ("WAYLAND_DISPLAY" ):
4344 for menu_cmd in WAYLAND_MENUS :
4445 if which (menu_cmd ) is not None :
45- return menu_cmd
46- elif environ .get ("DISPLAY" ):
46+ yield menu_cmd
47+ if environ .get ("DISPLAY" ):
4748 for menu_cmd in X11_MENUS :
4849 if which (menu_cmd ) is not None :
49- return menu_cmd
50- else :
51- # TODO can we detect whether we're in a term so we can run fzf?
52- error (
53- "Neither $DISPLAY nor $WAYLAND_DISPLAY are set,"
54- + " cannot launch a graphical menu."
55- + " Consider passing `--menu fzf`"
56- )
57- exit (1 )
58- return None
50+ yield menu_cmd
51+ if environ .get ("TMUX" ) and which ("fzf-tmux" ) is not None :
52+ yield "fzf-tmux"
53+ # if there's no display and fzf is installed we're probably(?) in a term
54+ if which ("fzf" ) is not None :
55+ print ("no graphical launchers found, trying fzf" , file = stderr )
56+ yield "fzf"
You can’t perform that action at this time.
0 commit comments