summaryrefslogtreecommitdiff
path: root/backend/localplatform.py
blob: 5febfcaf313161d8b2e315a3c65e06a32c9115c5 (plain)
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 platform, os

ON_WINDOWS = platform.system() == "Windows"
ON_LINUX = not ON_WINDOWS

if ON_WINDOWS:
    from localplatformwin import *
    import localplatformwin as localplatform
else:
    from localplatformlinux import *
    import localplatformlinux as localplatform

def get_privileged_path() -> str:
    '''Get path accessible by elevated user. Holds plugins, decky loader and decky loader configs'''
    return localplatform.get_privileged_path()

def get_unprivileged_path() -> str:
    '''Get path accessible by non-elevated user. Holds plugin configuration, plugin data and plugin logs. Externally referred to as the 'Homebrew' directory'''
    return localplatform.get_unprivileged_path()

def get_unprivileged_user() -> str:
    '''Get user that should own files made in unprivileged path'''
    return localplatform.get_unprivileged_user()

def get_chown_plugin_path() -> bool:
    return os.getenv("CHOWN_PLUGIN_PATH", "1") == "1"

def get_server_host() -> str:
    return os.getenv("SERVER_HOST", "127.0.0.1")

def get_server_port() -> int:
    return int(os.getenv("SERVER_PORT", "1337"))

def get_live_reload() -> bool:
    return os.getenv("LIVE_RELOAD", "1") == "1"

def get_keep_systemd_service() -> bool:
    return os.getenv("KEEP_SYSTEMD_SERVICE", "0") == "1"

def get_log_level() -> int:
    return {"CRITICAL": 50, "ERROR": 40, "WARNING": 30, "INFO": 20, "DEBUG": 10}[
        os.getenv("LOG_LEVEL", "INFO")
    ]