41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from os import environ
|
|
|
|
from .enums import SunshineAudioConfig
|
|
from .env_key import SunshineEnvKey as EnvKey
|
|
from .structs import (
|
|
SunshineAudioConfig,
|
|
SunshineClientInfo,
|
|
SunshineClientOptions,
|
|
SunshineClientSpecs,
|
|
SunshineEnvironmentVariables,
|
|
)
|
|
|
|
|
|
def load_env_variables() -> SunshineEnvironmentVariables:
|
|
def ld_str(var: EnvKey):
|
|
return environ.get(var.requested_key, var.default)
|
|
|
|
def ld_int(var: EnvKey):
|
|
return int(ld_str(var))
|
|
|
|
def ld_bool(var: EnvKey):
|
|
return ld_str(var).lower() == "true"
|
|
|
|
return SunshineEnvironmentVariables(
|
|
SunshineClientInfo(
|
|
app_id=ld_str(EnvKey.APP_ID), app_name=ld_str(EnvKey.APP_NAME)
|
|
),
|
|
SunshineClientSpecs(
|
|
width=ld_int(EnvKey.WIDTH),
|
|
height=ld_int(EnvKey.HEIGHT),
|
|
fps=ld_int(EnvKey.FPS),
|
|
hdr=ld_bool(EnvKey.HDR),
|
|
gcmap=ld_int(EnvKey.GCMAP),
|
|
),
|
|
SunshineClientOptions(
|
|
host_audio=ld_bool(EnvKey.HOST_AUDIO),
|
|
enable_sops=ld_bool(EnvKey.ENABLE_SOPS),
|
|
audio_config=SunshineAudioConfig(ld_str(EnvKey.AUDIO_CONFIG)),
|
|
),
|
|
)
|