Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: Detect Linux terminal and use different paste keys

Toby Foxd7c478790079
diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.js
index 6b0dedcce..1aaffcb9d 100644
--- a/src/helpers/clipboard.js
+++ b/src/helpers/clipboard.js
@@ -167,24 +167,78 @@ class ClipboardManager {
}
};
+ // Detect if the focused window is a terminal emulator
+ // Terminals use Ctrl+Shift+V for paste (since Ctrl+V/C are used for process control)
+ const isTerminal = () => {
+ try {
+ if (commandExists("xdotool")) {
+ const result = spawnSync("xdotool", [
+ "getactivewindow",
+ "getwindowclassname",
+ ]);
+ if (result.status === 0) {
+ const className = result.stdout.toString().toLowerCase().trim();
+ // Common terminal emulator class names
+ const terminalClasses = [
+ "konsole",
+ "gnome-terminal",
+ "terminal",
+ "kitty",
+ "alacritty",
+ "terminator",
+ "xterm",
+ "urxvt",
+ "rxvt",
+ "tilix",
+ "terminology",
+ "wezterm",
+ "foot",
+ "st",
+ "yakuake",
+ ];
+ const isTerminalWindow = terminalClasses.some((term) =>
+ className.includes(term)
+ );
+ if (isTerminalWindow) {
+ this.safeLog(`🖥️ Terminal detected: ${className}`);
+ }
+ return isTerminalWindow;
+ }
+ }
+ } catch (error) {
+ // Silent fallback - if detection fails, assume non-terminal
+ }
+ return false;
+ };
+
// Detect if running on Wayland or X11
const isWayland =
(process.env.XDG_SESSION_TYPE || "").toLowerCase() === "wayland" ||
!!process.env.WAYLAND_DISPLAY;
+ const inTerminal = isTerminal();
+ const pasteKeys = inTerminal ? "ctrl+shift+v" : "ctrl+v";
+
// Define paste tools in preference order based on display server
const candidates = isWayland
? [
// Wayland tools
- { cmd: "wtype", args: ["-M", "ctrl", "-p", "v", "-m", "ctrl"] },
+ inTerminal
+ ? {
+ cmd: "wtype",
+ args: ["-M", "ctrl", "-M", "shift", "-k", "v", "-m", "shift", "-m", "ctrl"],
+ }
+ : { cmd: "wtype", args: ["-M", "ctrl", "-k", "v", "-m", "ctrl"] },
// ydotool requires uinput permissions but included as fallback
- { cmd: "ydotool", args: ["key", "29:1", "47:1", "47:0", "29:0"] },
+ inTerminal
+ ? { cmd: "ydotool", args: ["key", "29:1", "42:1", "47:1", "47:0", "42:0", "29:0"] }
+ : { cmd: "ydotool", args: ["key", "29:1", "47:1", "47:0", "29:0"] },
// X11 fallback for XWayland
- { cmd: "xdotool", args: ["key", "ctrl+v"] },
+ { cmd: "xdotool", args: ["key", pasteKeys] },
]
: [
// X11 tools
- { cmd: "xdotool", args: ["key", "ctrl+v"] },
+ { cmd: "xdotool", args: ["key", pasteKeys] },
];
// Filter to only available tools