diff --git a/.config/i3/pass_typer.py b/.config/i3/pass_typer.py index ec2e818..4330c42 100755 --- a/.config/i3/pass_typer.py +++ b/.config/i3/pass_typer.py @@ -11,13 +11,19 @@ PASSWORD_STORE = PosixPath( os.environ.get("PASSWORD_STORE_DIR", PosixPath("~/.password-store").expanduser()) ) -ALIASES = { - "salt": "cms-net-svcs", -} - cmd = partial(subprocess.run, capture_output=True, encoding="ascii") +def alias(server_name): + match server_name: + case "salt": + return "cms-net-svcs" + case "iPad1" | "iPad2" | "iPad3": + return "ipads" + case _: + return server_name + + def notify(summary: str, body: str) -> None: subprocess.run(["notify-send", summary, body]) @@ -49,8 +55,7 @@ window_name = cmd(["xdotool", "getactivewindow", "getwindowname"]).stdout.strip( ssh_match = re.search(":(mosh|ssh) (?P.*)", window_name) if ssh_match: - raw_server_name = ssh_match.group("server") - server_name = ALIASES.get(raw_server_name, raw_server_name) + server_name = alias(ssh_match.group("server")) notify(f"Matched server '{server_name}'", f"Window name: {window_name}")