diff --git a/.gitignore b/.gitignore index 78fd378..ac5a70f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ **/*.sw* +**/__pycache__ diff --git a/src/main.py b/src/main.py index 52da529..4f2331e 100644 --- a/src/main.py +++ b/src/main.py @@ -2,9 +2,16 @@ import reader import writer import bucket +import argparse + def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--stdin", default=False, action="store_true") + args = ap.parse_args() + r = reader.Reader(reader.StdinReader()) - r = reader.Reader(reader.RandomReader()) + if not args.stdin: + r = reader.Reader(reader.RandomReader()) w = writer.Writer(writer.MultiWriter( #writer.StdoutWriter(), writer.PyAutoGUIWriter(), diff --git a/src/writer.py b/src/writer.py index 6eee525..00a423a 100644 --- a/src/writer.py +++ b/src/writer.py @@ -30,8 +30,14 @@ class StdoutWriter: print(v) class PyAutoGUIWriter: + translation = { + "a": "f24", + "b": "f23", + } + def __init__(self): self.keys_down = set() + print(json.dumps(PyAutoGUIWriter.translation, indent=" ")) def write(self, v): to_push = set() @@ -48,10 +54,9 @@ class PyAutoGUIWriter: # https://pyautogui.readthedocs.io/en/latest/keyboard.html#keyboard-keys def translate(self, v): - if v == "a": - return "f24" - elif v == "b": - return "f23" + result = PyAutoGUIWriter.translation.get(v, None) + if result: + return result def push(self, k): self.keys_down.add(k)