config.diff 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff --git a/VulcanBoard.py b/VulcanBoard.py
  2. index e64c74c..1f6ec1e 100644
  3. --- a/VulcanBoard.py
  4. +++ b/VulcanBoard.py
  5. @@ -20,6 +20,7 @@ from os import path, getenv, name
  6. import subprocess
  7. import sys
  8. from dataclasses import dataclass
  9. +from argparse import ArgumentParser
  10. import yaml
  11. from termcolor import colored
  12. @@ -40,7 +41,7 @@ def log(message: str, color="green") -> None:
  13. print(colored("[*] {}".format(message), color)) # pyright: ignore
  14. -def get_config_path():
  15. +def get_default_config_path():
  16. if name == "nt":
  17. return path.join(getenv("APPDATA", ""), "VulcanBoard", "config.yml")
  18. xdg_config_home = getenv("XDG_CONFIG_HOME", path.expanduser("~/.config"))
  19. @@ -59,6 +60,35 @@ def is_valid_hexcolor(hexcolor: str) -> bool:
  20. return True
  21. +@dataclass
  22. +class CmdlineArgs:
  23. + use_fullscreen: bool
  24. + config_path: str
  25. +
  26. +
  27. +def parse_argv() -> CmdlineArgs:
  28. + parser = ArgumentParser(
  29. + prog="VulcanBoard",
  30. + description="a hotkey board for desktop touchscreens",
  31. + )
  32. + parser.add_argument(
  33. + "-f",
  34. + "--fullscreen",
  35. + action="use_fullscreen",
  36. + help="open hotkey deck in fullscreen mode",
  37. + )
  38. + parser.add_argument(
  39. + "-c",
  40. + "--config-file",
  41. + type=str,
  42. + help="specify the configuration file to use",
  43. + default=get_default_config_path(),
  44. + )
  45. +
  46. + args = parser.parse_args()
  47. + return CmdlineArgs(args.fullscreen, args.config_path)
  48. +
  49. +
  50. @dataclass
  51. class Config:
  52. columns: int
  53. @@ -137,7 +167,7 @@ class ConfigLoader:
  54. class VulcanBoardApp(App):
  55. def build(self) -> GridLayout:
  56. - config = ConfigLoader(get_config_path())
  57. + config = ConfigLoader(get_default_config_path())
  58. button_map = {
  59. (btn["position"][0], btn["position"][1]): btn