Skip to content

Commit 4b8b78a

Browse files
author
nix
committed
add nix config support
1 parent c1740e1 commit 4b8b78a

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

funscript_editor/definitions.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@
66

77
import multiprocessing as mp
88

9-
10-
###############
11-
# DIRECTORIES #
12-
###############
13-
9+
CONFIG_VERSION = 1
1410
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
11+
CONFIG_TEMPLATE_DIR = os.path.join(ROOT_DIR, 'config')
12+
1513
if os.path.abspath(__file__).startswith("/nix"):
1614
CACHE_DIR = '/tmp/mtfg-cache'
15+
CONFIG_DIR = os.path.join(os.path.join(os.path.expanduser('~'), '.config'), 'mtfg')
16+
os.makedirs(CONFIG_DIR, exist_ok=True)
17+
COPY_CONFIG_TEMPLATES = True
18+
CONFIG_VERSION_FILE = os.path.join(CONFIG_DIR, ".version")
19+
if os.path.exists(CONFIG_VERSION_FILE):
20+
with open(CONFIG_VERSION_FILE, "r") as f:
21+
if f.readlines() == [str(CONFIG_VERSION)]:
22+
COPY_CONFIG_TEMPLATES = False
23+
if COPY_CONFIG_TEMPLATES:
24+
os.system(f"cp -rfv \"{CONFIG_TEMPLATE_DIR}/.\" \"{CONFIG_DIR}\"")
25+
with open(CONFIG_VERSION_FILE, "w") as f:
26+
f.write(str(CONFIG_VERSION))
1727
else:
1828
CACHE_DIR = os.path.join(ROOT_DIR, 'cache')
19-
CONFIG_DIR = os.path.join(ROOT_DIR, 'config')
20-
UI_DIR = os.path.join(ROOT_DIR, 'ui')
21-
ICON_PATH = os.path.join(CONFIG_DIR, 'icon.png')
29+
CONFIG_DIR = CONFIG_TEMPLATE_DIR
30+
31+
ICON_PATH = os.path.join(os.path.join(ROOT_DIR, 'config'), 'icon.png')
2232
DOCS_URL = "https://github.com/michael-mueller-git/Python-Funscript-Editor/tree/{tag}/docs/app/docs"
2333
RAW_TRACKING_DATA_CAHCE_FILE = os.path.join(CACHE_DIR, 'raw_tracking_data.json')
2434

@@ -43,22 +53,11 @@
4353
APP_DOCUMENTATION_DIR = ''
4454
CODE_DOCUMENTATION_DIR = ''
4555

46-
47-
################
48-
# CONFIG FILES #
49-
################
50-
5156
UI_CONFIG_FILE = os.path.join(CONFIG_DIR, 'ui.yaml')
5257
WINDOWS_LOG_CONFIG_FILE = os.path.join(CONFIG_DIR, 'logging_windows.yaml')
5358
LINUX_LOG_CONFIG_FILE = os.path.join(CONFIG_DIR, 'logging_linux.yaml')
5459
HYPERPARAMETER_CONFIG_FILE = os.path.join(CONFIG_DIR, 'hyperparameter.yaml')
5560
SETTINGS_CONFIG_FILE = os.path.join(CONFIG_DIR, 'settings.yaml')
5661
PROJECTION_CONFIG_FILE = os.path.join(CONFIG_DIR, 'projection.yaml')
57-
58-
59-
##########
60-
# CONFIG #
61-
##########
62-
6362
CPU_CORES = int(mp.cpu_count()-1)
6463

0 commit comments

Comments
 (0)