qutebrowser profile manager

add fzf as a menu choice

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