Skip to content

Commit

Permalink
feat!: switched config format to toml (#57)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: changes the config file used
  • Loading branch information
ErikBjare committed Jun 15, 2021
1 parent 8682633 commit 301449f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 22 deletions.
50 changes: 33 additions & 17 deletions aw_watcher_window/config.py
@@ -1,31 +1,47 @@
from configparser import ConfigParser
import argparse

from aw_core.config import load_config as _load_config
from aw_core.config import load_config_toml


default_config = """
[aw-watcher-window]
exclude_title = false
poll_time = 1.0
strategy_macos = "jxa"
""".strip()


def load_config():
default_client_config = ConfigParser()
default_client_config["aw-watcher-window"] = default_client_config["aw-watcher-window-testing"] = {
"exclude_title": False,
"poll_time": "1.0",
"strategy_macos": "jxa"
}
return load_config_toml("aw-watcher-window", default_config)["aw-watcher-window"]

# TODO: Handle so aw-watcher-window testing gets loaded instead of testing is on
return _load_config("aw-watcher-window", default_client_config)["aw-watcher-window"]

def parse_args():
config = load_config()

default_poll_time = config.getfloat("poll_time")
default_exclude_title = config.getboolean("exclude_title")
default_strategy_macos = config.get("strategy_macos")
default_poll_time = config["poll_time"]
default_exclude_title = config["exclude_title"]
default_strategy_macos = config["strategy_macos"]

parser = argparse.ArgumentParser("A cross platform window watcher for Activitywatch.\nSupported on: Linux (X11), macOS and Windows.")
parser = argparse.ArgumentParser(
"A cross platform window watcher for Activitywatch.\nSupported on: Linux (X11), macOS and Windows."
)
parser.add_argument("--testing", dest="testing", action="store_true")
parser.add_argument("--exclude-title", dest="exclude_title", action="store_true", default=default_exclude_title)
parser.add_argument(
"--exclude-title",
dest="exclude_title",
action="store_true",
default=default_exclude_title,
)
parser.add_argument("--verbose", dest="verbose", action="store_true")
parser.add_argument("--poll-time", dest="poll_time", type=float, default=default_poll_time)
parser.add_argument("--strategy", dest="strategy", default=default_strategy_macos, choices=["jxa", "applescript"], help="(macOS only) strategy to use for retrieving the active window")
parser.add_argument(
"--poll-time", dest="poll_time", type=float, default=default_poll_time
)
parser.add_argument(
"--strategy",
dest="strategy",
default=default_strategy_macos,
choices=["jxa", "applescript"],
help="(macOS only) strategy to use for retrieving the active window",
)
parsed_args = parser.parse_args()
return parsed_args
39 changes: 34 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 301449f

Please sign in to comment.