1
0
Fork 0

Compare commits

..

No commits in common. "308f3a6ece0353980ab8061b410e0d6b8b17adb9" and "b7674788a824a0e813754d227df1de101083c09a" have entirely different histories.

2 changed files with 18 additions and 30 deletions

View file

@ -1,13 +0,0 @@
#!/bin/bash
pip3 install python-lsp-server
ask_install() {
packages="$@"
read -p "Install $packages? [y/n] " -n 1 -r ; echo
[[ "$REPLY" = y ]] && pip3 install $packages
}
ask_install pyflakes
ask_install black python-lsp-black
ask_install mypy pylsp-mypy

View file

@ -28,8 +28,9 @@ import webbrowser
def load_config(config_path=None): def load_config(config_path=None):
if config_path is None: if config_path is None:
config_path = os.environ.get("ROFIBANGS_CONFIG_PATH") or os.path.expanduser( config_path = os.environ.get(
"~/.config/rofibangs.json" "ROFIBANGS_CONFIG_PATH",
os.path.expanduser("~/.config/rofibangs.json")
) )
try: try:
with open(config_path, "rt") as bangs_file: with open(config_path, "rt") as bangs_file:
@ -51,7 +52,7 @@ def run_rofi(config, input_text="", title="bang"):
[rofi_path, "-dmenu", "-p", title], [rofi_path, "-dmenu", "-p", title],
text=True, text=True,
capture_output=True, capture_output=True,
input=input_text, input=input_text
) )
output = completed_process.stdout output = completed_process.stdout
if not output: if not output:
@ -72,9 +73,12 @@ def open_bang(config, handle, query):
def main(): def main():
ap = argparse.ArgumentParser() ap = argparse.ArgumentParser()
ap.add_argument("-c", "--config", help="path to JSON config file") ap.add_argument(
ap.add_argument("-l", "--list", action="store_true", help="show available bangs") "-c", "--config", help="path to JSON config file"
ap.add_argument("-b", "--bang", help="launch with this bang already set") )
ap.add_argument(
"-l", "--list", action="store_true", help="show available bangs"
)
args = ap.parse_args() args = ap.parse_args()
config = load_config() config = load_config()
@ -85,19 +89,16 @@ def main():
list_bangs(config) list_bangs(config)
return return
if handle := args.bang: process_input = "\n".join(i["handle"] for i in config["bangs"]) + "\n"
output = run_rofi(config, input_text=process_input)
parts = output.split(maxsplit=1)
if len(parts) < 1:
exit("Bad Rofi output.")
if len(parts) == 1:
handle = parts[0]
query = run_rofi(config, title=handle) query = run_rofi(config, title=handle)
else: else:
process_input = "\n".join(i["handle"] for i in config["bangs"]) + "\n" handle, query = parts
output = run_rofi(config, input_text=process_input)
parts = output.split(maxsplit=1)
if len(parts) < 1:
exit("Bad Rofi output.")
if len(parts) == 1:
handle = parts[0]
query = run_rofi(config, title=handle)
else:
handle, query = parts
open_bang(config, handle, query) open_bang(config, handle, query)