From: 
Subject: Debian changes

The Debian packaging of linux-voice-assistant is maintained in git, using a workflow
similar to the one described in dgit-maint-merge(7).
The Debian delta is represented by this one combined patch; there isn't a
patch queue that can be represented as a quilt series.

A detailed breakdown of the changes is available from their canonical
representation -- git commits in the packaging repository.
For example, to see the changes made by the Debian maintainer in the first
upload of upstream version 1.2.3, you could use:

    % git clone https://git.dgit.debian.org/linux-voice-assistant
    % cd linux-voice-assistant
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

(If you have dgit, use `dgit clone linux-voice-assistant`, rather than plain `git clone`.)

We don't use debian/source/options single-debian-patch because it has bugs.
Therefore, NMUs etc. may nevertheless have made additional patches.

---

diff --git a/README.md b/README.md
index 3f8389c..cf9f742 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ usage: __main__.py [-h] [--name NAME] [--audio-input-device AUDIO_INPUT_DEVICE]
 | `--wake-word-dir`          | Directory with wake word models (.tflite) and configs (.json) | `wakewords/`                      |
 | `--wake-model`             | ID of active wake word model                                  | `okay_nabu`                       |
 | `--stop-model`             | ID of stop model                                              | `stop`                            |
-| `--download-dir`           | Directory to download custom wake word models, etc.           | `local/`                          |
+| `--download-dir`           | Directory to download custom wake word models, etc.           | `$XDG_DATA_HOME/linux-voice-assistant` or `~/.local/share/linux-voice-assistant` |
 | `--refractory-seconds`     | Seconds before wake word can be activated again               | 2.0                               |
 | `--timer-max-ring-seconds` | Seconds after which the timer stops ringing                   | 900.0                             |
 | `--wakeup-sound`           | Sound file played when wake word is detected                  | `sounds/wake_word_triggered.flac` |
@@ -100,7 +100,7 @@ usage: __main__.py [-h] [--name NAME] [--audio-input-device AUDIO_INPUT_DEVICE]
 | `--processing-sound`       | Sound played while assistant is processing                    | `sounds/processing.wav`           |
 | `--mute-sound`             | Sound played when muting the assistant                        | `sounds/mute_switch_on.flac`      |
 | `--unmute-sound`           | Sound played when unmuting the assistant                      | `sounds/mute_switch_off.flac`     |
-| `--preferences-file`       | Path to preferences JSON file                                 | `preferences.json`                |
+| `--preferences-file`       | Path to preferences JSON file                                 | `$XDG_CONFIG_HOME/linux-voice-assistant/preferences.json` or `~/.config/linux-voice-assistant/preferences.json` |
 | `--host`                   | IP-Address for ESPHome server, use 0.0.0.0 for all            | Autodetected                      |
 | `--network-interface`      | Network interface for ESPHome server                          | Autodetected                      |
 | `--port`                   | Port for ESPHome server                                       | 6053                              |
diff --git a/linux_voice_assistant/__main__.py b/linux_voice_assistant/__main__.py
index 18a43ea..cc61cfc 100644
--- a/linux_voice_assistant/__main__.py
+++ b/linux_voice_assistant/__main__.py
@@ -4,6 +4,7 @@ import asyncio
 import errno
 import json
 import logging
+import os
 import sys
 import threading
 import time
@@ -34,8 +35,32 @@ from .zeroconf import HomeAssistantZeroconf
 _LOGGER = logging.getLogger(__name__)
 _MODULE_DIR = Path(__file__).parent
 _REPO_DIR = _MODULE_DIR.parent
-_WAKEWORDS_DIR = _REPO_DIR / "wakewords"
-_SOUNDS_DIR = _REPO_DIR / "sounds"
+_APP_NAME = "linux-voice-assistant"
+_SYSTEM_DATA_DIR = Path("/usr/share") / _APP_NAME
+
+
+def _xdg_path(env_var: str, default_relative: Path, app_name: str) -> Path:
+    """Return an XDG base directory path for writable application state."""
+    base_dir = Path.home() / default_relative
+    if env_value := os.environ.get(env_var):
+        base_dir = Path(env_value).expanduser()
+
+    return base_dir / app_name
+
+
+def _asset_dir(name: str) -> Path:
+    for base_dir in (_REPO_DIR, _SYSTEM_DATA_DIR):
+        asset_dir = base_dir / name
+        if asset_dir.exists():
+            return asset_dir
+
+    return _REPO_DIR / name
+
+
+_WAKEWORDS_DIR = _asset_dir("wakewords")
+_SOUNDS_DIR = _asset_dir("sounds")
+_DEFAULT_DOWNLOAD_DIR = _xdg_path("XDG_DATA_HOME", Path(".local/share"), _APP_NAME)
+_DEFAULT_PREFERENCES_FILE = _xdg_path("XDG_CONFIG_HOME", Path(".config"), _APP_NAME) / "preferences.json"
 
 
 # -----------------------------------------------------------------------------
@@ -99,7 +124,7 @@ async def main() -> None:
     )
     parser.add_argument(
         "--download-dir",
-        default=_REPO_DIR / "local",
+        default=_DEFAULT_DOWNLOAD_DIR,
         help="Directory to download custom wake word models to",
     )
     parser.add_argument(
@@ -141,7 +166,7 @@ async def main() -> None:
     )
     parser.add_argument(
         "--preferences-file",
-        default=_REPO_DIR / "preferences.json",
+        default=_DEFAULT_PREFERENCES_FILE,
         help="Directory and file name for the file where the preferences are stored in JSON format",
     )
     parser.add_argument(
