Add Esc cancel support
This commit is contained in:
parent
b3be444625
commit
f9224621fa
6 changed files with 19 additions and 0 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue