Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat: Enhance Linux support with Wayland, multiple package formats, and window controls
Gabriel Stein9baa783b9a36
diff --git a/README.md b/README.mdindex e125d4355..8dd17d708 100644--- a/README.md+++ b/README.md@@ -88,23 +88,87 @@ npm run pack**Note**: On macOS, you may see a security warning when first opening the unsigned app. Right-click and select "Open" to bypass this.-#### Debian / Ubuntu (Packaging & Install)+#### Linux (Multiple Package Formats)-To build and install the `.deb` package on Debian-based distributions:+OpenWhispr now supports multiple Linux package formats for maximum compatibility:++**Available Formats**:+- `.deb` - Debian, Ubuntu, Linux Mint, Pop!_OS+- `.rpm` - Fedora, Red Hat, CentOS, openSUSE+- `.tar.gz` - Universal archive (works on any distro)+- `.flatpak` - Sandboxed cross-distro package+- `AppImage` - Portable single-file executable++**Building Linux Packages**:++```bash+# Build all Linux package formats+npm run build:linux++# Find packages in dist/:+# - OpenWhispr-x.x.x-linux-x64.deb+# - OpenWhispr-x.x.x-linux-x64.rpm+# - OpenWhispr-x.x.x-linux-x64.tar.gz+# - OpenWhispr-x.x.x-linux-x64.flatpak+# - OpenWhispr-x.x.x-linux-x64.AppImage+```++**Installation Examples**:```bash-npm run pack:linux-sudo apt install ./dist/open-whispr_*_amd64.deb-# or: sudo dpkg -i ./dist/open-whispr_*_amd64.deb+# Debian/Ubuntu+sudo apt install ./dist/OpenWhispr-*-linux-x64.deb++# Fedora/RHEL+sudo dnf install ./dist/OpenWhispr-*-linux-x64.rpm++# Universal tar.gz (no root required)+tar -xzf dist/OpenWhispr-*-linux-x64.tar.gz+cd OpenWhispr-*/+./openwhispr++# Flatpak+flatpak install --user ./dist/OpenWhispr-*-linux-x64.flatpak++# AppImage (existing method)+chmod +x dist/OpenWhispr-*.AppImage+./dist/OpenWhispr-*.AppImage```-Optional dependencies for automatic paste on X11:+**Optional Dependencies for Automatic Paste**:+The clipboard paste feature requires platform-specific tools:++**X11 (Traditional Linux Desktop)**:```bash+# Debian/Ubuntusudo apt install xdotool++# Fedora/RHEL+sudo dnf install xdotool++# Arch+sudo pacman -S xdotool+```++**Wayland (Modern Linux Desktop)**:+```bash+# Debian/Ubuntu+sudo apt install wtype++# Fedora/RHEL+sudo dnf install wtype++# Arch+sudo pacman -S wtype++# Alternative: ydotool (requires uinput permissions)+sudo apt install ydotool # or equivalent for your distro```-> ℹ️ On Wayland sessions, `xdotool` only works when running OpenWhispr under XWayland. Without it, dictation still copies text to the clipboard; you just need to paste manually.+> ℹ️ **Note**: OpenWhispr automatically detects your display server (X11 vs Wayland) and uses the appropriate paste tool. If no paste tool is installed, text will still be copied to the clipboard - you'll just need to paste manually with Ctrl+V.++> 🔒 **Flatpak Security**: The Flatpak package includes sandboxing with explicit permissions for microphone, clipboard, and file access. See [electron-builder.json](electron-builder.json) for the complete permission list.### Building for Distributiondiff --git a/electron-builder.json b/electron-builder.jsonindex a98895550..0d2e157e6 100644--- a/electron-builder.json+++ b/electron-builder.json@@ -67,10 +67,33 @@"linux": {"target": ["AppImage",- "deb"+ "deb",+ "rpm",+ "tar.gz",+ "flatpak"],"icon": "src/assets/icon.png",- "category": "Utility"+ "category": "Utility",+ "artifactName": "${productName}-${version}-${os}-${arch}.${ext}"+ },+ "flatpak": {+ "runtime": "org.freedesktop.Platform",+ "runtimeVersion": "24.08",+ "sdk": "org.freedesktop.Sdk",+ "useWaylandFlags": true,+ "finishArgs": [+ "--socket=wayland",+ "--socket=fallback-x11",+ "--share=network",+ "--share=ipc",+ "--device=dri",+ "--socket=pulseaudio",+ "--filesystem=home",+ "--filesystem=xdg-documents",+ "--filesystem=xdg-download",+ "--talk-name=org.freedesktop.Notifications",+ "--talk-name=org.freedesktop.portal.Desktop"+ ]},"deb": {"afterRemove": "resources/linux/after-remove.sh"diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsxindex d0f2cf4bd..3b2a2fc9e 100644--- a/src/components/TitleBar.tsx+++ b/src/components/TitleBar.tsx@@ -1,4 +1,5 @@import React from "react";+import WindowControls from "./WindowControls";interface TitleBarProps {title?: string;@@ -15,6 +16,12 @@ export default function TitleBar({className = "",actions,}: TitleBarProps) {+ // Get platform info+ const platform =+ typeof window !== "undefined" && window.electronAPI?.getPlatform+ ? window.electronAPI.getPlatform()+ : "darwin";+return (<divclassName={`bg-white border-b border-gray-100 select-none ${className}`}@@ -31,12 +38,14 @@ export default function TitleBar({{children}</div>- {/* Right section - actions */}- <div+ {/* Right section - actions and window controls */}+ <divclassName="flex items-center gap-2"style={{ WebkitAppRegion: "no-drag" }}>{actions}+ {/* Show window controls on Linux and Windows (macOS uses native controls) */}+ {platform !== "darwin" && <WindowControls />}</div></div></div>diff --git a/src/components/WindowControls.tsx b/src/components/WindowControls.tsxnew file mode 100644index 000000000..866324670--- /dev/null+++ b/src/components/WindowControls.tsx@@ -0,0 +1,98 @@+import React, { useEffect, useState } from "react";+import { Button } from "./ui/button";+import { Minus, Square, X, Copy } from "lucide-react";++/**+ * Window control buttons for Linux and Windows platforms+ * Provides minimize, maximize/restore, and close functionality+ * macOS uses native window controls so this component is not rendered there+ */+export default function WindowControls() {+ const [isMaximized, setIsMaximized] = useState(false);++ useEffect(() => {+ let mounted = true;++ // Sync maximized state with main process+ const syncIsMaximized = async () => {+ try {+ const maximized = await window.electronAPI?.windowIsMaximized?.();+ if (mounted) {+ setIsMaximized(!!maximized);+ }+ } catch {+ // Silently handle if API not available+ }+ };++ // Initial sync+ syncIsMaximized();++ // Poll for changes (window can be maximized via double-click on title bar, etc.)+ const intervalId = setInterval(syncIsMaximized, 1000);++ return () => {+ mounted = false;+ clearInterval(intervalId);+ };+ }, []);++ const handleMinimize = async () => {+ try {+ await window.electronAPI?.windowMinimize?.();+ } catch {+ // Silently handle if API not available+ }+ };++ const handleMaximize = async () => {+ try {+ await window.electronAPI?.windowMaximize?.();+ // Update state after toggle+ const maximized = await window.electronAPI?.windowIsMaximized?.();+ setIsMaximized(!!maximized);+ } catch {+ // Silently handle if API not available+ }+ };++ const handleClose = async () => {+ try {+ await window.electronAPI?.windowClose?.();+ } catch {+ // Silently handle if API not available+ }+ };++ return (+ <div className="flex items-center gap-1 pointer-events-auto">+ <Button+ variant="ghost"+ size="icon"+ onClick={handleMinimize}+ title="Minimize"+ className="h-8 w-8"+ >+ <Minus size={14} />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={handleMaximize}+ title={isMaximized ? "Restore" : "Maximize"}+ className="h-8 w-8"+ >+ {isMaximized ? <Copy size={14} /> : <Square size={12} />}+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={handleClose}+ className="h-8 w-8 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-950"+ title="Close"+ >+ <X size={14} />+ </Button>+ </div>+ );+}diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.jsindex e7ef8a8e6..6b0dedcce 100644--- a/src/helpers/clipboard.js+++ b/src/helpers/clipboard.js@@ -1,5 +1,5 @@const { clipboard } = require("electron");-const { spawn } = require("child_process");+const { spawn, spawnSync } = require("child_process");class ClipboardManager {constructor() {@@ -155,33 +155,100 @@ class ClipboardManager {}async pasteLinux(originalClipboard) {- return new Promise((resolve, reject) => {- const pasteProcess = spawn("xdotool", ["key", "ctrl+v"]);+ // Helper to check if a command exists+ const commandExists = (cmd) => {+ try {+ const res = spawnSync("sh", ["-c", `command -v ${cmd}`], {+ stdio: "ignore",+ });+ return res.status === 0;+ } catch {+ return false;+ }+ };- pasteProcess.on("close", (code) => {- if (code === 0) {- // Text pasted successfully- setTimeout(() => {- clipboard.writeText(originalClipboard);- }, 100);- resolve();- } else {- reject(- new Error(- `Linux paste failed with code ${code}. Text is copied to clipboard.`- )- );- }+ // Detect if running on Wayland or X11+ const isWayland =+ (process.env.XDG_SESSION_TYPE || "").toLowerCase() === "wayland" ||+ !!process.env.WAYLAND_DISPLAY;++ // Define paste tools in preference order based on display server+ const candidates = isWayland+ ? [+ // Wayland tools+ { cmd: "wtype", args: ["-M", "ctrl", "-p", "v", "-m", "ctrl"] },+ // ydotool requires uinput permissions but included as fallback+ { cmd: "ydotool", args: ["key", "29:1", "47:1", "47:0", "29:0"] },+ // X11 fallback for XWayland+ { cmd: "xdotool", args: ["key", "ctrl+v"] },+ ]+ : [+ // X11 tools+ { cmd: "xdotool", args: ["key", "ctrl+v"] },+ ];++ // Filter to only available tools+ const available = candidates.filter((c) => commandExists(c.cmd));++ // Attempt paste with a specific tool+ const pasteWith = (tool) =>+ new Promise((resolve, reject) => {+ const proc = spawn(tool.cmd, tool.args);++ let timedOut = false;+ const timeoutId = setTimeout(() => {+ timedOut = true;+ try {+ proc.kill("SIGKILL");+ } catch {+ // Ignore kill errors+ }+ }, 1000);++ proc.on("close", (code) => {+ if (timedOut)+ return reject(+ new Error(`Paste with ${tool.cmd} timed out after 1 second`)+ );+ clearTimeout(timeoutId);++ if (code === 0) {+ // Restore original clipboard after successful paste+ setTimeout(() => clipboard.writeText(originalClipboard), 100);+ resolve();+ } else {+ reject(new Error(`${tool.cmd} exited with code ${code}`));+ }+ });++ proc.on("error", (error) => {+ if (timedOut) return;+ clearTimeout(timeoutId);+ reject(error);+ });});- pasteProcess.on("error", (error) => {- reject(- new Error(- `Linux paste failed: ${error.message}. Text is copied to clipboard.`- )+ // Try each available tool in order+ for (const tool of available) {+ try {+ await pasteWith(tool);+ this.safeLog(`✅ Paste successful using ${tool.cmd}`);+ return; // Success!+ } catch (error) {+ this.safeLog(+ `⚠️ Paste with ${tool.cmd} failed:`,+ error?.message || error);- });- });+ // Continue to next tool+ }+ }++ // All tools failed - create specific error for renderer to handle+ const sessionInfo = isWayland ? "Wayland" : "X11";+ const errorMsg = `Clipboard copied, but paste simulation failed on ${sessionInfo}. Please install ${isWayland ? "wtype or ydotool" : "xdotool"} for automatic pasting, or paste manually with Ctrl+V.`;+ const err = new Error(errorMsg);+ err.code = "PASTE_SIMULATION_FAILED";+ throw err;}async checkAccessibilityPermissions() {