-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
43 lines (37 loc) · 1.37 KB
/
config.py
File metadata and controls
43 lines (37 loc) · 1.37 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
from pathlib import Path
class Config:
def __init__(self):
self.config_file = Path.home() / "ios_shareeasy_config.json"
self.default_config = {
"copy_enabled": True,
"file_enabled": True,
"save_path": str(Path.home() / "Downloads" / "iOS-ShareEasy"),
"notifications_enabled": True,
"autostart_enabled": False,
"port": 8765,
"language": "en", # Default: inglese
"hide_tray_icon": False,
"detailed_notifications": False,
"start_minimized": False,
"first_run": True # Indica se è il primo avvio
}
self.load()
def load(self):
if self.config_file.exists():
with open(self.config_file, 'r', encoding='utf-8') as f:
self.data = json.load(f)
else:
self.data = self.default_config.copy()
self.save()
# Crea la cartella di salvataggio se non esiste
os.makedirs(self.data["save_path"], exist_ok=True)
def save(self):
with open(self.config_file, 'w', encoding='utf-8') as f:
json.dump(self.data, f, indent=4)
def get(self, key):
return self.data.get(key, self.default_config.get(key))
def set(self, key, value):
self.data[key] = value
self.save()