← Whispering

feat: Add launcher scripts for both UI versions

d354be6652d37f553d13f53e881ab3ef2ee5ef1e · Claude · Dec 1, 2025 20:09

- Add run_nicegui.sh and run_nicegui.py for NiceGUI interface
- Add run_tkinter.sh and run_tkinter.py for legacy tkinter interface
- All launchers properly set up virtual env, Python path, and audio drivers
- Add scripts/README.md documenting all launcher options
- Keep project root clean by placing all launchers in scripts/ directory

+160 · 5 files changed

  • scripts/README.md +54 −0
  • scripts/run_nicegui.py +27 −0
  • scripts/run_nicegui.sh +35 −0
  • scripts/run_tkinter.py +21 −0
  • scripts/run_tkinter.sh +23 −0
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 0000000..6aeb08d
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,54 @@
+# Scripts Directory
+
+This directory contains all launcher and utility scripts for Whispering.
+
+## Launcher Scripts
+
+### NiceGUI Interface (New)
+- **run_nicegui.sh** - Bash launcher for NiceGUI interface
+- **run_nicegui.py** - Python launcher for NiceGUI interface
+
+The NiceGUI interface provides a modern, modular UI with clean separation of concerns.
+
+```bash
+# Bash launcher
+./scripts/run_nicegui.sh
+
+# Or Python launcher
+./scripts/run_nicegui.py
+```
+
+### Tkinter Interface (Legacy)
+- **run.sh** - Original Bash launcher for tkinter interface
+- **run_tkinter.sh** - Alternative Bash launcher for tkinter interface
+- **run_tkinter.py** - Python launcher for tkinter interface
+
+The tkinter interface is the original monolithic GUI.
+
+```bash
+# Original launcher
+./scripts/run.sh
+
+# Or alternative launchers
+./scripts/run_tkinter.sh
+./scripts/run_tkinter.py
+```
+
+## Installation Scripts
+- **install.sh** - Install all dependencies
+
+## Debugging Scripts
+- **debug_env.sh** - Debug environment and dependencies
+
+## Configuration Files
+These files may appear in this directory during runtime:
+- **whispering_settings.json** - Saved application settings
+- **tts_output/** - TTS audio output directory
+
+## Notes
+
+All scripts are designed to be run from anywhere in the project. They automatically:
+1. Detect the project root directory
+2. Activate the virtual environment if present
+3. Set up the Python path
+4. Configure audio drivers for best compatibility
diff --git a/scripts/run_nicegui.py b/scripts/run_nicegui.py
new file mode 100755
index 0000000..c5cc297
--- /dev/null
+++ b/scripts/run_nicegui.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+"""
+Launch script for Whispering with NiceGUI interface
+"""
+
+import sys
+import subprocess
+from pathlib import Path
+
+# Add src to path
+src_dir = Path(__file__).parent / "src"
+sys.path.insert(0, str(src_dir))
+
+# Check if NiceGUI is installed
+try:
+    import nicegui
+    print(f"✓ NiceGUI {nicegui.__version__} found")
+except ImportError:
+    print("✗ Error: NiceGUI is not installed.")
+    print("Please install dependencies:")
+    print("  pip install nicegui pyperclip")
+    sys.exit(1)
+
+# Launch the NiceGUI application
+print("Starting Whispering with NiceGUI interface...")
+from ui.main import main
+main()
diff --git a/scripts/run_nicegui.sh b/scripts/run_nicegui.sh
new file mode 100755
index 0000000..9e660d4
--- /dev/null
+++ b/scripts/run_nicegui.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Run Whispering with NiceGUI interface
+
+# Get the project directory (parent of scripts directory)
+PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+
+# Check if NiceGUI is installed
+if ! python3 -c "import nicegui" 2>/dev/null; then
+    echo "Error: NiceGUI is not installed."
+    echo "Please install dependencies:"
+    echo "  pip install nicegui pyperclip"
+    exit 1
+fi
+
+# Check if pyperclip is installed
+if ! python3 -c "import pyperclip" 2>/dev/null; then
+    echo "Warning: pyperclip is not installed. Copy/Cut features may not work."
+    echo "Install with: pip install pyperclip"
+fi
+
+# Activate virtual environment if it exists
+if [ -d "$PROJECT_DIR/.venv" ]; then
+    source "$PROJECT_DIR/.venv/bin/activate"
+fi
+
+# Prefer PulseAudio/PipeWire over ALSA for audio
+export SDL_AUDIODRIVER=pulse
+
+# Add src to Python path
+export PYTHONPATH="$PROJECT_DIR/src:$PYTHONPATH"
+
+# Change to src directory and run
+cd "$PROJECT_DIR/src"
+echo "Starting Whispering with NiceGUI interface..."
+python3 -m ui.main "$@"
diff --git a/scripts/run_tkinter.py b/scripts/run_tkinter.py
new file mode 100755
index 0000000..0621cc5
--- /dev/null
+++ b/scripts/run_tkinter.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+"""
+Launch script for Whispering with tkinter interface (legacy)
+"""
+
+import sys
+from pathlib import Path
+
+# Add src to path
+src_dir = Path(__file__).parent / "src"
+sys.path.insert(0, str(src_dir))
+
+# Launch the tkinter GUI
+print("Starting Whispering with tkinter interface...")
+from gui import App
+
+if __name__ == "__main__":
+    try:
+        App().mainloop()
+    except KeyboardInterrupt:
+        pass
diff --git a/scripts/run_tkinter.sh b/scripts/run_tkinter.sh
new file mode 100755
index 0000000..8bd8645
--- /dev/null
+++ b/scripts/run_tkinter.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Run Whispering with tkinter interface (legacy)
+
+# Get the project directory (parent of scripts directory)
+PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+
+# Activate virtual environment if it exists
+if [ -d "$PROJECT_DIR/.venv" ]; then
+    source "$PROJECT_DIR/.venv/bin/activate"
+fi
+
+# Prefer PulseAudio/PipeWire over ALSA for audio
+export SDL_AUDIODRIVER=pulse
+
+# Add src to Python path
+export PYTHONPATH="$PROJECT_DIR/src:$PYTHONPATH"
+
+# Change to src directory and run
+cd "$PROJECT_DIR/src"
+echo "Starting Whispering with tkinter interface..."
+
+# Filter ALSA noise
+python3 gui.py "$@" 2> >(grep -v "^ALSA lib\|^Expression '" >&2)