This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
62 lines (56 loc) · 1.89 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
50
51
52
53
54
55
56
57
58
59
60
61
62
import os.path
from globals import app_author, app_version, app_name
from appdirs import user_config_dir, user_data_dir
from pathlib import Path
import logging
class Config:
def __init__(self):
self.config_dir = user_config_dir(app_name, app_author)
self.data_dir = user_data_dir(app_name, app_author)
self.profile_location = Path(os.path.join(self.data_dir, 'profile.json'))
self._check_directories()
self._check_profile()
def _check_directories(self):
for d in [self.config_dir, self.data_dir]:
if not os.path.exists(d):
logging.info(f"Creating config directory {d}")
Path(d).mkdir(parents=True, exist_ok=True)
def _check_profile(self):
if not self.profile_location.exists():
logging.info(f"Creating default profiles.json file at {self.profile_location}")
with open(self.profile_location, 'w') as f:
f.write("""{
"Default": {
"layer1": {
"layerName": "Layer 1 Name",
"leftButton": null,
"rightButton": null,
"middleButton": null,
"mouseButton4": null,
"mouseButton5": null,
"scrollUp": null,
"scrollDown": null,
"tiltWheelLeft": null,
"tiltWheelRight": null
},
"layer2": {
"layerName": null,
"leftButton": null,
"rightButton": null,
"middleButton": null,
"mouseButton4": null,
"mouseButton5": null,
"scrollUp": null,
"scrollDown": null,
"tiltWheelLeft": null,
"tiltWheelRight": null
},
"description": "Default",
"windowCaption": "N/A",
"process": "*",
"windowClass": "N/A",
"parentClass": "N/A",
"matchType": "N/A",
"checked": 2
}
}""")