Internalized default settings
This commit is contained in:
parent
b12d9375ee
commit
5264103f31
@ -47,13 +47,6 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||||||
if not os.path.exists(self._PLUGINS_PATH):
|
if not os.path.exists(self._PLUGINS_PATH):
|
||||||
os.mkdir(self._PLUGINS_PATH)
|
os.mkdir(self._PLUGINS_PATH)
|
||||||
|
|
||||||
if not os.path.exists(self._CONFIG_FILE):
|
|
||||||
import shutil
|
|
||||||
try:
|
|
||||||
shutil.copyfile(self._USR_CONFIG_FILE, self._CONFIG_FILE)
|
|
||||||
except Exception as e:
|
|
||||||
raise
|
|
||||||
|
|
||||||
if not os.path.exists(self._DEFAULT_ICONS):
|
if not os.path.exists(self._DEFAULT_ICONS):
|
||||||
self._DEFAULT_ICONS = f"{self._USR_PATH}/icons"
|
self._DEFAULT_ICONS = f"{self._USR_PATH}/icons"
|
||||||
if not os.path.exists(self._DEFAULT_ICONS):
|
if not os.path.exists(self._DEFAULT_ICONS):
|
||||||
@ -158,8 +151,13 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||||||
self._debug = debug
|
self._debug = debug
|
||||||
|
|
||||||
def load_settings(self):
|
def load_settings(self):
|
||||||
|
if not os.path.exists(self._CONFIG_FILE):
|
||||||
|
self.settings = Settings()
|
||||||
|
return
|
||||||
|
|
||||||
with open(self._CONFIG_FILE) as file:
|
with open(self._CONFIG_FILE) as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
|
data["load_defaults"] = False
|
||||||
self.settings = Settings(**data)
|
self.settings = Settings(**data)
|
||||||
|
|
||||||
def save_settings(self):
|
def save_settings(self):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
|
|
||||||
@ -8,25 +8,25 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Config:
|
class Config:
|
||||||
base_of_home: str
|
base_of_home: str = ""
|
||||||
hide_hidden_files: str
|
hide_hidden_files: str = "true"
|
||||||
thumbnailer_path: str
|
thumbnailer_path: str = "ffmpegthumbnailer"
|
||||||
blender_thumbnailer_path: str
|
blender_thumbnailer_path: str = ""
|
||||||
go_past_home: str
|
go_past_home: str = "true"
|
||||||
lock_folder: str
|
lock_folder: str = "false"
|
||||||
locked_folders: str
|
locked_folders: list = field(default_factory=lambda: ["venv", "flasks"])
|
||||||
mplayer_options: str
|
mplayer_options: str = "-quiet -really-quiet -xy 1600 -geometry 50%:50%"
|
||||||
music_app: str
|
music_app: str = "deadbeef"
|
||||||
media_app: str
|
media_app: str = "mpv"
|
||||||
image_app: str
|
image_app: str = "mirage"
|
||||||
office_app: str
|
office_app: str = "libreoffice"
|
||||||
pdf_app: str
|
pdf_app: str = "evince"
|
||||||
code_app: str
|
code_app: str = "atom"
|
||||||
text_app: str
|
text_app: str = "mousepad"
|
||||||
terminal_app: str
|
terminal_app: str = "terminator"
|
||||||
container_icon_wh: []
|
file_manager_app: str = "solarfm"
|
||||||
video_icon_wh: []
|
container_icon_wh: list = field(default_factory=lambda: [128, 128])
|
||||||
sys_icon_wh: []
|
video_icon_wh: list = field(default_factory=lambda: [128, 64])
|
||||||
file_manager_app: str
|
sys_icon_wh: list = field(default_factory=lambda: [56, 56])
|
||||||
steam_cdn_url: str
|
steam_cdn_url: str = "https://steamcdn-a.akamaihd.net/steam/apps/"
|
||||||
remux_folder_max_disk_usage: str
|
remux_folder_max_disk_usage: str = "8589934592"
|
||||||
|
@ -8,5 +8,5 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Debugging:
|
class Debugging:
|
||||||
ch_log_lvl: int
|
ch_log_lvl: int = 10
|
||||||
fh_log_lvl: int
|
fh_log_lvl: int = 20
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
|
|
||||||
@ -8,11 +8,83 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Filters:
|
class Filters:
|
||||||
meshs: []
|
meshs: list = field(default_factory=lambda: [
|
||||||
code: []
|
".blend",
|
||||||
videos: []
|
".dae",
|
||||||
office: []
|
".fbx",
|
||||||
images: []
|
".gltf",
|
||||||
text: []
|
".obj",
|
||||||
music: []
|
".stl"
|
||||||
pdf: []
|
])
|
||||||
|
code: list = field(default_factory=lambda: [
|
||||||
|
".cpp",
|
||||||
|
".css",
|
||||||
|
".c",
|
||||||
|
".go",
|
||||||
|
".html",
|
||||||
|
".htm",
|
||||||
|
".java",
|
||||||
|
".js",
|
||||||
|
".json",
|
||||||
|
".lua",
|
||||||
|
".md",
|
||||||
|
".py",
|
||||||
|
".rs",
|
||||||
|
".toml",
|
||||||
|
".xml",
|
||||||
|
".pom"
|
||||||
|
])
|
||||||
|
videos: list = field(default_factory=lambda:[
|
||||||
|
".mkv",
|
||||||
|
".mp4",
|
||||||
|
".webm",
|
||||||
|
".avi",
|
||||||
|
".mov",
|
||||||
|
".m4v",
|
||||||
|
".mpg",
|
||||||
|
".mpeg",
|
||||||
|
".wmv",
|
||||||
|
".flv"
|
||||||
|
])
|
||||||
|
office: list = field(default_factory=lambda: [
|
||||||
|
".doc",
|
||||||
|
".docx",
|
||||||
|
".xls",
|
||||||
|
".xlsx",
|
||||||
|
".xlt",
|
||||||
|
".xltx",
|
||||||
|
".xlm",
|
||||||
|
".ppt",
|
||||||
|
".pptx",
|
||||||
|
".pps",
|
||||||
|
".ppsx",
|
||||||
|
".odt",
|
||||||
|
".rtf"
|
||||||
|
])
|
||||||
|
images: list = field(default_factory=lambda: [
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".jpeg",
|
||||||
|
".gif",
|
||||||
|
".ico",
|
||||||
|
".tga",
|
||||||
|
".webp"
|
||||||
|
])
|
||||||
|
text: list = field(default_factory=lambda: [
|
||||||
|
".txt",
|
||||||
|
".text",
|
||||||
|
".sh",
|
||||||
|
".cfg",
|
||||||
|
".conf",
|
||||||
|
".log"
|
||||||
|
])
|
||||||
|
music: list = field(default_factory=lambda: [
|
||||||
|
".psf",
|
||||||
|
".mp3",
|
||||||
|
".ogg",
|
||||||
|
".flac",
|
||||||
|
".m4a"
|
||||||
|
])
|
||||||
|
pdf: list = field(default_factory=lambda: [
|
||||||
|
".pdf"
|
||||||
|
])
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
|
|
||||||
# Gtk imports
|
# Gtk imports
|
||||||
@ -13,16 +13,19 @@ from .debugging import Debugging
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Settings:
|
class Settings:
|
||||||
config: Config
|
load_defaults: bool = True
|
||||||
filters: Filters
|
config: Config = field(default_factory=lambda: Config())
|
||||||
theming: Theming
|
filters: Filters = field(default_factory=lambda: Filters())
|
||||||
debugging: Debugging
|
theming: Theming = field(default_factory=lambda: Theming())
|
||||||
|
debugging: Debugging = field(default_factory=lambda: Debugging())
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.config = Config(**self.config)
|
if not self.load_defaults:
|
||||||
self.filters = Filters(**self.filters)
|
self.load_defaults = False
|
||||||
self.theming = Theming(**self.theming)
|
self.config = Config(**self.config)
|
||||||
self.debugging = Debugging(**self.debugging)
|
self.filters = Filters(**self.filters)
|
||||||
|
self.theming = Theming(**self.theming)
|
||||||
|
self.debugging = Debugging(**self.debugging)
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
return asdict(self)
|
return asdict(self)
|
||||||
|
@ -8,6 +8,6 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Theming:
|
class Theming:
|
||||||
success_color: str
|
success_color: str = "#88cc27"
|
||||||
warning_color: str
|
warning_color: str = "#ffa800"
|
||||||
error_color: str
|
error_color: str = "#ff0000"
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
{
|
|
||||||
"config": {
|
|
||||||
"base_of_home": "",
|
|
||||||
"hide_hidden_files": "true",
|
|
||||||
"thumbnailer_path": "ffmpegthumbnailer",
|
|
||||||
"blender_thumbnailer_path": "",
|
|
||||||
"go_past_home": "true",
|
|
||||||
"lock_folder": "false",
|
|
||||||
"locked_folders": "venv::::flasks",
|
|
||||||
"mplayer_options": "-quiet -really-quiet -xy 1600 -geometry 50%:50%",
|
|
||||||
"music_app": "deadbeef",
|
|
||||||
"media_app": "mpv",
|
|
||||||
"image_app": "mirage2",
|
|
||||||
"office_app": "libreoffice",
|
|
||||||
"pdf_app": "evince",
|
|
||||||
"code_app": "atom",
|
|
||||||
"text_app": "mousepad",
|
|
||||||
"terminal_app": "terminator",
|
|
||||||
"container_icon_wh": [128, 128],
|
|
||||||
"video_icon_wh": [128, 64],
|
|
||||||
"sys_icon_wh": [56, 56],
|
|
||||||
"file_manager_app": "solarfm",
|
|
||||||
"steam_cdn_url": "https://steamcdn-a.akamaihd.net/steam/apps/",
|
|
||||||
"remux_folder_max_disk_usage": "8589934592"
|
|
||||||
},
|
|
||||||
"filters": {
|
|
||||||
"meshs": [".dae", ".fbx", ".gltf", ".obj", ".stl"],
|
|
||||||
"code": [".cpp", ".css", ".c", ".go", ".html", ".htm", ".java", ".js", ".json", ".lua", ".md", ".py", ".rs", ".toml", ".xml", ".pom"],
|
|
||||||
"videos": [".mkv", ".mp4", ".webm", ".avi", ".mov", ".m4v", ".mpg", ".mpeg", ".wmv", ".flv"],
|
|
||||||
"office": [".doc", ".docx", ".xls", ".xlsx", ".xlt", ".xltx", ".xlm", ".ppt", ".pptx", ".pps", ".ppsx", ".odt", ".rtf"],
|
|
||||||
"images": [".png", ".jpg", ".jpeg", ".gif", ".ico", ".tga", ".webp"],
|
|
||||||
"text": [".txt", ".text", ".sh", ".cfg", ".conf", ".log"],
|
|
||||||
"music": [".psf", ".mp3", ".ogg", ".flac", ".m4a"],
|
|
||||||
"pdf": [".pdf"]
|
|
||||||
},
|
|
||||||
"theming":{
|
|
||||||
"success_color": "#88cc27",
|
|
||||||
"warning_color": "#ffa800",
|
|
||||||
"error_color": "#ff0000"
|
|
||||||
},
|
|
||||||
"debugging": {
|
|
||||||
"ch_log_lvl": 20,
|
|
||||||
"fh_log_lvl": 10
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user