core (constants): Use runtime dir:
PID and PB bridge socket were using temporary directory, but the good practice is to use XDG_RUNTIME_DIR instead.
This commit is contained in:
parent
1cf75f1126
commit
a338bef90d
2 changed files with 7 additions and 6 deletions
|
|
@ -38,6 +38,7 @@ xdg_config_dirs = [
|
||||||
d for d in os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg").split(":") if d
|
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_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:
|
class Const:
|
||||||
|
|
@ -80,7 +81,7 @@ class Const:
|
||||||
for p in CONFIG_PATHS:
|
for p in CONFIG_PATHS:
|
||||||
CONFIG_FILES.append(p / f"{APP_NAME_FILE}.toml")
|
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 ##
|
## Runtime ##
|
||||||
PLUGIN_EXT = "py"
|
PLUGIN_EXT = "py"
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,10 @@ class PbBridgeSettings(ConfigOptions):
|
||||||
default=8789, description='TCP port to use when ``connection_type`` is "socket"'
|
default=8789, description='TCP port to use when ``connection_type`` is "socket"'
|
||||||
)
|
)
|
||||||
socket_dir: DirectoryPathAuto = Field(
|
socket_dir: DirectoryPathAuto = Field(
|
||||||
default=C.TEMP_DIR,
|
default=C.RUNTIME_DIR,
|
||||||
description=(
|
description=(
|
||||||
"Directory where the UNIX socket file will be created when using unix_socket"
|
"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(
|
host: str = Field(
|
||||||
|
|
@ -263,10 +263,10 @@ class CommonSettings(ConfigOptions):
|
||||||
)
|
)
|
||||||
log_fmt: str | None = Field(default=None, description="Log message format")
|
log_fmt: str | None = Field(default=None, description="Log message format")
|
||||||
pid_dir: DirectoryPathAuto = Field(
|
pid_dir: DirectoryPathAuto = Field(
|
||||||
default=C.TEMP_DIR,
|
default=C.RUNTIME_DIR,
|
||||||
description=(
|
description=(
|
||||||
"Directory where PID files will be stored. Default is a subdirectory of the"
|
"Directory where PID files will be stored. Default is the user's runtime"
|
||||||
" system's temporary directory."
|
" directory."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
xmpp_domain: str = Field(
|
xmpp_domain: str = Field(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue