diff --git a/libervia/backend/core/constants.py b/libervia/backend/core/constants.py index b3c463f6..e067d1c4 100644 --- a/libervia/backend/core/constants.py +++ b/libervia/backend/core/constants.py @@ -38,6 +38,7 @@ xdg_config_dirs = [ d for d in os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg").split(":") if d ] xdg_data_home = Path(os.environ.get("XDG_DATA_HOME") or Path.home() / ".local/share") +xdg_runtime_dir = Path(os.environ.get("XDG_RUNTIME_DIR") or f"/run/user/{os.getuid()}") class Const: @@ -80,7 +81,7 @@ class Const: for p in CONFIG_PATHS: CONFIG_FILES.append(p / f"{APP_NAME_FILE}.toml") - TEMP_DIR = Path(tempfile.gettempdir(), f"{APP_NAME_FILE}_{logged_user}") + RUNTIME_DIR = xdg_runtime_dir / APP_NAME_FILE ## Runtime ## PLUGIN_EXT = "py" diff --git a/libervia/backend/tools/config.py b/libervia/backend/tools/config.py index 75d7c428..1b7b60e6 100644 --- a/libervia/backend/tools/config.py +++ b/libervia/backend/tools/config.py @@ -167,10 +167,10 @@ class PbBridgeSettings(ConfigOptions): default=8789, description='TCP port to use when ``connection_type`` is "socket"' ) socket_dir: DirectoryPathAuto = Field( - default=C.TEMP_DIR, + default=C.RUNTIME_DIR, description=( "Directory where the UNIX socket file will be created when using unix_socket" - " connection type." + " connection type. Default is the user's runtime directory." ), ) host: str = Field( @@ -263,10 +263,10 @@ class CommonSettings(ConfigOptions): ) log_fmt: str | None = Field(default=None, description="Log message format") pid_dir: DirectoryPathAuto = Field( - default=C.TEMP_DIR, + default=C.RUNTIME_DIR, description=( - "Directory where PID files will be stored. Default is a subdirectory of the" - " system's temporary directory." + "Directory where PID files will be stored. Default is the user's runtime" + " directory." ), ) xmpp_domain: str = Field(