Wake-word barge-in, Gitea auto-updater, hard_reset fix
This commit is contained in:
+23
-2
@@ -13,7 +13,7 @@ import sys
|
||||
from PySide6.QtCore import QThread
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from .. import config
|
||||
from .. import config, updater
|
||||
from ..controller import PetController
|
||||
from ..hotkey import GlobalHotkey
|
||||
from ..state import PetState
|
||||
@@ -91,6 +91,19 @@ def run() -> int:
|
||||
elif hotkey.running:
|
||||
_log(f"Push-to-talk: {config.PUSH_TO_TALK_HOTKEY}")
|
||||
|
||||
# The updater has already moved the checkout by the time this fires; all
|
||||
# that's left is to let Qt tear down cleanly (so the mic and the tray
|
||||
# icon are released) and then exec the new code. Doing the exec after
|
||||
# app.exec() returns, rather than from the controller thread, is what
|
||||
# guarantees the audio device is free before the new process opens it.
|
||||
pending_restart = {"tag": None}
|
||||
|
||||
def _handle_restart(tag: str) -> None:
|
||||
pending_restart["tag"] = tag
|
||||
app.quit()
|
||||
|
||||
controller.restart_requested.connect(_handle_restart)
|
||||
|
||||
def _shutdown() -> None:
|
||||
hotkey.stop()
|
||||
controller.stop()
|
||||
@@ -100,4 +113,12 @@ def run() -> int:
|
||||
app.aboutToQuit.connect(_shutdown)
|
||||
|
||||
thread.start()
|
||||
return app.exec()
|
||||
status = app.exec()
|
||||
|
||||
if pending_restart["tag"]:
|
||||
_log(f"Restarting into {pending_restart['tag']}…")
|
||||
try:
|
||||
updater.restart() # never returns
|
||||
except Exception as exc:
|
||||
_log(f"Couldn't restart automatically ({exc}) — start the pet again by hand.")
|
||||
return status
|
||||
|
||||
Reference in New Issue
Block a user