Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

disable cancel on linux (#392)

CJ Pais6c35a8d912e3
diff --git a/src-tauri/src/shortcut.rs b/src-tauri/src/shortcut.rs
index d87438ac..fdd5d758 100644
--- a/src-tauri/src/shortcut.rs
+++ b/src-tauri/src/shortcut.rs
@@ -739,24 +739,44 @@ pub fn resume_binding(app: AppHandle, id: String) -> Result<(), String> {
}
pub fn register_cancel_shortcut(app: &AppHandle) {
- let app_clone = app.clone();
- tauri::async_runtime::spawn(async move {
- if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
- if let Err(e) = register_shortcut(&app_clone, cancel_binding) {
- eprintln!("Failed to register cancel shortcut: {}", e);
+ // Cancel shortcut is disabled on Linux due to instability with dynamic shortcut registration
+ #[cfg(target_os = "linux")]
+ {
+ let _ = app;
+ return;
+ }
+
+ #[cfg(not(target_os = "linux"))]
+ {
+ let app_clone = app.clone();
+ tauri::async_runtime::spawn(async move {
+ if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
+ if let Err(e) = register_shortcut(&app_clone, cancel_binding) {
+ eprintln!("Failed to register cancel shortcut: {}", e);
+ }
}
- }
- });
+ });
+ }
}
pub fn unregister_cancel_shortcut(app: &AppHandle) {
- let app_clone = app.clone();
- tauri::async_runtime::spawn(async move {
- if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
- // We ignore errors here as it might already be unregistered
- let _ = unregister_shortcut(&app_clone, cancel_binding);
- }
- });
+ // Cancel shortcut is disabled on Linux due to instability with dynamic shortcut registration
+ #[cfg(target_os = "linux")]
+ {
+ let _ = app;
+ return;
+ }
+
+ #[cfg(not(target_os = "linux"))]
+ {
+ let app_clone = app.clone();
+ tauri::async_runtime::spawn(async move {
+ if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
+ // We ignore errors here as it might already be unregistered
+ let _ = unregister_shortcut(&app_clone, cancel_binding);
+ }
+ });
+ }
}
pub fn register_shortcut(app: &AppHandle, binding: ShortcutBinding) -> Result<(), String> {
diff --git a/src/components/settings/debug/DebugSettings.tsx b/src/components/settings/debug/DebugSettings.tsx
index 2a96c629..01e6c5b6 100644
--- a/src/components/settings/debug/DebugSettings.tsx
+++ b/src/components/settings/debug/DebugSettings.tsx
@@ -1,4 +1,5 @@
import React from "react";
+import { type } from "@tauri-apps/plugin-os";
import { WordCorrectionThreshold } from "./WordCorrectionThreshold";
import { LogDirectory } from "./LogDirectory";
import { LogLevelSelector } from "./LogLevelSelector";
@@ -17,6 +18,7 @@ import { useSettings } from "../../../hooks/useSettings";
export const DebugSettings: React.FC = () => {
const { getSetting } = useSettings();
const pushToTalk = getSetting("push_to_talk");
+ const isLinux = type() === "linux";
return (
<div className="max-w-3xl w-full mx-auto space-y-6">
@@ -38,11 +40,14 @@ export const DebugSettings: React.FC = () => {
<ClamshellMicrophoneSelector descriptionMode="tooltip" grouped={true} />
<PostProcessingToggle descriptionMode="tooltip" grouped={true} />
<MuteWhileRecording descriptionMode="tooltip" grouped={true} />
- <HandyShortcut
- shortcutId="cancel"
- grouped={true}
- disabled={pushToTalk}
- />
+ {/* Cancel shortcut is disabled on Linux due to instability with dynamic shortcut registration */}
+ {!isLinux && (
+ <HandyShortcut
+ shortcutId="cancel"
+ grouped={true}
+ disabled={pushToTalk}
+ />
+ )}
</SettingsGroup>
</div>
);