-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
43 lines (34 loc) · 1.04 KB
/
Copy pathconfig.py
File metadata and controls
43 lines (34 loc) · 1.04 KB
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
import json
import os
CONFIG_FILE = 'config.json'
DEFAULT_ICON_FILE = 'icon.png'
default_config = {
'voice': 'Antoni',
'language': 'en',
'max_memory': 10,
'screenshot_dir': 'screenshots',
'feedback_log_file': 'feedback.json',
'cancel_hotkey': 'ctrl+c'
}
def create_default_icon():
if not os.path.exists(DEFAULT_ICON_FILE):
from PIL import Image
img = Image.new('RGB', (64, 64), color = (73, 109, 137))
img.save(DEFAULT_ICON_FILE)
def load_config():
if not os.path.exists(CONFIG_FILE):
save_config(default_config)
print(f"Created default configuration file: {CONFIG_FILE}")
with open(CONFIG_FILE, 'r') as f:
return json.load(f)
def save_config(config):
with open(CONFIG_FILE, 'w') as f:
json.dump(config, f, indent=2)
def ensure_directories(config):
os.makedirs(config['screenshot_dir'], exist_ok=True)
def initialize_config():
config = load_config()
ensure_directories(config)
create_default_icon()
return config
config = initialize_config()