fix: set SDL_AUDIODRIVER=pulse and XDG_RUNTIME_DIR for cron/API audio
This commit is contained in:
+10
-1
@@ -46,18 +46,27 @@ def _default_command() -> str:
|
||||
"""Return the default shell command to run wecker.py from crontab."""
|
||||
project_root = _project_root()
|
||||
python_exec = sys.executable
|
||||
return f"cd {project_root} && {python_exec} wecker.py >> wecker.log 2>&1"
|
||||
runtime_dir = f"/run/user/{os.getuid()}"
|
||||
return (
|
||||
f"cd {project_root} && "
|
||||
f"XDG_RUNTIME_DIR={runtime_dir} SDL_AUDIODRIVER=pulse "
|
||||
f"{python_exec} wecker.py >> wecker.log 2>&1"
|
||||
)
|
||||
|
||||
|
||||
def _start_wecker_process() -> subprocess.Popen:
|
||||
"""Start wecker.py without invoking a shell."""
|
||||
project_root = _project_root()
|
||||
env = os.environ.copy()
|
||||
env.setdefault("SDL_AUDIODRIVER", "pulse")
|
||||
env.setdefault("XDG_RUNTIME_DIR", f"/run/user/{os.getuid()}")
|
||||
return subprocess.Popen(
|
||||
[sys.executable, str(project_root / "wecker.py")],
|
||||
cwd=project_root,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
start_new_session=True,
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user