diff --git a/buttond.py b/buttond.py index 17f5f82..692feb4 100755 --- a/buttond.py +++ b/buttond.py @@ -25,12 +25,14 @@ from signal import pause # Device.pin_factory = MockFactory() +# callback intermidiary to sanitize user input def _activate(macro): if macro is None: return macro = macro.strip('\"').upper() if macro is "": return + # pass macro to baconscript print("doing macro ", macro) comment(macro) @@ -63,12 +65,15 @@ for b in config.get('button', 'names').split(','): print('Error configuring button', b, e) continue + +# clear temp variables off the stack try: - # clear temp variables off the stack del pin, closed, opened except (NameError): pass + +# when run directly, sleep until button signal or KeyboardInterrupt if __name__ == '__main__': try: pause()