feat: add global recording shortcut

This commit is contained in:
Evandro committed 2026-06-11 01:05:50 -03:00
1 parent 1f6ea8e5db
commit 2aaad73652
3 files changed
+268 -196

No files matched your search

+3
View File
@@ -4,6 +4,7 @@ pub mod error;
pub mod injection;
pub mod models;
pub mod settings;
pub mod shortcuts;
pub mod transcription;
pub mod tray;
pub mod ui_commands;
@@ -14,8 +15,10 @@ use app_state::ManagedAppState;
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(shortcuts::plugin())
.setup(|app| {
tray::setup(app)?;
shortcuts::setup(app)?;
Ok(())
})
.manage(ManagedAppState::default())
+20
View File
@@ -0,0 +1,20 @@
use tauri::{App, Emitter, Runtime};
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
pub const TOGGLE_RECORDING_EVENT: &str = "transcript://toggle-recording";
pub fn plugin<R: Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri_plugin_global_shortcut::Builder::new()
.with_handler(|app, _shortcut, event| {
if event.state() == ShortcutState::Pressed {
let _ = app.emit(TOGGLE_RECORDING_EVENT, ());
}
})
.build()
}
pub fn setup(app: &App) -> Result<(), Box<dyn std::error::Error>> {
let shortcut = Shortcut::new(Some(Modifiers::CONTROL | Modifiers::SHIFT), Code::Space);
app.global_shortcut().register(shortcut)?;
Ok(())
}