qutebrowser profile manager

add fzf as a menu choice

+9 -10
+2 -4
qbpm/main.py
··· 89 89 90 90 choose = subparsers.add_parser( 91 91 "choose", 92 - help="choose profile using a dmenu-compatible launcher or an applescript dialog", 92 + help="interactively choose a profile to launch", 93 93 ) 94 94 menus = sorted(SUPPORTED_MENUS) 95 95 choose.add_argument( ··· 105 105 ) 106 106 choose.set_defaults(operation=operations.choose, passthrough=True) 107 107 108 - edit = subparsers.add_parser( 109 - "edit", help="edit a profile's config.py using $EDITOR" 110 - ) 108 + edit = subparsers.add_parser("edit", help="edit a profile's config.py") 111 109 edit.add_argument("profile_name", metavar="profile", help="profile to edit") 112 110 edit.set_defaults(operation=build_op(operations.edit)) 113 111
+4 -2
qbpm/operations.py
··· 11 11 12 12 from qbpm import profiles 13 13 from qbpm.profiles import Profile 14 - from qbpm.utils import SUPPORTED_MENUS, error, get_default_menu, user_data_dir 14 + from qbpm.utils import AUTO_MENUS, error, get_default_menu, user_data_dir 15 15 16 16 17 17 def from_session( ··· 88 88 def choose(args: argparse.Namespace) -> bool: 89 89 menu = args.menu or get_default_menu() 90 90 if not menu: 91 - error(f"No menu program found, please install one of: {SUPPORTED_MENUS}") 91 + error(f"No menu program found, please install one of: {AUTO_MENUS}") 92 92 return False 93 93 if menu == "applescript" and platform != "darwin": 94 94 error(f"Menu applescript cannot be used on a {platform} host") ··· 140 140 command = f"{menu} --dmenu {prompt}" 141 141 elif program in ["dmenu", "dmenu-wl"]: 142 142 command = f"{menu} {prompt}" 143 + elif program == "fzf": 144 + command = f"{menu} --prompt 'qutebrowser '" 143 145 exe = command.split(" ")[0] 144 146 if not shutil.which(exe): 145 147 error(f"command '{exe}' not found")
+3 -4
qbpm/utils.py
··· 8 8 9 9 from xdg import BaseDirectory # type: ignore 10 10 11 - SUPPORTED_MENUS = ["wofi", "rofi", "dmenu", "dmenu-wl", "applescript"] 11 + AUTO_MENUS = ["wofi", "rofi", "dmenu", "dmenu-wl"] 12 + SUPPORTED_MENUS = AUTO_MENUS + ["fzf", "applescript"] 12 13 13 14 14 15 def error(msg: str) -> None: ··· 37 38 def get_default_menu() -> Optional[str]: 38 39 if sys.platform == "darwin": 39 40 return "applescript" 40 - for menu_cmd in SUPPORTED_MENUS: 41 - if menu_cmd == "applescript": 42 - continue 41 + for menu_cmd in AUTO_MENUS: 43 42 if which(menu_cmd) is not None: 44 43 return menu_cmd 45 44 return None