_cli.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. rescriptoon
  3. Copyright (C) 2018-2019 Fabian Peter Hammerle <fabian@hammerle.me>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. """
  15. import argparse
  16. import logging
  17. from Xlib import X, XK
  18. import rescriptoon
  19. _DEFAULT_TOGGLE_KEYSYM_NAME = "grave"
  20. def main() -> None:
  21. logging.basicConfig(level=logging.DEBUG)
  22. argparser = argparse.ArgumentParser(
  23. description="Attach resriptoon to running Toontown Rewritten engines.",
  24. )
  25. argparser.add_argument(
  26. "--toggle",
  27. "-t",
  28. metavar="KEYSYM_NAME",
  29. dest="toggle_keysym_name",
  30. default=_DEFAULT_TOGGLE_KEYSYM_NAME,
  31. help="key to turn extended keyboard controls on / off."
  32. + " any keysym name may be used"
  33. + " (see XStringToKeysym & X11/keysymdef.h, "
  34. + " default: %(default)s)",
  35. )
  36. args = argparser.parse_args()
  37. toggle_keysym = XK.string_to_keysym(args.toggle_keysym_name)
  38. if toggle_keysym == X.NoSymbol:
  39. raise ValueError(
  40. "controls toggle: unknown keysym name '{}'".format(args.toggle_keysym_name)
  41. )
  42. rescriptoon.Overlay(toggle_keysym=toggle_keysym).run()