Add Esc cancel support

This commit is contained in:
Thales Maciel 2026-02-24 14:23:03 -03:00
parent b3be444625
commit f9224621fa
No known key found for this signature in database
GPG key ID: 33112E6833C34679
6 changed files with 19 additions and 0 deletions

View file

@ -231,6 +231,12 @@ class Daemon:
stream, record = payload
self._start_stop_worker(stream, record, trigger, process_audio)
def cancel_recording(self):
with self.lock:
if self.state != State.RECORDING:
return
self.stop_recording(trigger="cancel", process_audio=False)
def shutdown(self, timeout: float = 5.0) -> bool:
self.request_shutdown()
self.stop_recording(trigger="shutdown", process_audio=False)
@ -348,6 +354,7 @@ def main():
cfg.daemon.hotkey,
lambda: logging.info("hotkey pressed (dry-run)") if args.dry_run else daemon.toggle(),
)
desktop.start_cancel_listener(lambda: daemon.cancel_recording())
logging.info("ready")
try:
desktop.run_tray(daemon.get_state, lambda: shutdown("quit requested"))