Adds subtitle default dir

This commit is contained in:
Javanaut
2026-04-11 21:17:21 +02:00
parent 9a980b5766
commit 528915a235
5 changed files with 249 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ CONFIG_FILE="${FFX_CONFIG_FILE:-${CONFIG_DIR}/ffx.json}"
VAR_DIR="${FFX_VAR_DIR:-${HOME}/.local/var/ffx}"
LOG_DIR="${FFX_LOG_DIR:-${HOME}/.local/var/log}"
DATABASE_FILE="${FFX_DATABASE_FILE:-${VAR_DIR}/ffx.db}"
SUBTITLES_BASE_DIR="${FFX_SUBTITLES_BASE_DIR:-${HOME}/.local/var/sync/subtitles}"
CHECK_ONLY=0
WITH_TESTS=0
@@ -47,6 +48,7 @@ Environment overrides:
FFX_VAR_DIR Override the default data directory.
FFX_LOG_DIR Override the default log directory.
FFX_DATABASE_FILE Override the database path written into a newly seeded config.
FFX_SUBTITLES_BASE_DIR Override the default subtitles base directory written into a newly seeded config.
Notes:
- tools/setup.sh is the first installation step and owns bundle venv setup.
@@ -142,6 +144,13 @@ component_detail() {
printf 'missing; prep can create it'
fi
;;
subtitles-base-dir)
if check_seeded_dir "${SUBTITLES_BASE_DIR}"; then
printf '%s' "${SUBTITLES_BASE_DIR}"
else
printf 'missing; prep can create it'
fi
;;
ffx-config)
if check_seeded_file "${CONFIG_FILE}"; then
printf '%s' "${CONFIG_FILE}"
@@ -195,6 +204,9 @@ report_seeded_component() {
log-dir)
check_seeded_dir "${LOG_DIR}" || ok=0
;;
subtitles-base-dir)
check_seeded_dir "${SUBTITLES_BASE_DIR}" || ok=0
;;
ffx-config)
check_seeded_file "${CONFIG_FILE}" || ok=0
;;
@@ -231,6 +243,7 @@ print_seeded_file_status() {
report_seeded_component "Config dir" "config-dir" "optional"
report_seeded_component "Var dir" "var-dir" "optional"
report_seeded_component "Log dir" "log-dir" "optional"
report_seeded_component "Subtitles base dir" "subtitles-base-dir" "optional"
report_seeded_component "ffx config" "ffx-config" "optional"
}
@@ -340,12 +353,23 @@ seed_default_config() {
created_any=1
fi
if [ ! -d "${SUBTITLES_BASE_DIR}" ]; then
printf 'Creating subtitles base dir at %s...\n' "${SUBTITLES_BASE_DIR}"
if ! mkdir -p "${SUBTITLES_BASE_DIR}"; then
printf 'Failed to create subtitles base dir at %s.\n' "${SUBTITLES_BASE_DIR}" >&2
INSTALL_FAILURES=$((INSTALL_FAILURES + 1))
return 1
fi
created_any=1
fi
if [ ! -f "${CONFIG_FILE}" ]; then
printf 'Seeding ffx config at %s...\n' "${CONFIG_FILE}"
if ! cat >"${CONFIG_FILE}" <<EOF
{
"databasePath": "${DATABASE_FILE}",
"logDirectory": "${LOG_DIR}",
"subtitlesDirectory": "${SUBTITLES_BASE_DIR}",
"metadata": {
"signature": {
"RECODED_WITH": "FFX"