From 99b4d9f2fef5aca39cdedf033cfb3cb3e48c7ac1 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 28 Mar 2022 22:28:59 -0400 Subject: [PATCH] Apply black formatter to python files --- .config/i3/compact_workspace_numbers.py | 3 +-- .config/i3/pass_typer.py | 14 ++++++++------ .config/i3/rename_workspace.py | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.config/i3/compact_workspace_numbers.py b/.config/i3/compact_workspace_numbers.py index 5dd4b32..fb825eb 100755 --- a/.config/i3/compact_workspace_numbers.py +++ b/.config/i3/compact_workspace_numbers.py @@ -8,8 +8,7 @@ i3 = i3ipc.Connection() workspaces = i3.get_workspaces() for tens, workspace_group in groupby(workspaces, lambda ws: ws.num // 10): - workspaces = [ws for ws in workspace_group - if ws.num != -1 and ws.num % 10 != 0] + workspaces = [ws for ws in workspace_group if ws.num != -1 and ws.num % 10 != 0] workspaces.sort(key=lambda ws: ws.num) for num, ws in enumerate(workspaces, 1): diff --git a/.config/i3/pass_typer.py b/.config/i3/pass_typer.py index 4450c05..89d9363 100755 --- a/.config/i3/pass_typer.py +++ b/.config/i3/pass_typer.py @@ -17,11 +17,11 @@ cmd = partial(subprocess.run, capture_output=True, encoding="ascii") def alias(server_name): match server_name.rpartition("@"): case [_, _, "salt"]: - return 'cms/*cms-net-svcs' + return "cms/*cms-net-svcs" case [_, _, ("iPad1" | "iPad2" | "iPad3")]: - return 'cms/*ipads' + return "cms/*ipads" case [_, _, ("octopi-taz-6" | "octopi-lulzbot-mini")]: - return 'cms/*octopi' + return "cms/*octopi" case _: return server_name @@ -43,14 +43,16 @@ def get_password(password_name: str) -> None: def select_and_type(server_name: str) -> None: - files = chain(PASSWORD_STORE.glob(f"servers/**/{server_name}.gpg"), - PASSWORD_STORE.glob(f"servers/**/*@{server_name}.gpg")) + files = chain( + PASSWORD_STORE.glob(f"servers/**/{server_name}.gpg"), + PASSWORD_STORE.glob(f"servers/**/*@{server_name}.gpg"), + ) file_list = {str(f.relative_to(PASSWORD_STORE).with_suffix("")) for f in files} selected = rofi_select(file_list) password = get_password(selected) - subprocess.run(["xdotool", "type", password + '\n']) + subprocess.run(["xdotool", "type", password + "\n"]) window_name = cmd(["xdotool", "getactivewindow", "getwindowname"]).stdout.strip() diff --git a/.config/i3/rename_workspace.py b/.config/i3/rename_workspace.py index f40446c..a862c9d 100755 --- a/.config/i3/rename_workspace.py +++ b/.config/i3/rename_workspace.py @@ -10,15 +10,22 @@ workspaces = i3.get_workspaces() focused = [ws for ws in workspaces if ws.focused] if len(focused) == 1: # I have no idea when it wouldn't be, but whatever - inputName = subprocess.check_output( - ['rofi', '-dmenu', '-l', '0', '-p', 'New name']).decode().strip() + inputName = ( + subprocess.check_output(["rofi", "-dmenu", "-l", "0", "-p", "New name"]) + .decode() + .strip() + ) oldNum = str(focused[0].num) # basically either take raw input, allow clearing text part of a name, # or add input to current number # TODO: handle renaming of workspace without number to another name without a number - newName = inputName if re.match('^[0-9]+:', inputName) is not None else \ - oldNum if inputName == "" else \ - oldNum + ':' + inputName + newName = ( + inputName + if re.match("^[0-9]+:", inputName) is not None + else oldNum + if inputName == "" + else oldNum + ":" + inputName + ) i3.command(f"rename workspace to {newName}")