-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
config.py
49 lines (40 loc) · 1.41 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import argparse
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():
return load_config_toml("aw-watcher-window", default_config)["aw-watcher-window"]
def parse_args():
config = load_config()
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.add_argument("--host", dest="host")
parser.add_argument("--port", dest="port")
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("--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",
)
parsed_args = parser.parse_args()
return parsed_args