mirror of
https://github.com/jahruz67/wisp-open.git
synced 2026-08-08 18:14:08 +00:00
DUMP
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# wis-free-v3
|
||||
|
||||
A high-performance, native Windows voice dictation application built in Go using the Wails framework. **wis-free-v3** provides instant speech-to-text with AI-powered refinement, operating as a background service with global hotkey support.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
- **Blazing Fast**: Native implementation ensures zero lag during recording and transcription.
|
||||
- **Global Accessibility**: Trigger from anywhere via configurable global hotkeys.
|
||||
- **AI-Powered Refinement**: Integrates Groq (Whisper + Llama) for intelligent punctuation and grammar fixing.
|
||||
- **Offline Capability**: Supports local Whisper.cpp for sensitive or offline workflows.
|
||||
- **Micro-Automation**: Automatically pastes transcribed text directly into your active window.
|
||||
- **Ultra-Leighton**: Low memory footprint while running in the system tray.
|
||||
|
||||
## 📂 Project Structure
|
||||
|
||||
```text
|
||||
.
|
||||
├── assets/ # Branding and icons
|
||||
├── build/ # Wails build artifacts and manifests
|
||||
├── frontend/ # Svelte/Vue/React settings UI
|
||||
├── internal/ # Private application logic
|
||||
│ ├── audio/ # Sound capture and processing
|
||||
│ ├── config/ # Persistent configuration management
|
||||
│ ├── hotkey/ # Global keyboard hooks
|
||||
│ ├── logger/ # Structured logging utilities
|
||||
│ ├── services/ # Cloud and local AI providers
|
||||
│ ├── system/ # Windows OS integration (Startup/Tray)
|
||||
│ └── ui/ # Native overlay and window management
|
||||
├── scripts/ # Development and deployment automation
|
||||
├── app.go # Application lifecycle management
|
||||
├── main.go # Entry point
|
||||
└── wails.json # Project configuration
|
||||
```
|
||||
|
||||
## 🛠️ Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Go**: 1.23 or higher
|
||||
- **Wails CLI**: `go install github.com/wailsapp/wails/v2/cmd/wails@latest`
|
||||
- **Compiler**: GCC (TDM-GCC recommended for Windows)
|
||||
|
||||
### Installation & Build
|
||||
|
||||
1. Clone the repository.
|
||||
2. Run the build script:
|
||||
```powershell
|
||||
.\scripts\build.bat
|
||||
```
|
||||
3. The executable will be available in `build\bin/wis-free-v3.exe`.
|
||||
|
||||
## ⚙️ Configuration
|
||||
|
||||
Settings are managed via the built-in UI (Right-click tray → Settings) or manually in `%USERPROFILE%\.wis-free-v3\config.json`.
|
||||
|
||||
```json
|
||||
{
|
||||
"api_key": "gsk_...",
|
||||
"shortcut": "alt+z",
|
||||
"whisper_model": "whisper-large-v3-turbo",
|
||||
"ai_model": "llama-3.3-70b-versatile"
|
||||
}
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
This project is maintained with a focus on code quality and modular architecture. Please ensure all logic remains within the `internal/` package to maintain clean boundaries.
|
||||
|
||||
## 📄 License
|
||||
|
||||
Distributed under the MIT License. See `LICENSE` for more information.
|
||||
@@ -0,0 +1,560 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"wis-free-v3/internal/audio/media"
|
||||
"wis-free-v3/internal/audio/recorder"
|
||||
"wis-free-v3/internal/config"
|
||||
"wis-free-v3/internal/hotkey"
|
||||
"wis-free-v3/internal/logger"
|
||||
"wis-free-v3/internal/services/transcriber"
|
||||
"wis-free-v3/internal/services/whisper"
|
||||
"wis-free-v3/internal/system/startup"
|
||||
"wis-free-v3/internal/ui/overlay"
|
||||
"wis-free-v3/internal/ui/tray"
|
||||
|
||||
"github.com/go-vgo/robotgo"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"golang.design/x/clipboard"
|
||||
)
|
||||
|
||||
// App struct
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
audioRecorder *recorder.AudioRecorder
|
||||
hotkeyListener *hotkey.Listener
|
||||
transcriber *transcriber.Client
|
||||
config *config.Config
|
||||
overlay *overlay.Overlay
|
||||
recordingPath string
|
||||
isQuitting bool
|
||||
wasMediaPlaying bool
|
||||
whisperManager *whisper.Manager
|
||||
}
|
||||
|
||||
// NewApp creates a new App application struct
|
||||
func NewApp() *App {
|
||||
return &App{}
|
||||
}
|
||||
|
||||
// GetConfig returns the app configuration
|
||||
func (a *App) GetConfig() *config.Config {
|
||||
return a.config
|
||||
}
|
||||
|
||||
// ShowSettings shows the settings window
|
||||
func (a *App) ShowSettings() {
|
||||
if a.ctx != nil {
|
||||
runtime.WindowShow(a.ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// startup is called when the app starts
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
|
||||
// Initialize components
|
||||
a.startupHeadless()
|
||||
|
||||
// Start system tray in a goroutine
|
||||
go tray.Start(a)
|
||||
}
|
||||
|
||||
// beforeClose is called when the window is about to close
|
||||
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
|
||||
if a.isQuitting {
|
||||
return false
|
||||
}
|
||||
runtime.WindowHide(ctx)
|
||||
return true
|
||||
}
|
||||
|
||||
// Quit handles application exit from tray
|
||||
func (a *App) Quit() {
|
||||
a.isQuitting = true
|
||||
logger.Info("Application quitting...")
|
||||
logger.Close()
|
||||
runtime.Quit(a.ctx)
|
||||
}
|
||||
|
||||
// StartRecording starts the audio recording
|
||||
func (a *App) StartRecording() {
|
||||
logger.Info("StartRecording triggered")
|
||||
|
||||
// Pause media if playing
|
||||
a.wasMediaPlaying = media.PauseMedia()
|
||||
if a.wasMediaPlaying {
|
||||
logger.Info("Media paused for recording")
|
||||
}
|
||||
|
||||
tray.UpdateStatus("Recording...")
|
||||
if a.overlay != nil {
|
||||
a.overlay.Show("Recording...")
|
||||
}
|
||||
|
||||
if a.audioRecorder == nil {
|
||||
logger.Error("Recorder not initialized")
|
||||
tray.UpdateStatus("Ready")
|
||||
if a.overlay != nil {
|
||||
a.overlay.Hide()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Save to a temporary file
|
||||
tempDir := os.TempDir()
|
||||
timestamp := time.Now().Format("20060102_150405")
|
||||
a.recordingPath = filepath.Join(tempDir, fmt.Sprintf("wis_recording_%s.wav", timestamp))
|
||||
|
||||
err := a.audioRecorder.Start(a.recordingPath)
|
||||
if err != nil {
|
||||
logger.Error("Failed to start recording with primary device: %v", err)
|
||||
|
||||
// IDIOT-PROOFING: Fallback to default microphone if the selected one fails
|
||||
if a.config.MicrophoneDevice != nil {
|
||||
logger.Info("Attempting fallback to default microphone...")
|
||||
a.audioRecorder.SetDevice("") // Reset to default
|
||||
err = a.audioRecorder.Start(a.recordingPath)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Error("Recording completely failed: %v", err)
|
||||
tray.UpdateStatus("Ready")
|
||||
if a.overlay != nil {
|
||||
a.overlay.Hide()
|
||||
}
|
||||
// Resume media if we paused it
|
||||
media.ResumeMedia(a.wasMediaPlaying)
|
||||
return
|
||||
}
|
||||
logger.Info("Fallback successful - using default microphone")
|
||||
}
|
||||
}
|
||||
|
||||
// StopRecording stops the audio recording and triggers transcription
|
||||
func (a *App) StopRecording() {
|
||||
logger.Info("StopRecording triggered")
|
||||
|
||||
// Resume media if it was playing before
|
||||
media.ResumeMedia(a.wasMediaPlaying)
|
||||
if a.wasMediaPlaying {
|
||||
logger.Info("Media resumed after recording")
|
||||
}
|
||||
|
||||
if a.audioRecorder == nil {
|
||||
return
|
||||
}
|
||||
|
||||
err := a.audioRecorder.Stop()
|
||||
if err != nil {
|
||||
logger.Error("Failed to stop recording: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Transcribe in a goroutine to avoid blocking
|
||||
go a.processRecording()
|
||||
}
|
||||
|
||||
// processRecording handles transcription and pasting
|
||||
func (a *App) processRecording() {
|
||||
if a.recordingPath == "" {
|
||||
logger.Error("No recording path set")
|
||||
tray.UpdateStatus("Ready")
|
||||
if a.overlay != nil {
|
||||
a.overlay.Hide()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info("Transcribing audio...")
|
||||
tray.UpdateStatus("Transcribing...")
|
||||
if a.overlay != nil {
|
||||
a.overlay.Show("Transcribing...")
|
||||
}
|
||||
|
||||
var text string
|
||||
var err error
|
||||
|
||||
// Check if using local whisper
|
||||
isLocal := strings.HasPrefix(a.config.WhisperModel, "local-")
|
||||
|
||||
// IDIOT-PROOFING: Validate API key before attempting cloud transcription
|
||||
if !isLocal && !strings.HasPrefix(a.config.APIKey, "gsk_") {
|
||||
err = fmt.Errorf("invalid API key - must start with gsk_")
|
||||
} else if isLocal {
|
||||
// Use local whisper.cpp
|
||||
if a.whisperManager == nil {
|
||||
var mgrErr error
|
||||
a.whisperManager, mgrErr = whisper.NewManager()
|
||||
if mgrErr != nil {
|
||||
logger.Error("Failed to create whisper manager: %v", mgrErr)
|
||||
err = mgrErr
|
||||
}
|
||||
}
|
||||
|
||||
if a.whisperManager != nil {
|
||||
text, err = a.whisperManager.Transcribe(a.recordingPath)
|
||||
}
|
||||
} else {
|
||||
// Use cloud API
|
||||
text, err = a.transcriber.TranscribeAudio(a.recordingPath, a.config.Language)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Error("Transcription failed: %v", err)
|
||||
tray.UpdateStatus("Ready")
|
||||
if a.overlay != nil {
|
||||
a.overlay.Hide()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info("Transcribed: %s", text)
|
||||
|
||||
// Refine text (optional)
|
||||
refinedText, err := a.transcriber.RefineText(text)
|
||||
if err != nil {
|
||||
logger.Error("Refinement failed: %v", err)
|
||||
// Fallback to original text
|
||||
refinedText = text
|
||||
} else {
|
||||
logger.Info("Refined: %s", refinedText)
|
||||
}
|
||||
|
||||
// Save to history
|
||||
historyItem := config.HistoryItem{
|
||||
Text: refinedText,
|
||||
Timestamp: time.Now().Format(time.RFC3339),
|
||||
}
|
||||
// Prepend to history
|
||||
a.config.History = append([]config.HistoryItem{historyItem}, a.config.History...)
|
||||
// Keep only last 50 items
|
||||
if len(a.config.History) > 50 {
|
||||
a.config.History = a.config.History[:50]
|
||||
}
|
||||
config.Save(a.config, "")
|
||||
|
||||
// Copy to clipboard
|
||||
clipboard.Write(clipboard.FmtText, []byte(refinedText))
|
||||
|
||||
// Paste
|
||||
a.pasteText()
|
||||
|
||||
// Clean up the recording file
|
||||
os.Remove(a.recordingPath)
|
||||
logger.Info("Processing complete!")
|
||||
tray.UpdateStatus("Ready")
|
||||
|
||||
// Hide overlay after a short delay
|
||||
time.Sleep(1 * time.Second)
|
||||
if a.overlay != nil {
|
||||
a.overlay.Hide()
|
||||
}
|
||||
}
|
||||
|
||||
// pasteText simulates Ctrl+V to paste from clipboard
|
||||
func (a *App) pasteText() {
|
||||
// Give a small delay for clipboard to update
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
// Simulate Ctrl+V
|
||||
robotgo.KeyToggle("control", "down")
|
||||
robotgo.KeyTap("v")
|
||||
robotgo.KeyToggle("control", "up")
|
||||
}
|
||||
|
||||
// GetSettings returns the current configuration
|
||||
func (a *App) GetSettings() map[string]interface{} {
|
||||
conf := make(map[string]interface{})
|
||||
conf["api_key"] = a.config.APIKey
|
||||
conf["shortcut"] = a.config.Shortcut
|
||||
conf["whisper_model"] = a.config.WhisperModel
|
||||
conf["ai_model"] = a.config.AIModel
|
||||
conf["ai_prompt"] = a.config.AIPrompt
|
||||
conf["language"] = a.config.Language
|
||||
conf["microphone_device"] = a.config.MicrophoneDevice
|
||||
conf["history"] = a.config.History
|
||||
conf["startup"] = startup.IsInStartup()
|
||||
return conf
|
||||
}
|
||||
|
||||
// SaveSettings updates the configuration
|
||||
func (a *App) SaveSettings(settings map[string]interface{}) string {
|
||||
if val, ok := settings["api_key"].(string); ok {
|
||||
a.config.APIKey = val
|
||||
}
|
||||
if val, ok := settings["shortcut"].(string); ok {
|
||||
// Validate shortcut before applying
|
||||
trigger, _ := hotkey.ParseShortcut(val)
|
||||
if len(trigger) == 0 {
|
||||
logger.Error("Invalid shortcut: %s (rejected)", val)
|
||||
return "Invalid shortcut - must have at least one modifier and a regular key"
|
||||
}
|
||||
|
||||
a.config.Shortcut = val
|
||||
// Update existing listener with new shortcut (hot-swap)
|
||||
if a.hotkeyListener != nil {
|
||||
a.hotkeyListener.UpdateShortcut(val)
|
||||
} else {
|
||||
// Should not happen if app started correctly, but just in case
|
||||
a.hotkeyListener = hotkey.NewListener(val, a.StartRecording, a.StopRecording)
|
||||
a.hotkeyListener.Start()
|
||||
}
|
||||
}
|
||||
if val, ok := settings["whisper_model"].(string); ok {
|
||||
a.config.WhisperModel = val
|
||||
}
|
||||
if val, ok := settings["ai_model"].(string); ok {
|
||||
a.config.AIModel = val
|
||||
}
|
||||
if val, ok := settings["ai_prompt"].(string); ok {
|
||||
a.config.AIPrompt = val
|
||||
}
|
||||
if val, ok := settings["language"].(string); ok {
|
||||
a.config.Language = val
|
||||
}
|
||||
if val, ok := settings["microphone_device"]; ok {
|
||||
if val == nil {
|
||||
a.config.MicrophoneDevice = nil
|
||||
} else {
|
||||
// Handle float64 from JSON/JS
|
||||
if f, ok := val.(float64); ok {
|
||||
i := int(f)
|
||||
a.config.MicrophoneDevice = &i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save to file
|
||||
config.Save(a.config, "")
|
||||
|
||||
// Re-init transcriber with new settings
|
||||
a.transcriber = transcriber.NewClient(
|
||||
a.config.APIKey,
|
||||
a.config.WhisperModel,
|
||||
a.config.AIModel,
|
||||
a.config.AIPrompt,
|
||||
)
|
||||
|
||||
logger.Info("Settings saved")
|
||||
return "Settings saved successfully"
|
||||
}
|
||||
|
||||
// GetMicrophones returns available microphone devices
|
||||
func (a *App) GetMicrophones() []map[string]interface{} {
|
||||
var result []map[string]interface{}
|
||||
|
||||
if a.audioRecorder != nil {
|
||||
mics, err := a.audioRecorder.GetMicrophones()
|
||||
if err != nil {
|
||||
logger.Error("Failed to enumerate microphones: %v", err)
|
||||
} else {
|
||||
for i, mic := range mics {
|
||||
result = append(result, map[string]interface{}{
|
||||
"index": i - 1, // -1 for default, 0+ for specific devices
|
||||
"name": mic.Name,
|
||||
"id": mic.ID,
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to just default
|
||||
return []map[string]interface{}{
|
||||
{"index": -1, "name": "System Default", "id": ""},
|
||||
}
|
||||
}
|
||||
|
||||
// ToggleStartup toggles Windows startup status
|
||||
func (a *App) ToggleStartup(enable bool) string {
|
||||
var err error
|
||||
if enable {
|
||||
err = startup.AddToStartup()
|
||||
} else {
|
||||
err = startup.RemoveFromStartup()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Error("Startup toggle error: %v", err)
|
||||
return fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
return "Success"
|
||||
}
|
||||
|
||||
// ClearHistory clears the transcription history
|
||||
func (a *App) ClearHistory() {
|
||||
a.config.History = []config.HistoryItem{}
|
||||
config.Save(a.config, "")
|
||||
logger.Info("History cleared")
|
||||
}
|
||||
|
||||
// startupHeadless initializes the app without Wails context
|
||||
func (a *App) startupHeadless() {
|
||||
// Initialize Logger
|
||||
err := logger.Init()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to initialize logger: %v\n", err)
|
||||
}
|
||||
|
||||
// Initialize clipboard
|
||||
err = clipboard.Init()
|
||||
if err != nil {
|
||||
logger.Error("Failed to initialize clipboard: %v", err)
|
||||
}
|
||||
|
||||
// Load configuration
|
||||
configPath, err := config.GetConfigPath()
|
||||
if err != nil {
|
||||
logger.Error("Failed to get config path: %v", err)
|
||||
a.config = config.DefaultConfig()
|
||||
} else {
|
||||
a.config, err = config.Load(configPath)
|
||||
if err != nil {
|
||||
logger.Error("Failed to load config: %v", err)
|
||||
a.config = config.DefaultConfig()
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize heavy components in background for instant startup
|
||||
go func() {
|
||||
// Initialize transcriber
|
||||
a.transcriber = transcriber.NewClient(
|
||||
a.config.APIKey,
|
||||
a.config.WhisperModel,
|
||||
a.config.AIModel,
|
||||
a.config.AIPrompt,
|
||||
)
|
||||
|
||||
// Initialize whisper manager
|
||||
a.whisperManager, _ = whisper.NewManager()
|
||||
|
||||
// Initialize Audio Recorder
|
||||
rec, err := recorder.NewRecorder()
|
||||
if err != nil {
|
||||
logger.Error("Error initializing recorder: %v", err)
|
||||
} else {
|
||||
a.audioRecorder = rec
|
||||
}
|
||||
|
||||
// Initialize Overlay
|
||||
a.overlay = overlay.NewOverlay()
|
||||
|
||||
// Connect volume feedback from recorder to overlay
|
||||
if a.audioRecorder != nil && a.overlay != nil {
|
||||
a.audioRecorder.OnVolume = func(level float64) {
|
||||
a.overlay.SetVolume(level)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize Hotkey Listener
|
||||
a.hotkeyListener = hotkey.NewListener(a.config.Shortcut, a.StartRecording, a.StopRecording)
|
||||
a.hotkeyListener.Start()
|
||||
|
||||
logger.Info("Background components initialized successfully!")
|
||||
}()
|
||||
|
||||
logger.Info("Basic app components loaded, continuing startup...")
|
||||
}
|
||||
|
||||
// Shutdown cleans up resources
|
||||
func (a *App) Shutdown(ctx context.Context) {
|
||||
if a.hotkeyListener != nil {
|
||||
a.hotkeyListener.Stop()
|
||||
}
|
||||
if a.audioRecorder != nil {
|
||||
a.audioRecorder.Cleanup()
|
||||
}
|
||||
if a.overlay != nil {
|
||||
a.overlay.Close()
|
||||
}
|
||||
logger.Close()
|
||||
}
|
||||
|
||||
// Greet returns a greeting for the given name (for frontend testing)
|
||||
func (a *App) Greet(name string) string {
|
||||
return fmt.Sprintf("Hello %s, It's show time!", name)
|
||||
}
|
||||
|
||||
// CheckOnline checks if internet connection is available
|
||||
func (a *App) CheckOnline() bool {
|
||||
return whisper.CheckOnline()
|
||||
}
|
||||
|
||||
// IsWhisperInstalled checks if offline whisper is installed
|
||||
func (a *App) IsWhisperInstalled() bool {
|
||||
mgr, err := whisper.NewManager()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return mgr.IsInstalled()
|
||||
}
|
||||
|
||||
// GetWhisperInfo returns information about installed whisper
|
||||
func (a *App) GetWhisperInfo() map[string]interface{} {
|
||||
mgr, err := whisper.NewManager()
|
||||
if err != nil {
|
||||
return map[string]interface{}{"installed": false}
|
||||
}
|
||||
|
||||
if !mgr.IsInstalled() {
|
||||
return map[string]interface{}{"installed": false}
|
||||
}
|
||||
|
||||
info, err := mgr.GetInstalledInfo()
|
||||
if err != nil {
|
||||
return map[string]interface{}{"installed": false}
|
||||
}
|
||||
|
||||
return map[string]interface{}{
|
||||
"installed": true,
|
||||
"model": info.Model,
|
||||
"version": info.Version,
|
||||
}
|
||||
}
|
||||
|
||||
// InstallWhisper starts the whisper installation process
|
||||
func (a *App) InstallWhisper(model string) string {
|
||||
mgr, err := whisper.NewManager()
|
||||
if err != nil {
|
||||
return fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
|
||||
if err := mgr.Install(model); err != nil {
|
||||
return fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
|
||||
return "Installation started - check the terminal window"
|
||||
}
|
||||
|
||||
// UninstallWhisper removes the whisper installation
|
||||
func (a *App) UninstallWhisper() string {
|
||||
mgr, err := whisper.NewManager()
|
||||
if err != nil {
|
||||
return fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
|
||||
if err := mgr.Uninstall(); err != nil {
|
||||
return fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
|
||||
return "Whisper uninstalled successfully"
|
||||
}
|
||||
|
||||
// GetAvailableWhisperModels returns list of available whisper models
|
||||
func (a *App) GetAvailableWhisperModels() []map[string]string {
|
||||
var models []map[string]string
|
||||
for name, info := range whisper.Models {
|
||||
models = append(models, map[string]string{
|
||||
"name": name,
|
||||
"size": info.Size,
|
||||
})
|
||||
}
|
||||
return models
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,35 @@
|
||||
# Build Directory
|
||||
|
||||
The build directory is used to house all the build files and assets for your application.
|
||||
|
||||
The structure is:
|
||||
|
||||
* bin - Output directory
|
||||
* darwin - macOS specific files
|
||||
* windows - Windows specific files
|
||||
|
||||
## Mac
|
||||
|
||||
The `darwin` directory holds files specific to Mac builds.
|
||||
These may be customised and used as part of the build. To return these files to the default state, simply delete them
|
||||
and
|
||||
build with `wails build`.
|
||||
|
||||
The directory contains the following files:
|
||||
|
||||
- `Info.plist` - the main plist file used for Mac builds. It is used when building using `wails build`.
|
||||
- `Info.dev.plist` - same as the main plist file but used when building using `wails dev`.
|
||||
|
||||
## Windows
|
||||
|
||||
The `windows` directory contains the manifest and rc files used when building with `wails build`.
|
||||
These may be customised for your application. To return these files to the default state, simply delete them and
|
||||
build with `wails build`.
|
||||
|
||||
- `icon.ico` - The icon used for the application. This is used when building using `wails build`. If you wish to
|
||||
use a different icon, simply replace this file with your own. If it is missing, a new `icon.ico` file
|
||||
will be created using the `appicon.png` file in the build directory.
|
||||
- `installer/*` - The files used to create the Windows installer. These are used when building using `wails build`.
|
||||
- `info.json` - Application details used for Windows builds. The data here will be used by the Windows installer,
|
||||
as well as the application itself (right click the exe -> properties -> details)
|
||||
- `wails.exe.manifest` - The main application manifest file.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>{{.Info.ProductName}}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{.OutputFilename}}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.wails.{{.Name}}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>{{.Info.Comments}}</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>iconfile</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.13.0</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>true</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>{{.Info.Copyright}}</string>
|
||||
{{if .Info.FileAssociations}}
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
{{range .Info.FileAssociations}}
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>{{.Ext}}</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>{{.Name}}</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>{{.Role}}</string>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>{{.IconName}}</string>
|
||||
</dict>
|
||||
{{end}}
|
||||
</array>
|
||||
{{end}}
|
||||
{{if .Info.Protocols}}
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
{{range .Info.Protocols}}
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.wails.{{.Scheme}}</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>{{.Scheme}}</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>{{.Role}}</string>
|
||||
</dict>
|
||||
{{end}}
|
||||
</array>
|
||||
{{end}}
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsLocalNetworking</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>{{.Info.ProductName}}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{.OutputFilename}}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.wails.{{.Name}}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>{{.Info.Comments}}</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>iconfile</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.13.0</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>true</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>{{.Info.Copyright}}</string>
|
||||
{{if .Info.FileAssociations}}
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
{{range .Info.FileAssociations}}
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>{{.Ext}}</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>{{.Name}}</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>{{.Role}}</string>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>{{.IconName}}</string>
|
||||
</dict>
|
||||
{{end}}
|
||||
</array>
|
||||
{{end}}
|
||||
{{if .Info.Protocols}}
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
{{range .Info.Protocols}}
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.wails.{{.Scheme}}</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>{{.Scheme}}</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>{{.Role}}</string>
|
||||
</dict>
|
||||
{{end}}
|
||||
</array>
|
||||
{{end}}
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"fixed": {
|
||||
"file_version": "{{.Info.ProductVersion}}"
|
||||
},
|
||||
"info": {
|
||||
"0000": {
|
||||
"ProductVersion": "{{.Info.ProductVersion}}",
|
||||
"CompanyName": "{{.Info.CompanyName}}",
|
||||
"FileDescription": "{{.Info.ProductName}}",
|
||||
"LegalCopyright": "{{.Info.Copyright}}",
|
||||
"ProductName": "{{.Info.ProductName}}",
|
||||
"Comments": "{{.Info.Comments}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
Unicode true
|
||||
|
||||
####
|
||||
## Please note: Template replacements don't work in this file. They are provided with default defines like
|
||||
## mentioned underneath.
|
||||
## If the keyword is not defined, "wails_tools.nsh" will populate them with the values from ProjectInfo.
|
||||
## If they are defined here, "wails_tools.nsh" will not touch them. This allows to use this project.nsi manually
|
||||
## from outside of Wails for debugging and development of the installer.
|
||||
##
|
||||
## For development first make a wails nsis build to populate the "wails_tools.nsh":
|
||||
## > wails build --target windows/amd64 --nsis
|
||||
## Then you can call makensis on this file with specifying the path to your binary:
|
||||
## For a AMD64 only installer:
|
||||
## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe
|
||||
## For a ARM64 only installer:
|
||||
## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe
|
||||
## For a installer with both architectures:
|
||||
## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe
|
||||
####
|
||||
## The following information is taken from the ProjectInfo file, but they can be overwritten here.
|
||||
####
|
||||
## !define INFO_PROJECTNAME "MyProject" # Default "{{.Name}}"
|
||||
## !define INFO_COMPANYNAME "MyCompany" # Default "{{.Info.CompanyName}}"
|
||||
## !define INFO_PRODUCTNAME "MyProduct" # Default "{{.Info.ProductName}}"
|
||||
## !define INFO_PRODUCTVERSION "1.0.0" # Default "{{.Info.ProductVersion}}"
|
||||
## !define INFO_COPYRIGHT "Copyright" # Default "{{.Info.Copyright}}"
|
||||
###
|
||||
## !define PRODUCT_EXECUTABLE "Application.exe" # Default "${INFO_PROJECTNAME}.exe"
|
||||
## !define UNINST_KEY_NAME "UninstKeyInRegistry" # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
|
||||
####
|
||||
## !define REQUEST_EXECUTION_LEVEL "admin" # Default "admin" see also https://nsis.sourceforge.io/Docs/Chapter4.html
|
||||
####
|
||||
## Include the wails tools
|
||||
####
|
||||
!include "wails_tools.nsh"
|
||||
|
||||
# The version information for this two must consist of 4 parts
|
||||
VIProductVersion "${INFO_PRODUCTVERSION}.0"
|
||||
VIFileVersion "${INFO_PRODUCTVERSION}.0"
|
||||
|
||||
VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}"
|
||||
VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
|
||||
VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}"
|
||||
VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}"
|
||||
VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}"
|
||||
VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}"
|
||||
|
||||
# Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware
|
||||
ManifestDPIAware true
|
||||
|
||||
!include "MUI.nsh"
|
||||
|
||||
!define MUI_ICON "..\icon.ico"
|
||||
!define MUI_UNICON "..\icon.ico"
|
||||
# !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\leftimage.bmp" #Include this to add a bitmap on the left side of the Welcome Page. Must be a size of 164x314
|
||||
!define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
|
||||
!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
|
||||
|
||||
!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
|
||||
# !insertmacro MUI_PAGE_LICENSE "resources\eula.txt" # Adds a EULA page to the installer
|
||||
!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
|
||||
!insertmacro MUI_PAGE_INSTFILES # Installing page.
|
||||
!insertmacro MUI_PAGE_FINISH # Finished installation page.
|
||||
|
||||
!insertmacro MUI_UNPAGE_INSTFILES # Uinstalling page
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English" # Set the Language of the installer
|
||||
|
||||
## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
|
||||
#!uninstfinalize 'signtool --file "%1"'
|
||||
#!finalize 'signtool --file "%1"'
|
||||
|
||||
Name "${INFO_PRODUCTNAME}"
|
||||
OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
|
||||
InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
|
||||
ShowInstDetails show # This will always show the installation details.
|
||||
|
||||
Function .onInit
|
||||
!insertmacro wails.checkArchitecture
|
||||
FunctionEnd
|
||||
|
||||
Section
|
||||
!insertmacro wails.setShellContext
|
||||
|
||||
!insertmacro wails.webview2runtime
|
||||
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
!insertmacro wails.files
|
||||
|
||||
CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
|
||||
CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
|
||||
|
||||
!insertmacro wails.associateFiles
|
||||
!insertmacro wails.associateCustomProtocols
|
||||
|
||||
!insertmacro wails.writeUninstaller
|
||||
SectionEnd
|
||||
|
||||
Section "uninstall"
|
||||
!insertmacro wails.setShellContext
|
||||
|
||||
RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath
|
||||
|
||||
RMDir /r $INSTDIR
|
||||
|
||||
Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
|
||||
Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"
|
||||
|
||||
!insertmacro wails.unassociateFiles
|
||||
!insertmacro wails.unassociateCustomProtocols
|
||||
|
||||
!insertmacro wails.deleteUninstaller
|
||||
SectionEnd
|
||||
@@ -0,0 +1,249 @@
|
||||
# DO NOT EDIT - Generated automatically by `wails build`
|
||||
|
||||
!include "x64.nsh"
|
||||
!include "WinVer.nsh"
|
||||
!include "FileFunc.nsh"
|
||||
|
||||
!ifndef INFO_PROJECTNAME
|
||||
!define INFO_PROJECTNAME "{{.Name}}"
|
||||
!endif
|
||||
!ifndef INFO_COMPANYNAME
|
||||
!define INFO_COMPANYNAME "{{.Info.CompanyName}}"
|
||||
!endif
|
||||
!ifndef INFO_PRODUCTNAME
|
||||
!define INFO_PRODUCTNAME "{{.Info.ProductName}}"
|
||||
!endif
|
||||
!ifndef INFO_PRODUCTVERSION
|
||||
!define INFO_PRODUCTVERSION "{{.Info.ProductVersion}}"
|
||||
!endif
|
||||
!ifndef INFO_COPYRIGHT
|
||||
!define INFO_COPYRIGHT "{{.Info.Copyright}}"
|
||||
!endif
|
||||
!ifndef PRODUCT_EXECUTABLE
|
||||
!define PRODUCT_EXECUTABLE "${INFO_PROJECTNAME}.exe"
|
||||
!endif
|
||||
!ifndef UNINST_KEY_NAME
|
||||
!define UNINST_KEY_NAME "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
|
||||
!endif
|
||||
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINST_KEY_NAME}"
|
||||
|
||||
!ifndef REQUEST_EXECUTION_LEVEL
|
||||
!define REQUEST_EXECUTION_LEVEL "admin"
|
||||
!endif
|
||||
|
||||
RequestExecutionLevel "${REQUEST_EXECUTION_LEVEL}"
|
||||
|
||||
!ifdef ARG_WAILS_AMD64_BINARY
|
||||
!define SUPPORTS_AMD64
|
||||
!endif
|
||||
|
||||
!ifdef ARG_WAILS_ARM64_BINARY
|
||||
!define SUPPORTS_ARM64
|
||||
!endif
|
||||
|
||||
!ifdef SUPPORTS_AMD64
|
||||
!ifdef SUPPORTS_ARM64
|
||||
!define ARCH "amd64_arm64"
|
||||
!else
|
||||
!define ARCH "amd64"
|
||||
!endif
|
||||
!else
|
||||
!ifdef SUPPORTS_ARM64
|
||||
!define ARCH "arm64"
|
||||
!else
|
||||
!error "Wails: Undefined ARCH, please provide at least one of ARG_WAILS_AMD64_BINARY or ARG_WAILS_ARM64_BINARY"
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!macro wails.checkArchitecture
|
||||
!ifndef WAILS_WIN10_REQUIRED
|
||||
!define WAILS_WIN10_REQUIRED "This product is only supported on Windows 10 (Server 2016) and later."
|
||||
!endif
|
||||
|
||||
!ifndef WAILS_ARCHITECTURE_NOT_SUPPORTED
|
||||
!define WAILS_ARCHITECTURE_NOT_SUPPORTED "This product can't be installed on the current Windows architecture. Supports: ${ARCH}"
|
||||
!endif
|
||||
|
||||
${If} ${AtLeastWin10}
|
||||
!ifdef SUPPORTS_AMD64
|
||||
${if} ${IsNativeAMD64}
|
||||
Goto ok
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
!ifdef SUPPORTS_ARM64
|
||||
${if} ${IsNativeARM64}
|
||||
Goto ok
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
IfSilent silentArch notSilentArch
|
||||
silentArch:
|
||||
SetErrorLevel 65
|
||||
Abort
|
||||
notSilentArch:
|
||||
MessageBox MB_OK "${WAILS_ARCHITECTURE_NOT_SUPPORTED}"
|
||||
Quit
|
||||
${else}
|
||||
IfSilent silentWin notSilentWin
|
||||
silentWin:
|
||||
SetErrorLevel 64
|
||||
Abort
|
||||
notSilentWin:
|
||||
MessageBox MB_OK "${WAILS_WIN10_REQUIRED}"
|
||||
Quit
|
||||
${EndIf}
|
||||
|
||||
ok:
|
||||
!macroend
|
||||
|
||||
!macro wails.files
|
||||
!ifdef SUPPORTS_AMD64
|
||||
${if} ${IsNativeAMD64}
|
||||
File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_AMD64_BINARY}"
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
!ifdef SUPPORTS_ARM64
|
||||
${if} ${IsNativeARM64}
|
||||
File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_ARM64_BINARY}"
|
||||
${EndIf}
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro wails.writeUninstaller
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
|
||||
SetRegView 64
|
||||
WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "${INFO_COMPANYNAME}"
|
||||
WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${INFO_PRODUCTNAME}"
|
||||
WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${INFO_PRODUCTVERSION}"
|
||||
WriteRegStr HKLM "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXECUTABLE}"
|
||||
WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
||||
WriteRegStr HKLM "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
|
||||
|
||||
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
|
||||
IntFmt $0 "0x%08X" $0
|
||||
WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" "$0"
|
||||
!macroend
|
||||
|
||||
!macro wails.deleteUninstaller
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
|
||||
SetRegView 64
|
||||
DeleteRegKey HKLM "${UNINST_KEY}"
|
||||
!macroend
|
||||
|
||||
!macro wails.setShellContext
|
||||
${If} ${REQUEST_EXECUTION_LEVEL} == "admin"
|
||||
SetShellVarContext all
|
||||
${else}
|
||||
SetShellVarContext current
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
# Install webview2 by launching the bootstrapper
|
||||
# See https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#online-only-deployment
|
||||
!macro wails.webview2runtime
|
||||
!ifndef WAILS_INSTALL_WEBVIEW_DETAILPRINT
|
||||
!define WAILS_INSTALL_WEBVIEW_DETAILPRINT "Installing: WebView2 Runtime"
|
||||
!endif
|
||||
|
||||
SetRegView 64
|
||||
# If the admin key exists and is not empty then webview2 is already installed
|
||||
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||
${If} $0 != ""
|
||||
Goto ok
|
||||
${EndIf}
|
||||
|
||||
${If} ${REQUEST_EXECUTION_LEVEL} == "user"
|
||||
# If the installer is run in user level, check the user specific key exists and is not empty then webview2 is already installed
|
||||
ReadRegStr $0 HKCU "Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||
${If} $0 != ""
|
||||
Goto ok
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
SetDetailsPrint both
|
||||
DetailPrint "${WAILS_INSTALL_WEBVIEW_DETAILPRINT}"
|
||||
SetDetailsPrint listonly
|
||||
|
||||
InitPluginsDir
|
||||
CreateDirectory "$pluginsdir\webview2bootstrapper"
|
||||
SetOutPath "$pluginsdir\webview2bootstrapper"
|
||||
File "tmp\MicrosoftEdgeWebview2Setup.exe"
|
||||
ExecWait '"$pluginsdir\webview2bootstrapper\MicrosoftEdgeWebview2Setup.exe" /silent /install'
|
||||
|
||||
SetDetailsPrint both
|
||||
ok:
|
||||
!macroend
|
||||
|
||||
# Copy of APP_ASSOCIATE and APP_UNASSOCIATE macros from here https://gist.github.com/nikku/281d0ef126dbc215dd58bfd5b3a5cd5b
|
||||
!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
|
||||
; Backup the previously associated file class
|
||||
ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" ""
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "${FILECLASS}_backup" "$R0"
|
||||
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "${FILECLASS}"
|
||||
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}" "" `${DESCRIPTION}`
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\DefaultIcon" "" `${ICON}`
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell" "" "open"
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open\command" "" `${COMMAND}`
|
||||
!macroend
|
||||
|
||||
!macro APP_UNASSOCIATE EXT FILECLASS
|
||||
; Backup the previously associated file class
|
||||
ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" `${FILECLASS}_backup`
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "$R0"
|
||||
|
||||
DeleteRegKey SHELL_CONTEXT `Software\Classes\${FILECLASS}`
|
||||
!macroend
|
||||
|
||||
!macro wails.associateFiles
|
||||
; Create file associations
|
||||
{{range .Info.FileAssociations}}
|
||||
!insertmacro APP_ASSOCIATE "{{.Ext}}" "{{.Name}}" "{{.Description}}" "$INSTDIR\{{.IconName}}.ico" "Open with ${INFO_PRODUCTNAME}" "$INSTDIR\${PRODUCT_EXECUTABLE} $\"%1$\""
|
||||
|
||||
File "..\{{.IconName}}.ico"
|
||||
{{end}}
|
||||
!macroend
|
||||
|
||||
!macro wails.unassociateFiles
|
||||
; Delete app associations
|
||||
{{range .Info.FileAssociations}}
|
||||
!insertmacro APP_UNASSOCIATE "{{.Ext}}" "{{.Name}}"
|
||||
|
||||
Delete "$INSTDIR\{{.IconName}}.ico"
|
||||
{{end}}
|
||||
!macroend
|
||||
|
||||
!macro CUSTOM_PROTOCOL_ASSOCIATE PROTOCOL DESCRIPTION ICON COMMAND
|
||||
DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}"
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "" "${DESCRIPTION}"
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "URL Protocol" ""
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\DefaultIcon" "" "${ICON}"
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell" "" ""
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open" "" ""
|
||||
WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open\command" "" "${COMMAND}"
|
||||
!macroend
|
||||
|
||||
!macro CUSTOM_PROTOCOL_UNASSOCIATE PROTOCOL
|
||||
DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}"
|
||||
!macroend
|
||||
|
||||
!macro wails.associateCustomProtocols
|
||||
; Create custom protocols associations
|
||||
{{range .Info.Protocols}}
|
||||
!insertmacro CUSTOM_PROTOCOL_ASSOCIATE "{{.Scheme}}" "{{.Description}}" "$INSTDIR\${PRODUCT_EXECUTABLE},0" "$INSTDIR\${PRODUCT_EXECUTABLE} $\"%1$\""
|
||||
|
||||
{{end}}
|
||||
!macroend
|
||||
|
||||
!macro wails.unassociateCustomProtocols
|
||||
; Delete app custom protocol associations
|
||||
{{range .Info.Protocols}}
|
||||
!insertmacro CUSTOM_PROTOCOL_UNASSOCIATE "{{.Scheme}}"
|
||||
{{end}}
|
||||
!macroend
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<assemblyIdentity type="win32" name="com.wails.{{.Name}}" version="{{.Info.ProductVersion}}.0" processorArchitecture="*"/>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
||||
@@ -0,0 +1,499 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
||||
<title>wis-free-v3 Settings</title>
|
||||
<link rel="stylesheet" href="./src/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app" class="container">
|
||||
<!-- Header -->
|
||||
<div class="flex-between" style="margin-bottom: 30px;">
|
||||
<h1 style="margin: 0;">wis-free-v3 Settings</h1>
|
||||
<div style="color: var(--text-muted); font-size: 12px;">v1.0.0</div>
|
||||
</div>
|
||||
|
||||
<div id="saveStatus" class="save-status">Settings Saved!</div>
|
||||
|
||||
<!-- Settings Form -->
|
||||
<div id="settingsForm">
|
||||
|
||||
<!-- API Key -->
|
||||
<div class="section">
|
||||
<label>Groq API Key</label>
|
||||
<div class="form-control">
|
||||
<div class="flex-row">
|
||||
<div class="input-wrapper">
|
||||
<input type="password" id="apiKey" placeholder="gsk_...">
|
||||
<button class="eye-btn" onclick="toggleApiKey()" id="eyeBtn">👁️</button>
|
||||
</div>
|
||||
<button onclick="saveApiKey()">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
<p style="font-size: 12px; color: var(--text-muted); margin-top: 8px;">
|
||||
Get your free API key at <a href="https://console.groq.com/keys" target="_blank"
|
||||
style="color: var(--primary);">console.groq.com/keys</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Shortcut -->
|
||||
<div class="section">
|
||||
<label>Shortcut (Hold to Record)</label>
|
||||
<div class="form-control">
|
||||
<div class="flex-row">
|
||||
<div class="input-wrapper">
|
||||
<input type="text" id="shortcutInput" placeholder="Click Record to set..." readonly>
|
||||
</div>
|
||||
<button onclick="recordShortcut()" id="recordBtn">Record</button>
|
||||
</div>
|
||||
</div>
|
||||
<p style="font-size: 12px; color: var(--text-muted); margin-top: 8px;">
|
||||
Click Record, then press your desired key combination (e.g., Ctrl+X)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Whisper Model -->
|
||||
<div class="section">
|
||||
<label>Whisper Model</label>
|
||||
<select id="whisperModel" onchange="saveWhisperModel()" class="form-control">
|
||||
<option value="whisper-large-v3-turbo">whisper-large-v3-turbo (Recommended)</option>
|
||||
<option value="whisper-large-v3">whisper-large-v3</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="section">
|
||||
<label>Transcription Language</label>
|
||||
<select id="language" onchange="saveLanguage()" class="form-control">
|
||||
<option value="en">English (en)</option>
|
||||
<option value="es">Spanish (es)</option>
|
||||
</select>
|
||||
<p style="font-size: 11px; color: var(--text-muted); margin-top: 5px;">Specifying language reduces latency and improves accuracy.</p>
|
||||
</div>
|
||||
|
||||
<!-- AI Model -->
|
||||
<div class="section">
|
||||
<label>AI Model (Text Refinement)</label>
|
||||
<select id="aiModel" onchange="saveAiModel()" class="form-control">
|
||||
<option value="None">None (Skip Refinement)</option>
|
||||
<option value="openai/gpt-oss-120b-high">openai/gpt-oss-120b (high reasoning)</option>
|
||||
<option value="openai/gpt-oss-120b">openai/gpt-oss-120b (low reasoning)</option>
|
||||
<option value="openai/gpt-oss-20b-high">openai/gpt-oss-20b (high reasoning)</option>
|
||||
<option value="openai/gpt-oss-20b">openai/gpt-oss-20b (low reasoning)</option>
|
||||
<option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile</option>
|
||||
<option value="llama-3.1-8b-instant">llama-3.1-8b-instant (faster)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Microphone -->
|
||||
<div class="section">
|
||||
<label>Microphone</label>
|
||||
<select id="micDevice" onchange="saveMicDevice()" class="form-control">
|
||||
<option value="default">System Default</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- AI Prompt -->
|
||||
<div class="section">
|
||||
<label>AI Prompt (System Message)</label>
|
||||
<textarea id="aiPrompt" rows="3" placeholder="Custom instructions for text refinement..."
|
||||
class="form-control"></textarea>
|
||||
<div style="text-align: right; margin-top: 10px;">
|
||||
<button onclick="savePrompt()">Save Prompt</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Startup -->
|
||||
<div class="section flex-between">
|
||||
<span style="font-weight: 500;">Run on Windows Startup</span>
|
||||
<label class="flex-row" style="margin: 0; cursor: pointer;">
|
||||
<input type="checkbox" id="startupToggle" onchange="toggleStartup()" style="width: auto;">
|
||||
<span>Enable</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- History -->
|
||||
<div class="section">
|
||||
<div class="flex-between" style="margin-bottom: 10px;">
|
||||
<label style="margin: 0;">Transcription History</label>
|
||||
<button onclick="clearHistory()"
|
||||
style="background: transparent; color: #f87171; padding: 0; font-size: 12px;">Clear</button>
|
||||
</div>
|
||||
<div id="historyList" class="history-list">
|
||||
<div style="text-align: center; color: var(--text-muted); padding: 20px;">No history yet.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Offline Mode -->
|
||||
<div class="section"
|
||||
style="margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border-color);">
|
||||
<label>Offline Whisper</label>
|
||||
|
||||
<!-- Online/Offline Status -->
|
||||
<div id="connectionStatus"
|
||||
style="margin-bottom: 15px; padding: 10px; border-radius: 8px; text-align: center;">
|
||||
Checking connection...
|
||||
</div>
|
||||
|
||||
<!-- Whisper Status -->
|
||||
<div id="whisperSection">
|
||||
<div id="whisperNotInstalled">
|
||||
<p style="font-size: 13px; color: var(--text-muted); margin-bottom: 15px;">
|
||||
Install offline transcription for use without internet. Uses GPU acceleration if available.
|
||||
</p>
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label style="font-size: 12px;">Model Size:</label>
|
||||
<select id="whisperModelSelect" style="margin-top: 5px;" class="form-control">
|
||||
<option value="tiny">Tiny (75 MB) - Fastest</option>
|
||||
<option value="base">Base (150 MB) - Fast</option>
|
||||
<option value="small" selected>Small (500 MB) - Recommended</option>
|
||||
<option value="medium">Medium (1.5 GB) - High Quality</option>
|
||||
</select>
|
||||
</div>
|
||||
<button onclick="installWhisper()" id="installBtn"
|
||||
style="background: linear-gradient(135deg, #6366f1, #8b5cf6); padding: 12px 24px; font-size: 14px; width: 100%;">
|
||||
🚀 Install Offline Whisper
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="whisperInstalled" style="display: none;">
|
||||
<div
|
||||
style="background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); border-radius: 8px; padding: 15px; margin-bottom: 15px;">
|
||||
<div style="color: #22c55e; font-weight: 500;">✓ Offline Whisper Installed</div>
|
||||
<div style="font-size: 12px; color: var(--text-muted); margin-top: 5px;">
|
||||
Model: <span id="installedModel">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<p style="font-size: 12px; color: var(--text-muted); margin-bottom: 15px;">
|
||||
Select "Local - Whisper" in the Whisper Model dropdown above to use offline transcription.
|
||||
</p>
|
||||
<button onclick="uninstallWhisper()"
|
||||
style="background: transparent; border: 1px solid #f87171; color: #f87171; padding: 10px 20px; font-size: 13px;">
|
||||
🗑️ Uninstall Offline Whisper
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
let apiKeyVisible = false;
|
||||
|
||||
// Toggle API key visibility
|
||||
window.toggleApiKey = function () {
|
||||
const input = document.getElementById('apiKey');
|
||||
const btn = document.getElementById('eyeBtn');
|
||||
apiKeyVisible = !apiKeyVisible;
|
||||
input.type = apiKeyVisible ? 'text' : 'password';
|
||||
btn.textContent = apiKeyVisible ? '🙈' : '👁️';
|
||||
};
|
||||
|
||||
// Record shortcut
|
||||
window.recordShortcut = function () {
|
||||
const btn = document.getElementById('recordBtn');
|
||||
const input = document.getElementById('shortcutInput');
|
||||
|
||||
btn.textContent = 'Recording...';
|
||||
btn.disabled = true;
|
||||
input.value = '';
|
||||
|
||||
let lastShortcut = '';
|
||||
|
||||
const keydownHandler = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const mods = [];
|
||||
if (e.ctrlKey) mods.push('ctrl');
|
||||
if (e.altKey) mods.push('alt');
|
||||
if (e.shiftKey) mods.push('shift');
|
||||
if (e.metaKey || e.key === 'Meta' || e.key === 'OS') mods.push('win');
|
||||
|
||||
let key = e.key.toLowerCase();
|
||||
if (key === 'control') key = 'ctrl';
|
||||
if (key === 'alt') key = 'alt';
|
||||
if (key === 'shift') key = 'shift';
|
||||
if (key === 'meta' || key === 'os') key = 'win';
|
||||
if (key === ' ') key = 'space';
|
||||
|
||||
const parts = new Set(mods);
|
||||
parts.add(key);
|
||||
|
||||
// Order them: modifiers first, then the latest key
|
||||
const partsArray = Array.from(parts).filter(p => p !== key);
|
||||
partsArray.push(key);
|
||||
|
||||
lastShortcut = partsArray.join('+');
|
||||
input.value = lastShortcut;
|
||||
|
||||
// Finalize immediately if a non-modifier key is pressed
|
||||
if (!['ctrl', 'alt', 'shift', 'win'].includes(key)) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
const keyupHandler = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Finalize when keys are released if we have a valid shortcut
|
||||
if (lastShortcut) {
|
||||
// Check if it's a modifier-only shortcut that we should finalize
|
||||
const isModifierOnly = lastShortcut.split('+').every(p => ['ctrl', 'alt', 'shift', 'win'].includes(p));
|
||||
if (isModifierOnly && lastShortcut.includes('+')) {
|
||||
// Wait a tiny bit to see if they press another key, but usually release means they are done
|
||||
setTimeout(finish, 100);
|
||||
} else if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const finish = () => {
|
||||
if (!lastShortcut) {
|
||||
btn.textContent = 'Record';
|
||||
btn.disabled = false;
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
window.go.main.App.SaveSettings({ shortcut: lastShortcut }).then(() => {
|
||||
btn.textContent = 'Record';
|
||||
btn.disabled = false;
|
||||
cleanup();
|
||||
});
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
window.removeEventListener('keydown', keydownHandler, true);
|
||||
window.removeEventListener('keyup', keyupHandler, true);
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', keydownHandler, true);
|
||||
window.addEventListener('keyup', keyupHandler, true);
|
||||
};
|
||||
|
||||
// Load settings on page load
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const settings = await window.go.main.App.GetSettings();
|
||||
|
||||
document.getElementById('apiKey').value = settings.api_key || '';
|
||||
document.getElementById('shortcutInput').value = settings.shortcut || 'alt+z';
|
||||
document.getElementById('whisperModel').value = settings.whisper_model || 'whisper-large-v3-turbo';
|
||||
document.getElementById('aiModel').value = settings.ai_model || 'llama-3.3-70b-versatile';
|
||||
document.getElementById('aiPrompt').value = settings.ai_prompt || '';
|
||||
document.getElementById('language').value = settings.language || 'en';
|
||||
document.getElementById('startupToggle').checked = settings.startup || false;
|
||||
|
||||
// History
|
||||
const history = settings.history || [];
|
||||
const container = document.getElementById('historyList');
|
||||
if (history.length > 0) {
|
||||
container.innerHTML = '';
|
||||
[...history].reverse().forEach(item => {
|
||||
const el = document.createElement('div');
|
||||
el.className = 'history-item';
|
||||
|
||||
const time = document.createElement('span');
|
||||
time.className = 'history-time';
|
||||
time.textContent = new Date(item.timestamp).toLocaleString(undefined, {
|
||||
month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'
|
||||
});
|
||||
|
||||
const text = document.createElement('div');
|
||||
text.textContent = item.text;
|
||||
|
||||
el.appendChild(time);
|
||||
el.appendChild(text);
|
||||
container.appendChild(el);
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load settings:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Load mics
|
||||
async function loadMics() {
|
||||
try {
|
||||
const mics = await window.go.main.App.GetMicrophones();
|
||||
const select = document.getElementById('micDevice');
|
||||
mics.forEach(mic => {
|
||||
if (mic.index !== -1) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = mic.index;
|
||||
opt.textContent = mic.name;
|
||||
select.appendChild(opt);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Failed to load mics:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Save functions
|
||||
window.saveApiKey = async function () {
|
||||
const key = document.getElementById('apiKey').value.trim();
|
||||
await window.go.main.App.SaveSettings({ api_key: key });
|
||||
showSaveStatus();
|
||||
};
|
||||
|
||||
function showSaveStatus(message = 'Settings Saved!') {
|
||||
const el = document.getElementById('saveStatus');
|
||||
el.textContent = message;
|
||||
el.classList.add('show');
|
||||
setTimeout(() => el.classList.remove('show'), 2000);
|
||||
}
|
||||
|
||||
window.saveWhisperModel = async function () {
|
||||
await window.go.main.App.SaveSettings({ whisper_model: document.getElementById('whisperModel').value });
|
||||
showSaveStatus();
|
||||
};
|
||||
|
||||
window.saveAiModel = async function () {
|
||||
await window.go.main.App.SaveSettings({ ai_model: document.getElementById('aiModel').value });
|
||||
showSaveStatus();
|
||||
};
|
||||
|
||||
window.saveLanguage = async function () {
|
||||
await window.go.main.App.SaveSettings({ language: document.getElementById('language').value });
|
||||
showSaveStatus('Language Saved!');
|
||||
};
|
||||
|
||||
window.saveMicDevice = async function () {
|
||||
const val = document.getElementById('micDevice').value;
|
||||
await window.go.main.App.SaveSettings({ microphone_device: val === 'default' ? null : parseInt(val) });
|
||||
showSaveStatus();
|
||||
};
|
||||
|
||||
window.savePrompt = async function () {
|
||||
await window.go.main.App.SaveSettings({ ai_prompt: document.getElementById('aiPrompt').value.trim() });
|
||||
showSaveStatus('Prompt Saved!');
|
||||
};
|
||||
|
||||
window.toggleStartup = async function () {
|
||||
await window.go.main.App.ToggleStartup(document.getElementById('startupToggle').checked);
|
||||
};
|
||||
|
||||
window.clearHistory = async function () {
|
||||
if (confirm('Clear all history?')) {
|
||||
await window.go.main.App.ClearHistory();
|
||||
document.getElementById('historyList').innerHTML = '<div style="text-align: center; color: var(--text-muted); padding: 20px;">No history yet.</div>';
|
||||
}
|
||||
};
|
||||
|
||||
// Check connection status
|
||||
async function checkConnection() {
|
||||
try {
|
||||
const isOnline = await window.go.main.App.CheckOnline();
|
||||
const statusEl = document.getElementById('connectionStatus');
|
||||
|
||||
if (isOnline) {
|
||||
statusEl.innerHTML = '🟢 Online - Cloud transcription available';
|
||||
statusEl.style.background = 'rgba(34, 197, 94, 0.1)';
|
||||
statusEl.style.color = '#22c55e';
|
||||
} else {
|
||||
statusEl.innerHTML = '🔴 Offline - Install local Whisper for transcription';
|
||||
statusEl.style.background = 'rgba(239, 68, 68, 0.1)';
|
||||
statusEl.style.color = '#ef4444';
|
||||
|
||||
// Disable cloud AI options when offline
|
||||
const aiSelect = document.getElementById('aiModel');
|
||||
const whisperSelect = document.getElementById('whisperModel');
|
||||
|
||||
// Add offline notice to options
|
||||
for (let opt of aiSelect.options) {
|
||||
if (opt.value !== 'None' && !opt.value.startsWith('local-')) {
|
||||
opt.disabled = true;
|
||||
if (!opt.text.includes('(offline)')) {
|
||||
opt.text += ' (offline)';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Connection check failed:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Check whisper installation status
|
||||
async function checkWhisperStatus() {
|
||||
try {
|
||||
const info = await window.go.main.App.GetWhisperInfo();
|
||||
const whisperSelect = document.getElementById('whisperModel');
|
||||
|
||||
// Remove any existing local option
|
||||
const existingLocal = whisperSelect.querySelector('option[value^="local-"]');
|
||||
if (existingLocal) existingLocal.remove();
|
||||
|
||||
if (info.installed) {
|
||||
document.getElementById('whisperNotInstalled').style.display = 'none';
|
||||
document.getElementById('whisperInstalled').style.display = 'block';
|
||||
document.getElementById('installedModel').textContent = info.model + ' model';
|
||||
|
||||
// Add local option to whisper dropdown
|
||||
const localOption = document.createElement('option');
|
||||
localOption.value = 'local-' + info.model;
|
||||
localOption.textContent = '🖥️ Local - ' + info.model + ' (offline)';
|
||||
localOption.style.fontWeight = 'bold';
|
||||
whisperSelect.insertBefore(localOption, whisperSelect.firstChild);
|
||||
} else {
|
||||
document.getElementById('whisperNotInstalled').style.display = 'block';
|
||||
document.getElementById('whisperInstalled').style.display = 'none';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Whisper status check failed:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Install whisper
|
||||
window.installWhisper = async function () {
|
||||
const model = document.getElementById('whisperModelSelect').value;
|
||||
const btn = document.getElementById('installBtn');
|
||||
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Starting installation...';
|
||||
|
||||
try {
|
||||
const result = await window.go.main.App.InstallWhisper(model);
|
||||
alert(result + '\n\nA terminal window will open showing the installation progress. This may take several minutes depending on your internet speed.');
|
||||
|
||||
// Check status after a delay
|
||||
setTimeout(checkWhisperStatus, 5000);
|
||||
} catch (err) {
|
||||
alert('Installation failed: ' + err);
|
||||
}
|
||||
|
||||
btn.disabled = false;
|
||||
btn.textContent = '🚀 Install Offline Whisper';
|
||||
};
|
||||
|
||||
// Uninstall whisper
|
||||
window.uninstallWhisper = async function () {
|
||||
if (!confirm('Are you sure you want to uninstall offline Whisper? This will delete the downloaded model.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await window.go.main.App.UninstallWhisper();
|
||||
alert(result);
|
||||
checkWhisperStatus();
|
||||
} catch (err) {
|
||||
alert('Uninstall failed: ' + err);
|
||||
}
|
||||
};
|
||||
|
||||
// Init
|
||||
loadSettings();
|
||||
loadMics();
|
||||
checkConnection();
|
||||
checkWhisperStatus();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Generated
+653
@@ -0,0 +1,653 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "0.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "frontend",
|
||||
"version": "0.0.0",
|
||||
"devDependencies": {
|
||||
"vite": "^3.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.18.tgz",
|
||||
"integrity": "sha512-5GT+kcs2WVGjVs7+boataCkO5Fg0y4kCjzkB5bAip7H4jfnOS3dA6KPiww9W1OEKTKeAcUVhdZGvgI65OXmUnw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.18.tgz",
|
||||
"integrity": "sha512-L4jVKS82XVhw2nvzLg/19ClLWg0y27ulRwuP7lcyL6AbUWB5aPglXY3M21mauDQMDfRLs8cQmeT03r/+X3cZYQ==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.18.tgz",
|
||||
"integrity": "sha512-x/R72SmW3sSFRm5zrrIjAhCeQSAWoni3CmHEqfQrZIQTM3lVCdehdwuIqaOtfC2slvpdlLa62GYoN8SxT23m6Q==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/android-arm": "0.15.18",
|
||||
"@esbuild/linux-loong64": "0.15.18",
|
||||
"esbuild-android-64": "0.15.18",
|
||||
"esbuild-android-arm64": "0.15.18",
|
||||
"esbuild-darwin-64": "0.15.18",
|
||||
"esbuild-darwin-arm64": "0.15.18",
|
||||
"esbuild-freebsd-64": "0.15.18",
|
||||
"esbuild-freebsd-arm64": "0.15.18",
|
||||
"esbuild-linux-32": "0.15.18",
|
||||
"esbuild-linux-64": "0.15.18",
|
||||
"esbuild-linux-arm": "0.15.18",
|
||||
"esbuild-linux-arm64": "0.15.18",
|
||||
"esbuild-linux-mips64le": "0.15.18",
|
||||
"esbuild-linux-ppc64le": "0.15.18",
|
||||
"esbuild-linux-riscv64": "0.15.18",
|
||||
"esbuild-linux-s390x": "0.15.18",
|
||||
"esbuild-netbsd-64": "0.15.18",
|
||||
"esbuild-openbsd-64": "0.15.18",
|
||||
"esbuild-sunos-64": "0.15.18",
|
||||
"esbuild-windows-32": "0.15.18",
|
||||
"esbuild-windows-64": "0.15.18",
|
||||
"esbuild-windows-arm64": "0.15.18"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-android-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.18.tgz",
|
||||
"integrity": "sha512-wnpt3OXRhcjfIDSZu9bnzT4/TNTDsOUvip0foZOUBG7QbSt//w3QV4FInVJxNhKc/ErhUxc5z4QjHtMi7/TbgA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-android-arm64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.18.tgz",
|
||||
"integrity": "sha512-G4xu89B8FCzav9XU8EjsXacCKSG2FT7wW9J6hOc18soEHJdtWu03L3TQDGf0geNxfLTtxENKBzMSq9LlbjS8OQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-darwin-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.18.tgz",
|
||||
"integrity": "sha512-2WAvs95uPnVJPuYKP0Eqx+Dl/jaYseZEUUT1sjg97TJa4oBtbAKnPnl3b5M9l51/nbx7+QAEtuummJZW0sBEmg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-darwin-arm64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.18.tgz",
|
||||
"integrity": "sha512-tKPSxcTJ5OmNb1btVikATJ8NftlyNlc8BVNtyT/UAr62JFOhwHlnoPrhYWz09akBLHI9nElFVfWSTSRsrZiDUA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-freebsd-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.18.tgz",
|
||||
"integrity": "sha512-TT3uBUxkteAjR1QbsmvSsjpKjOX6UkCstr8nMr+q7zi3NuZ1oIpa8U41Y8I8dJH2fJgdC3Dj3CXO5biLQpfdZA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-freebsd-arm64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.18.tgz",
|
||||
"integrity": "sha512-R/oVr+X3Tkh+S0+tL41wRMbdWtpWB8hEAMsOXDumSSa6qJR89U0S/PpLXrGF7Wk/JykfpWNokERUpCeHDl47wA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-32": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.18.tgz",
|
||||
"integrity": "sha512-lphF3HiCSYtaa9p1DtXndiQEeQDKPl9eN/XNoBf2amEghugNuqXNZA/ZovthNE2aa4EN43WroO0B85xVSjYkbg==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.18.tgz",
|
||||
"integrity": "sha512-hNSeP97IviD7oxLKFuii5sDPJ+QHeiFTFLoLm7NZQligur8poNOWGIgpQ7Qf8Balb69hptMZzyOBIPtY09GZYw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-arm": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.18.tgz",
|
||||
"integrity": "sha512-UH779gstRblS4aoS2qpMl3wjg7U0j+ygu3GjIeTonCcN79ZvpPee12Qun3vcdxX+37O5LFxz39XeW2I9bybMVA==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-arm64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.18.tgz",
|
||||
"integrity": "sha512-54qr8kg/6ilcxd+0V3h9rjT4qmjc0CccMVWrjOEM/pEcUzt8X62HfBSeZfT2ECpM7104mk4yfQXkosY8Quptug==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-mips64le": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.18.tgz",
|
||||
"integrity": "sha512-Mk6Ppwzzz3YbMl/ZZL2P0q1tnYqh/trYZ1VfNP47C31yT0K8t9s7Z077QrDA/guU60tGNp2GOwCQnp+DYv7bxQ==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-ppc64le": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.18.tgz",
|
||||
"integrity": "sha512-b0XkN4pL9WUulPTa/VKHx2wLCgvIAbgwABGnKMY19WhKZPT+8BxhZdqz6EgkqCLld7X5qiCY2F/bfpUUlnFZ9w==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-riscv64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.18.tgz",
|
||||
"integrity": "sha512-ba2COaoF5wL6VLZWn04k+ACZjZ6NYniMSQStodFKH/Pu6RxzQqzsmjR1t9QC89VYJxBeyVPTaHuBMCejl3O/xg==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-linux-s390x": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.18.tgz",
|
||||
"integrity": "sha512-VbpGuXEl5FCs1wDVp93O8UIzl3ZrglgnSQ+Hu79g7hZu6te6/YHgVJxCM2SqfIila0J3k0csfnf8VD2W7u2kzQ==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-netbsd-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.18.tgz",
|
||||
"integrity": "sha512-98ukeCdvdX7wr1vUYQzKo4kQ0N2p27H7I11maINv73fVEXt2kyh4K4m9f35U1K43Xc2QGXlzAw0K9yoU7JUjOg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-openbsd-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.18.tgz",
|
||||
"integrity": "sha512-yK5NCcH31Uae076AyQAXeJzt/vxIo9+omZRKj1pauhk3ITuADzuOx5N2fdHrAKPxN+zH3w96uFKlY7yIn490xQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-sunos-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.18.tgz",
|
||||
"integrity": "sha512-On22LLFlBeLNj/YF3FT+cXcyKPEI263nflYlAhz5crxtp3yRG1Ugfr7ITyxmCmjm4vbN/dGrb/B7w7U8yJR9yw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-windows-32": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.18.tgz",
|
||||
"integrity": "sha512-o+eyLu2MjVny/nt+E0uPnBxYuJHBvho8vWsC2lV61A7wwTWC3jkN2w36jtA+yv1UgYkHRihPuQsL23hsCYGcOQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-windows-64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.18.tgz",
|
||||
"integrity": "sha512-qinug1iTTaIIrCorAUjR0fcBk24fjzEedFYhhispP8Oc7SFvs+XeW3YpAKiKp8dRpizl4YYAhxMjlftAMJiaUw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild-windows-arm64": {
|
||||
"version": "0.15.18",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.18.tgz",
|
||||
"integrity": "sha512-q9bsYzegpZcLziq0zgUi5KqGVtfhjxGbnksaBFYmWLxeV/S1fK4OLdq2DFYnXcLMjlZw2L0jLsk1eGoB522WXQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/is-core-module": {
|
||||
"version": "2.16.1",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
|
||||
"integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"hasown": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.11",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
|
||||
"integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/path-parse": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.6",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||
"integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/postcss/"
|
||||
},
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.11",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
"version": "1.22.11",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",
|
||||
"integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-core-module": "^2.16.1",
|
||||
"path-parse": "^1.0.7",
|
||||
"supports-preserve-symlinks-flag": "^1.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"resolve": "bin/resolve"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "2.79.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz",
|
||||
"integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-preserve-symlinks-flag": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
||||
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "3.2.11",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-3.2.11.tgz",
|
||||
"integrity": "sha512-K/jGKL/PgbIgKCiJo5QbASQhFiV02X9Jh+Qq0AKCRCRKZtOTVi4t6wh75FDpGf2N9rYOnzH87OEFQNaFy6pdxQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.15.9",
|
||||
"postcss": "^8.4.18",
|
||||
"resolve": "^1.22.1",
|
||||
"rollup": "^2.79.1"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": ">= 14",
|
||||
"less": "*",
|
||||
"sass": "*",
|
||||
"stylus": "*",
|
||||
"sugarss": "*",
|
||||
"terser": "^5.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"sass": {
|
||||
"optional": true
|
||||
},
|
||||
"stylus": {
|
||||
"optional": true
|
||||
},
|
||||
"sugarss": {
|
||||
"optional": true
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^3.0.7"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
be0c7dc3573b2470ab6a8ec4c48845b6
|
||||
@@ -0,0 +1,54 @@
|
||||
#logo {
|
||||
display: block;
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
margin: auto;
|
||||
padding: 10% 0 0;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
background-origin: content-box;
|
||||
}
|
||||
|
||||
.result {
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
margin: 1.5rem auto;
|
||||
}
|
||||
|
||||
.input-box .btn {
|
||||
width: 60px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
margin: 0 0 0 20px;
|
||||
padding: 0 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.input-box .btn:hover {
|
||||
background-image: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%);
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.input-box .input {
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
background-color: rgba(240, 240, 240, 1);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.input-box .input:hover {
|
||||
border: none;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
.input-box .input:focus {
|
||||
border: none;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com),
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
@@ -0,0 +1,252 @@
|
||||
// Main JavaScript for Settings UI
|
||||
|
||||
// Global state
|
||||
let currentSettings = {};
|
||||
let apiKeyVisible = true;
|
||||
|
||||
// Initialize
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
await loadSettings();
|
||||
await loadMicrophones();
|
||||
|
||||
// Show form after loading
|
||||
document.getElementById('loadingIndicator').style.display = 'none';
|
||||
document.getElementById('settingsForm').style.display = 'block';
|
||||
});
|
||||
|
||||
// Load settings from backend
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const settings = await window.go.main.App.GetSettings();
|
||||
currentSettings = settings;
|
||||
|
||||
console.log("Loaded settings:", settings);
|
||||
|
||||
// Populate fields
|
||||
document.getElementById('apiKey').value = settings.api_key || '';
|
||||
document.getElementById('shortcutInput').value = settings.shortcut || 'alt+z';
|
||||
document.getElementById('whisperModel').value = settings.whisper_model || 'whisper-large-v3-turbo';
|
||||
document.getElementById('aiModel').value = settings.ai_model || 'llama-3.3-70b-versatile';
|
||||
document.getElementById('aiPrompt').value = settings.ai_prompt || '';
|
||||
document.getElementById('startupToggle').checked = settings.startup || false;
|
||||
|
||||
// Load history
|
||||
renderHistory(settings.history || []);
|
||||
|
||||
} catch (err) {
|
||||
console.error("Failed to load settings:", err);
|
||||
alert("Failed to load settings: " + err);
|
||||
}
|
||||
}
|
||||
|
||||
// Load microphones
|
||||
async function loadMicrophones() {
|
||||
try {
|
||||
const mics = await window.go.main.App.GetMicrophones();
|
||||
const select = document.getElementById('micDevice');
|
||||
|
||||
// Keep default option
|
||||
select.innerHTML = '<option value="default">System Default</option>';
|
||||
|
||||
mics.forEach(mic => {
|
||||
if (mic.index !== -1) {
|
||||
const option = document.createElement('option');
|
||||
option.value = mic.index;
|
||||
option.textContent = mic.name;
|
||||
select.appendChild(option);
|
||||
}
|
||||
});
|
||||
|
||||
// Set current selection
|
||||
if (currentSettings.microphone_device !== null && currentSettings.microphone_device !== undefined) {
|
||||
select.value = currentSettings.microphone_device;
|
||||
} else {
|
||||
select.value = "default";
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error("Failed to load microphones:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Render history list
|
||||
function renderHistory(history) {
|
||||
const container = document.getElementById('historyList');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (!history || history.length === 0) {
|
||||
container.innerHTML = '<div style="text-align: center; color: var(--text-muted); padding: 20px;">No history yet. Use your shortcut to start recording!</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Show newest first
|
||||
const sorted = [...history].reverse();
|
||||
|
||||
sorted.forEach(item => {
|
||||
const el = document.createElement('div');
|
||||
el.className = 'history-item';
|
||||
|
||||
const time = new Date(item.timestamp).toLocaleString();
|
||||
|
||||
el.innerHTML = `
|
||||
<div class="history-time">${time}</div>
|
||||
<div style="white-space: pre-wrap;">${escapeHtml(item.text)}</div>
|
||||
`;
|
||||
container.appendChild(el);
|
||||
});
|
||||
}
|
||||
|
||||
// Toggle API key visibility
|
||||
function toggleApiKeyVisibility() {
|
||||
const input = document.getElementById('apiKey');
|
||||
const btn = document.getElementById('toggleKeyBtn');
|
||||
|
||||
if (apiKeyVisible) {
|
||||
input.type = 'password';
|
||||
btn.textContent = 'Show';
|
||||
apiKeyVisible = false;
|
||||
} else {
|
||||
input.type = 'text';
|
||||
btn.textContent = 'Hide';
|
||||
apiKeyVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Save API Key
|
||||
async function saveApiKey() {
|
||||
const key = document.getElementById('apiKey').value.trim();
|
||||
if (!key) {
|
||||
alert('Please enter an API key');
|
||||
return;
|
||||
}
|
||||
await saveSetting('api_key', key);
|
||||
showToast('API Key saved');
|
||||
}
|
||||
|
||||
// Save Shortcut
|
||||
async function saveShortcut() {
|
||||
const shortcut = document.getElementById('shortcutInput').value.trim().toLowerCase();
|
||||
|
||||
if (!shortcut) {
|
||||
alert('Please enter a shortcut');
|
||||
return;
|
||||
}
|
||||
|
||||
const parts = shortcut.split('+');
|
||||
if (parts.length < 2) {
|
||||
alert('Shortcut must have a modifier + key (e.g., ctrl+x)');
|
||||
return;
|
||||
}
|
||||
|
||||
await saveSetting('shortcut', shortcut);
|
||||
showToast('Shortcut saved: ' + shortcut);
|
||||
}
|
||||
|
||||
// Save Whisper Model
|
||||
async function saveWhisperModel() {
|
||||
const model = document.getElementById('whisperModel').value;
|
||||
await saveSetting('whisper_model', model);
|
||||
showToast('Whisper model saved');
|
||||
}
|
||||
|
||||
// Save AI Model
|
||||
async function saveAiModel() {
|
||||
const model = document.getElementById('aiModel').value;
|
||||
await saveSetting('ai_model', model);
|
||||
showToast('AI model saved');
|
||||
}
|
||||
|
||||
// Save Microphone
|
||||
async function saveMicDevice() {
|
||||
const val = document.getElementById('micDevice').value;
|
||||
let device = null;
|
||||
if (val !== "default") {
|
||||
device = parseInt(val);
|
||||
}
|
||||
await saveSetting('microphone_device', device);
|
||||
showToast('Microphone saved');
|
||||
}
|
||||
|
||||
// Save Prompt
|
||||
async function savePrompt() {
|
||||
const prompt = document.getElementById('aiPrompt').value.trim();
|
||||
await saveSetting('ai_prompt', prompt);
|
||||
showToast('Prompt saved');
|
||||
}
|
||||
|
||||
// Toggle Startup
|
||||
async function toggleStartup() {
|
||||
const enabled = document.getElementById('startupToggle').checked;
|
||||
try {
|
||||
const result = await window.go.main.App.ToggleStartup(enabled);
|
||||
if (result !== "Success") {
|
||||
alert("Failed to update startup: " + result);
|
||||
document.getElementById('startupToggle').checked = !enabled;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to toggle startup:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear History
|
||||
async function clearHistory() {
|
||||
if (confirm("Are you sure you want to clear all history?")) {
|
||||
await window.go.main.App.ClearHistory();
|
||||
renderHistory([]);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to save a single setting
|
||||
async function saveSetting(key, value) {
|
||||
try {
|
||||
const settings = {};
|
||||
settings[key] = value;
|
||||
const result = await window.go.main.App.SaveSettings(settings);
|
||||
currentSettings[key] = value;
|
||||
return result;
|
||||
} catch (err) {
|
||||
console.error(`Failed to save ${key}:`, err);
|
||||
alert(`Failed to save setting: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to escape HTML
|
||||
function escapeHtml(text) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
// Toast notification
|
||||
function showToast(msg) {
|
||||
console.log(msg);
|
||||
|
||||
// Create toast element
|
||||
let toast = document.getElementById('toast');
|
||||
if (!toast) {
|
||||
toast = document.createElement('div');
|
||||
toast.id = 'toast';
|
||||
toast.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
font-weight: 500;
|
||||
z-index: 1000;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
`;
|
||||
document.body.appendChild(toast);
|
||||
}
|
||||
|
||||
toast.textContent = msg;
|
||||
toast.style.opacity = '1';
|
||||
|
||||
setTimeout(() => {
|
||||
toast.style.opacity = '0';
|
||||
}, 2000);
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
:root {
|
||||
--bg-color: #0b0f1a;
|
||||
--card-bg: rgba(30, 41, 59, 0.7);
|
||||
--input-bg: rgba(51, 65, 85, 0.5);
|
||||
--text-color: #f8fafc;
|
||||
--text-muted: #94a3b8;
|
||||
--primary-color: #3b82f6;
|
||||
--primary-hover: #2563eb;
|
||||
--accent-color: #6366f1;
|
||||
--border-color: rgba(75, 85, 99, 0.4);
|
||||
--success-color: #10b981;
|
||||
--glass-border: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
body {
|
||||
background: radial-gradient(circle at top right, #1e293b, #0b0f1a);
|
||||
color: var(--text-color);
|
||||
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||
margin: 0;
|
||||
padding: 30px;
|
||||
min-height: 100vh;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
background: linear-gradient(135deg, #60a5fa, #a78bfa);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.section {
|
||||
background: var(--card-bg);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
padding: 24px;
|
||||
border-radius: 16px;
|
||||
margin-bottom: 24px;
|
||||
border: 1px solid var(--glass-border);
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.section:hover {
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
color: var(--text-muted);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
input[type="password"],
|
||||
select,
|
||||
textarea {
|
||||
width: 100%;
|
||||
background: var(--input-bg);
|
||||
border: 1px solid var(--border-color);
|
||||
color: white;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
select:focus,
|
||||
textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color);
|
||||
background: rgba(51, 65, 85, 0.8);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
max-width: 480px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.input-wrapper input {
|
||||
width: 100%;
|
||||
padding-right: 44px;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.eye-btn {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
cursor: pointer;
|
||||
padding: 4px !important;
|
||||
font-size: 16px;
|
||||
opacity: 0.5;
|
||||
transition: opacity 0.2s;
|
||||
line-height: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.eye-btn:hover {
|
||||
opacity: 1;
|
||||
transform: translateY(-50%) scale(1.1);
|
||||
}
|
||||
|
||||
.save-status {
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
background: var(--success-color);
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 12px;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
|
||||
transform: translateY(100px);
|
||||
opacity: 0;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.save-status.show {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: var(--primary-color);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
|
||||
background-color: var(--primary-hover);
|
||||
}
|
||||
|
||||
button:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
button[style*="background: transparent"] {
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
text-decoration: underline;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
button[style*="background: transparent"]:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.flex-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.flex-between {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.history-list {
|
||||
max-height: 250px;
|
||||
overflow-y: auto;
|
||||
margin-top: 10px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
padding: 14px;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.history-item:hover {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
.history-time {
|
||||
color: var(--primary-color);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 6px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Scrollbar excellence */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function ClearHistory(): Promise<void>;
|
||||
|
||||
export function GetMicrophones(): Promise<Array<{ [key: string]: any }>>;
|
||||
|
||||
export function GetSettings(): Promise<{ [key: string]: any }>;
|
||||
|
||||
export function Greet(arg1: string): Promise<string>;
|
||||
|
||||
export function SaveSettings(arg1: { [key: string]: any }): Promise<string>;
|
||||
|
||||
export function ToggleStartup(arg1: boolean): Promise<string>;
|
||||
@@ -0,0 +1,50 @@
|
||||
// @ts-check
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function ClearHistory() {
|
||||
return window['go']['main']['App']['ClearHistory']();
|
||||
}
|
||||
|
||||
export function GetMicrophones() {
|
||||
return window['go']['main']['App']['GetMicrophones']();
|
||||
}
|
||||
|
||||
export function GetSettings() {
|
||||
return window['go']['main']['App']['GetSettings']();
|
||||
}
|
||||
|
||||
export function Greet(arg1) {
|
||||
return window['go']['main']['App']['Greet'](arg1);
|
||||
}
|
||||
|
||||
export function SaveSettings(arg1) {
|
||||
return window['go']['main']['App']['SaveSettings'](arg1);
|
||||
}
|
||||
|
||||
export function ToggleStartup(arg1) {
|
||||
return window['go']['main']['App']['ToggleStartup'](arg1);
|
||||
}
|
||||
|
||||
export function CheckOnline() {
|
||||
return window['go']['main']['App']['CheckOnline']();
|
||||
}
|
||||
|
||||
export function IsWhisperInstalled() {
|
||||
return window['go']['main']['App']['IsWhisperInstalled']();
|
||||
}
|
||||
|
||||
export function GetWhisperInfo() {
|
||||
return window['go']['main']['App']['GetWhisperInfo']();
|
||||
}
|
||||
|
||||
export function InstallWhisper(arg1) {
|
||||
return window['go']['main']['App']['InstallWhisper'](arg1);
|
||||
}
|
||||
|
||||
export function UninstallWhisper() {
|
||||
return window['go']['main']['App']['UninstallWhisper']();
|
||||
}
|
||||
|
||||
export function GetAvailableWhisperModels() {
|
||||
return window['go']['main']['App']['GetAvailableWhisperModels']();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@wailsapp/runtime",
|
||||
"version": "2.0.0",
|
||||
"description": "Wails Javascript runtime library",
|
||||
"main": "runtime.js",
|
||||
"types": "runtime.d.ts",
|
||||
"scripts": {
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/wailsapp/wails.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Wails",
|
||||
"Javascript",
|
||||
"Go"
|
||||
],
|
||||
"author": "Lea Anthony <lea.anthony@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/wailsapp/wails/issues"
|
||||
},
|
||||
"homepage": "https://github.com/wailsapp/wails#readme"
|
||||
}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
export interface Position {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Size {
|
||||
w: number;
|
||||
h: number;
|
||||
}
|
||||
|
||||
export interface Screen {
|
||||
isCurrent: boolean;
|
||||
isPrimary: boolean;
|
||||
width : number
|
||||
height : number
|
||||
}
|
||||
|
||||
// Environment information such as platform, buildtype, ...
|
||||
export interface EnvironmentInfo {
|
||||
buildType: string;
|
||||
platform: string;
|
||||
arch: string;
|
||||
}
|
||||
|
||||
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
|
||||
// emits the given event. Optional data may be passed with the event.
|
||||
// This will trigger any event listeners.
|
||||
export function EventsEmit(eventName: string, ...data: any): void;
|
||||
|
||||
// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name.
|
||||
export function EventsOn(eventName: string, callback: (...data: any) => void): () => void;
|
||||
|
||||
// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
|
||||
// sets up a listener for the given event name, but will only trigger a given number times.
|
||||
export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
|
||||
|
||||
// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce)
|
||||
// sets up a listener for the given event name, but will only trigger once.
|
||||
export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void;
|
||||
|
||||
// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff)
|
||||
// unregisters the listener for the given event name.
|
||||
export function EventsOff(eventName: string, ...additionalEventNames: string[]): void;
|
||||
|
||||
// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall)
|
||||
// unregisters all listeners.
|
||||
export function EventsOffAll(): void;
|
||||
|
||||
// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint)
|
||||
// logs the given message as a raw message
|
||||
export function LogPrint(message: string): void;
|
||||
|
||||
// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace)
|
||||
// logs the given message at the `trace` log level.
|
||||
export function LogTrace(message: string): void;
|
||||
|
||||
// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug)
|
||||
// logs the given message at the `debug` log level.
|
||||
export function LogDebug(message: string): void;
|
||||
|
||||
// [LogError](https://wails.io/docs/reference/runtime/log#logerror)
|
||||
// logs the given message at the `error` log level.
|
||||
export function LogError(message: string): void;
|
||||
|
||||
// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal)
|
||||
// logs the given message at the `fatal` log level.
|
||||
// The application will quit after calling this method.
|
||||
export function LogFatal(message: string): void;
|
||||
|
||||
// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo)
|
||||
// logs the given message at the `info` log level.
|
||||
export function LogInfo(message: string): void;
|
||||
|
||||
// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning)
|
||||
// logs the given message at the `warning` log level.
|
||||
export function LogWarning(message: string): void;
|
||||
|
||||
// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload)
|
||||
// Forces a reload by the main application as well as connected browsers.
|
||||
export function WindowReload(): void;
|
||||
|
||||
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
|
||||
// Reloads the application frontend.
|
||||
export function WindowReloadApp(): void;
|
||||
|
||||
// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop)
|
||||
// Sets the window AlwaysOnTop or not on top.
|
||||
export function WindowSetAlwaysOnTop(b: boolean): void;
|
||||
|
||||
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
|
||||
// *Windows only*
|
||||
// Sets window theme to system default (dark/light).
|
||||
export function WindowSetSystemDefaultTheme(): void;
|
||||
|
||||
// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme)
|
||||
// *Windows only*
|
||||
// Sets window to light theme.
|
||||
export function WindowSetLightTheme(): void;
|
||||
|
||||
// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme)
|
||||
// *Windows only*
|
||||
// Sets window to dark theme.
|
||||
export function WindowSetDarkTheme(): void;
|
||||
|
||||
// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter)
|
||||
// Centers the window on the monitor the window is currently on.
|
||||
export function WindowCenter(): void;
|
||||
|
||||
// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle)
|
||||
// Sets the text in the window title bar.
|
||||
export function WindowSetTitle(title: string): void;
|
||||
|
||||
// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen)
|
||||
// Makes the window full screen.
|
||||
export function WindowFullscreen(): void;
|
||||
|
||||
// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen)
|
||||
// Restores the previous window dimensions and position prior to full screen.
|
||||
export function WindowUnfullscreen(): void;
|
||||
|
||||
// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen)
|
||||
// Returns the state of the window, i.e. whether the window is in full screen mode or not.
|
||||
export function WindowIsFullscreen(): Promise<boolean>;
|
||||
|
||||
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
|
||||
// Sets the width and height of the window.
|
||||
export function WindowSetSize(width: number, height: number): void;
|
||||
|
||||
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
|
||||
// Gets the width and height of the window.
|
||||
export function WindowGetSize(): Promise<Size>;
|
||||
|
||||
// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize)
|
||||
// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions.
|
||||
// Setting a size of 0,0 will disable this constraint.
|
||||
export function WindowSetMaxSize(width: number, height: number): void;
|
||||
|
||||
// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize)
|
||||
// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions.
|
||||
// Setting a size of 0,0 will disable this constraint.
|
||||
export function WindowSetMinSize(width: number, height: number): void;
|
||||
|
||||
// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition)
|
||||
// Sets the window position relative to the monitor the window is currently on.
|
||||
export function WindowSetPosition(x: number, y: number): void;
|
||||
|
||||
// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition)
|
||||
// Gets the window position relative to the monitor the window is currently on.
|
||||
export function WindowGetPosition(): Promise<Position>;
|
||||
|
||||
// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide)
|
||||
// Hides the window.
|
||||
export function WindowHide(): void;
|
||||
|
||||
// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow)
|
||||
// Shows the window, if it is currently hidden.
|
||||
export function WindowShow(): void;
|
||||
|
||||
// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise)
|
||||
// Maximises the window to fill the screen.
|
||||
export function WindowMaximise(): void;
|
||||
|
||||
// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise)
|
||||
// Toggles between Maximised and UnMaximised.
|
||||
export function WindowToggleMaximise(): void;
|
||||
|
||||
// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise)
|
||||
// Restores the window to the dimensions and position prior to maximising.
|
||||
export function WindowUnmaximise(): void;
|
||||
|
||||
// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised)
|
||||
// Returns the state of the window, i.e. whether the window is maximised or not.
|
||||
export function WindowIsMaximised(): Promise<boolean>;
|
||||
|
||||
// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise)
|
||||
// Minimises the window.
|
||||
export function WindowMinimise(): void;
|
||||
|
||||
// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise)
|
||||
// Restores the window to the dimensions and position prior to minimising.
|
||||
export function WindowUnminimise(): void;
|
||||
|
||||
// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised)
|
||||
// Returns the state of the window, i.e. whether the window is minimised or not.
|
||||
export function WindowIsMinimised(): Promise<boolean>;
|
||||
|
||||
// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal)
|
||||
// Returns the state of the window, i.e. whether the window is normal or not.
|
||||
export function WindowIsNormal(): Promise<boolean>;
|
||||
|
||||
// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour)
|
||||
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
|
||||
export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void;
|
||||
|
||||
// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall)
|
||||
// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system.
|
||||
export function ScreenGetAll(): Promise<Screen[]>;
|
||||
|
||||
// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl)
|
||||
// Opens the given URL in the system browser.
|
||||
export function BrowserOpenURL(url: string): void;
|
||||
|
||||
// [Environment](https://wails.io/docs/reference/runtime/intro#environment)
|
||||
// Returns information about the environment
|
||||
export function Environment(): Promise<EnvironmentInfo>;
|
||||
|
||||
// [Quit](https://wails.io/docs/reference/runtime/intro#quit)
|
||||
// Quits the application.
|
||||
export function Quit(): void;
|
||||
|
||||
// [Hide](https://wails.io/docs/reference/runtime/intro#hide)
|
||||
// Hides the application.
|
||||
export function Hide(): void;
|
||||
|
||||
// [Show](https://wails.io/docs/reference/runtime/intro#show)
|
||||
// Shows the application.
|
||||
export function Show(): void;
|
||||
|
||||
// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext)
|
||||
// Returns the current text stored on clipboard
|
||||
export function ClipboardGetText(): Promise<string>;
|
||||
|
||||
// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext)
|
||||
// Sets a text on the clipboard
|
||||
export function ClipboardSetText(text: string): Promise<boolean>;
|
||||
|
||||
// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop)
|
||||
// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
||||
export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void
|
||||
|
||||
// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff)
|
||||
// OnFileDropOff removes the drag and drop listeners and handlers.
|
||||
export function OnFileDropOff() :void
|
||||
|
||||
// Check if the file path resolver is available
|
||||
export function CanResolveFilePaths(): boolean;
|
||||
|
||||
// Resolves file paths for an array of files
|
||||
export function ResolveFilePaths(files: File[]): void
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
export function LogPrint(message) {
|
||||
window.runtime.LogPrint(message);
|
||||
}
|
||||
|
||||
export function LogTrace(message) {
|
||||
window.runtime.LogTrace(message);
|
||||
}
|
||||
|
||||
export function LogDebug(message) {
|
||||
window.runtime.LogDebug(message);
|
||||
}
|
||||
|
||||
export function LogInfo(message) {
|
||||
window.runtime.LogInfo(message);
|
||||
}
|
||||
|
||||
export function LogWarning(message) {
|
||||
window.runtime.LogWarning(message);
|
||||
}
|
||||
|
||||
export function LogError(message) {
|
||||
window.runtime.LogError(message);
|
||||
}
|
||||
|
||||
export function LogFatal(message) {
|
||||
window.runtime.LogFatal(message);
|
||||
}
|
||||
|
||||
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
||||
return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
|
||||
}
|
||||
|
||||
export function EventsOn(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, -1);
|
||||
}
|
||||
|
||||
export function EventsOff(eventName, ...additionalEventNames) {
|
||||
return window.runtime.EventsOff(eventName, ...additionalEventNames);
|
||||
}
|
||||
|
||||
export function EventsOffAll() {
|
||||
return window.runtime.EventsOffAll();
|
||||
}
|
||||
|
||||
export function EventsOnce(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, 1);
|
||||
}
|
||||
|
||||
export function EventsEmit(eventName) {
|
||||
let args = [eventName].slice.call(arguments);
|
||||
return window.runtime.EventsEmit.apply(null, args);
|
||||
}
|
||||
|
||||
export function WindowReload() {
|
||||
window.runtime.WindowReload();
|
||||
}
|
||||
|
||||
export function WindowReloadApp() {
|
||||
window.runtime.WindowReloadApp();
|
||||
}
|
||||
|
||||
export function WindowSetAlwaysOnTop(b) {
|
||||
window.runtime.WindowSetAlwaysOnTop(b);
|
||||
}
|
||||
|
||||
export function WindowSetSystemDefaultTheme() {
|
||||
window.runtime.WindowSetSystemDefaultTheme();
|
||||
}
|
||||
|
||||
export function WindowSetLightTheme() {
|
||||
window.runtime.WindowSetLightTheme();
|
||||
}
|
||||
|
||||
export function WindowSetDarkTheme() {
|
||||
window.runtime.WindowSetDarkTheme();
|
||||
}
|
||||
|
||||
export function WindowCenter() {
|
||||
window.runtime.WindowCenter();
|
||||
}
|
||||
|
||||
export function WindowSetTitle(title) {
|
||||
window.runtime.WindowSetTitle(title);
|
||||
}
|
||||
|
||||
export function WindowFullscreen() {
|
||||
window.runtime.WindowFullscreen();
|
||||
}
|
||||
|
||||
export function WindowUnfullscreen() {
|
||||
window.runtime.WindowUnfullscreen();
|
||||
}
|
||||
|
||||
export function WindowIsFullscreen() {
|
||||
return window.runtime.WindowIsFullscreen();
|
||||
}
|
||||
|
||||
export function WindowGetSize() {
|
||||
return window.runtime.WindowGetSize();
|
||||
}
|
||||
|
||||
export function WindowSetSize(width, height) {
|
||||
window.runtime.WindowSetSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetMaxSize(width, height) {
|
||||
window.runtime.WindowSetMaxSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetMinSize(width, height) {
|
||||
window.runtime.WindowSetMinSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetPosition(x, y) {
|
||||
window.runtime.WindowSetPosition(x, y);
|
||||
}
|
||||
|
||||
export function WindowGetPosition() {
|
||||
return window.runtime.WindowGetPosition();
|
||||
}
|
||||
|
||||
export function WindowHide() {
|
||||
window.runtime.WindowHide();
|
||||
}
|
||||
|
||||
export function WindowShow() {
|
||||
window.runtime.WindowShow();
|
||||
}
|
||||
|
||||
export function WindowMaximise() {
|
||||
window.runtime.WindowMaximise();
|
||||
}
|
||||
|
||||
export function WindowToggleMaximise() {
|
||||
window.runtime.WindowToggleMaximise();
|
||||
}
|
||||
|
||||
export function WindowUnmaximise() {
|
||||
window.runtime.WindowUnmaximise();
|
||||
}
|
||||
|
||||
export function WindowIsMaximised() {
|
||||
return window.runtime.WindowIsMaximised();
|
||||
}
|
||||
|
||||
export function WindowMinimise() {
|
||||
window.runtime.WindowMinimise();
|
||||
}
|
||||
|
||||
export function WindowUnminimise() {
|
||||
window.runtime.WindowUnminimise();
|
||||
}
|
||||
|
||||
export function WindowSetBackgroundColour(R, G, B, A) {
|
||||
window.runtime.WindowSetBackgroundColour(R, G, B, A);
|
||||
}
|
||||
|
||||
export function ScreenGetAll() {
|
||||
return window.runtime.ScreenGetAll();
|
||||
}
|
||||
|
||||
export function WindowIsMinimised() {
|
||||
return window.runtime.WindowIsMinimised();
|
||||
}
|
||||
|
||||
export function WindowIsNormal() {
|
||||
return window.runtime.WindowIsNormal();
|
||||
}
|
||||
|
||||
export function BrowserOpenURL(url) {
|
||||
window.runtime.BrowserOpenURL(url);
|
||||
}
|
||||
|
||||
export function Environment() {
|
||||
return window.runtime.Environment();
|
||||
}
|
||||
|
||||
export function Quit() {
|
||||
window.runtime.Quit();
|
||||
}
|
||||
|
||||
export function Hide() {
|
||||
window.runtime.Hide();
|
||||
}
|
||||
|
||||
export function Show() {
|
||||
window.runtime.Show();
|
||||
}
|
||||
|
||||
export function ClipboardGetText() {
|
||||
return window.runtime.ClipboardGetText();
|
||||
}
|
||||
|
||||
export function ClipboardSetText(text) {
|
||||
return window.runtime.ClipboardSetText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
||||
*
|
||||
* @export
|
||||
* @callback OnFileDropCallback
|
||||
* @param {number} x - x coordinate of the drop
|
||||
* @param {number} y - y coordinate of the drop
|
||||
* @param {string[]} paths - A list of file paths.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
||||
*
|
||||
* @export
|
||||
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
||||
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
|
||||
*/
|
||||
export function OnFileDrop(callback, useDropTarget) {
|
||||
return window.runtime.OnFileDrop(callback, useDropTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* OnFileDropOff removes the drag and drop listeners and handlers.
|
||||
*/
|
||||
export function OnFileDropOff() {
|
||||
return window.runtime.OnFileDropOff();
|
||||
}
|
||||
|
||||
export function CanResolveFilePaths() {
|
||||
return window.runtime.CanResolveFilePaths();
|
||||
}
|
||||
|
||||
export function ResolveFilePaths(files) {
|
||||
return window.runtime.ResolveFilePaths(files);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
module wis-free-v3
|
||||
|
||||
go 1.24
|
||||
|
||||
require (
|
||||
github.com/gen2brain/malgo v0.11.24
|
||||
github.com/getlantern/systray v1.2.2
|
||||
github.com/go-vgo/robotgo v0.110.8
|
||||
github.com/robotn/gohook v0.42.2
|
||||
github.com/wailsapp/wails/v2 v2.11.0
|
||||
golang.design/x/clipboard v0.7.1
|
||||
golang.org/x/sys v0.33.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bep/debounce v1.2.1 // indirect
|
||||
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e // indirect
|
||||
github.com/ebitengine/purego v0.8.3 // indirect
|
||||
github.com/gen2brain/shm v0.1.1 // indirect
|
||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
|
||||
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect
|
||||
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 // indirect
|
||||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect
|
||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect
|
||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||
github.com/jezek/xgb v1.1.1 // indirect
|
||||
github.com/labstack/echo/v4 v4.13.3 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||
github.com/leaanthony/u v1.1.1 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/otiai10/gosseract v2.2.1+incompatible // indirect
|
||||
github.com/otiai10/mint v1.6.3 // indirect
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/robotn/xgb v0.10.0 // indirect
|
||||
github.com/robotn/xgbutil v0.10.0 // indirect
|
||||
github.com/samber/lo v1.49.1 // indirect
|
||||
github.com/shirou/gopsutil/v4 v4.25.4 // indirect
|
||||
github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.15 // indirect
|
||||
github.com/tklauser/numcpus v0.10.0 // indirect
|
||||
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/vcaesar/gops v0.41.0 // indirect
|
||||
github.com/vcaesar/imgo v0.41.0 // indirect
|
||||
github.com/vcaesar/keycode v0.10.1 // indirect
|
||||
github.com/vcaesar/screenshot v0.11.1 // indirect
|
||||
github.com/vcaesar/tt v0.20.1 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.22 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
|
||||
golang.org/x/exp/shiny v0.0.0-20250606033433-dcc06ee1d476 // indirect
|
||||
golang.org/x/image v0.28.0 // indirect
|
||||
golang.org/x/mobile v0.0.0-20250606033058-a2a15c67f36f // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,175 @@
|
||||
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
|
||||
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0=
|
||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e h1:L+XrFvD0vBIBm+Wf9sFN6aU395t7JROoai0qXZraA4U=
|
||||
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e/go.mod h1:SUxUaAK/0UG5lYyZR1L1nC4AaYYvSSYTWQSH3FPcxKU=
|
||||
github.com/ebitengine/purego v0.8.3 h1:K+0AjQp63JEZTEMZiwsI9g0+hAMNohwUOtY0RPGexmc=
|
||||
github.com/ebitengine/purego v0.8.3/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/gen2brain/malgo v0.11.24 h1:hHcIJVfzWcEDHFdPl5Dl/CUSOjzOleY0zzAV8Kx+imE=
|
||||
github.com/gen2brain/malgo v0.11.24/go.mod h1:f9TtuN7DVrXMiV/yIceMeWpvanyVzJQMlBecJFVMxww=
|
||||
github.com/gen2brain/shm v0.1.1 h1:1cTVA5qcsUFixnDHl14TmRoxgfWEEZlTezpUj1vm5uQ=
|
||||
github.com/gen2brain/shm v0.1.1/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA=
|
||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=
|
||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY=
|
||||
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So=
|
||||
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A=
|
||||
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 h1:guBYzEaLz0Vfc/jv0czrr2z7qyzTOGC9hiQ0VC+hKjk=
|
||||
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7/go.mod h1:zx/1xUUeYPy3Pcmet8OSXLbF47l+3y6hIPpyLWoR9oc=
|
||||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0=
|
||||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o=
|
||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc=
|
||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA=
|
||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA=
|
||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
|
||||
github.com/getlantern/systray v1.2.2 h1:dCEHtfmvkJG7HZ8lS/sLklTH4RKUcIsKrAD9sThoEBE=
|
||||
github.com/getlantern/systray v1.2.2/go.mod h1:pXFOI1wwqwYXEhLPm9ZGjS2u/vVELeIgNMY5HvhHhcE=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-vgo/robotgo v0.110.8 h1:tWoUyqlZgDJ61bQju3WGSb/NIIfNV4TkYL3GFeWcHio=
|
||||
github.com/go-vgo/robotgo v0.110.8/go.mod h1:45w33PzprtFncpw4cAt9SzMtSY9XnVfotu+RrCVN8JE=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
|
||||
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
||||
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed1YDKpEz01A=
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU=
|
||||
github.com/leaanthony/gosod v1.0.4 h1:YLAbVyd591MRffDgxUOU1NwLhT9T1/YiwjKZpkNFeaI=
|
||||
github.com/leaanthony/gosod v1.0.4/go.mod h1:GKuIL0zzPj3O1SdWQOdgURSuhkF+Urizzxh26t9f1cw=
|
||||
github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js=
|
||||
github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8=
|
||||
github.com/leaanthony/u v1.1.1 h1:TUFjwDGlNX+WuwVEzDqQwC2lOv0P4uhTQw7CMFdiK7M=
|
||||
github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI=
|
||||
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc=
|
||||
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
|
||||
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVOV7XMi41HtzL8X2I=
|
||||
github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE=
|
||||
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
|
||||
github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/robotn/gohook v0.42.2 h1:AI9OVh5o59c76jp9Xcc4NpIvze2YeKX1Rn8JvflAUXY=
|
||||
github.com/robotn/gohook v0.42.2/go.mod h1:PYgH0f1EaxhCvNSqIVTfo+SIUh1MrM2Uhe2w7SvFJDE=
|
||||
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
|
||||
github.com/robotn/xgb v0.10.0 h1:O3kFbIwtwZ3pgLbp1h5slCQ4OpY8BdwugJLrUe6GPIM=
|
||||
github.com/robotn/xgb v0.10.0/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
|
||||
github.com/robotn/xgbutil v0.10.0 h1:gvf7mGQqCWQ68aHRtCxgdewRk+/KAJui6l3MJQQRCKw=
|
||||
github.com/robotn/xgbutil v0.10.0/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
|
||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||
github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw=
|
||||
github.com/shirou/gopsutil/v4 v4.25.4/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA=
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35 h1:wAZbkTZkqDzWsqxPh2qkBd3KvFU7tcxV0BP0Rnhkxog=
|
||||
github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35/go.mod h1:aMd4yDHLjbOuYP6fMxj1d9ACDQlSWwYztcpybGHCQc8=
|
||||
github.com/tc-hib/winres v0.3.1 h1:CwRjEGrKdbi5CvZ4ID+iyVhgyfatxFoizjPhzez9Io4=
|
||||
github.com/tc-hib/winres v0.3.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
|
||||
github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4=
|
||||
github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4=
|
||||
github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
|
||||
github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ=
|
||||
github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
|
||||
github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/vcaesar/gops v0.41.0 h1:FG748Jyw3FOuZnbzSgB+CQSx2e5LbLCPWV2JU1brFdc=
|
||||
github.com/vcaesar/gops v0.41.0/go.mod h1:/3048L7Rj7QjQKTSB+kKc7hDm63YhTWy5QJ10TCP37A=
|
||||
github.com/vcaesar/imgo v0.41.0 h1:kNLYGrThXhB9Dd6IwFmfPnxq9P6yat2g7dpPjr7OWO8=
|
||||
github.com/vcaesar/imgo v0.41.0/go.mod h1:/LGOge8etlzaVu/7l+UfhJxR6QqaoX5yeuzGIMfWb4I=
|
||||
github.com/vcaesar/keycode v0.10.1 h1:0DesGmMAPWpYTCYddOFiCMKCDKgNnwiQa2QXindVUHw=
|
||||
github.com/vcaesar/keycode v0.10.1/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
|
||||
github.com/vcaesar/screenshot v0.11.1 h1:GgPuN89XC4Yh38dLx4quPlSo3YiWWhwIria/j3LtrqU=
|
||||
github.com/vcaesar/screenshot v0.11.1/go.mod h1:gJNwHBiP1v1v7i8TQ4yV1XJtcyn2I/OJL7OziVQkwjs=
|
||||
github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4=
|
||||
github.com/vcaesar/tt v0.20.1/go.mod h1:cH2+AwGAJm19Wa6xvEa+0r+sXDJBT0QgNQey6mwqLeU=
|
||||
github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6NZijQ58=
|
||||
github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/wails/v2 v2.11.0 h1:seLacV8pqupq32IjS4Y7V8ucab0WZwtK6VvUVxSBtqQ=
|
||||
github.com/wailsapp/wails/v2 v2.11.0/go.mod h1:jrf0ZaM6+GBc1wRmXsM8cIvzlg0karYin3erahI4+0k=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
golang.design/x/clipboard v0.7.1 h1:OEG3CmcYRBNnRwpDp7+uWLiZi3hrMRJpE9JkkkYtz2c=
|
||||
golang.design/x/clipboard v0.7.1/go.mod h1:i5SiIqj0wLFw9P/1D7vfILFK0KHMk7ydE72HRrUIgkg=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
|
||||
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
|
||||
golang.org/x/exp/shiny v0.0.0-20250606033433-dcc06ee1d476 h1:Wdx0vgH5Wgsw+lF//LJKmWOJBLWX6nprsMqnf99rYDE=
|
||||
golang.org/x/exp/shiny v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:ygj7T6vSGhhm/9yTpOQQNvuAUFziTH7RUiH74EoE2C8=
|
||||
golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE=
|
||||
golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY=
|
||||
golang.org/x/mobile v0.0.0-20250606033058-a2a15c67f36f h1:/n+PL2HlfqeSiDCuhdBbRNlGS/g2fM4OHufalHaTVG8=
|
||||
golang.org/x/mobile v0.0.0-20250606033058-a2a15c67f36f/go.mod h1:ESkJ836Z6LpG6mTVAhA48LpfW/8fNR0ifStlH2axyfg=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Windows.Media.Control;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
class MediaCheck
|
||||
{
|
||||
static async Task<int> Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
var sessionManager = await GlobalSystemMediaTransportControlsSessionManager.RequestAsync();
|
||||
var session = sessionManager.GetCurrentSession();
|
||||
|
||||
if (session == null)
|
||||
{
|
||||
return 0; // No media session
|
||||
}
|
||||
|
||||
var playbackInfo = session.GetPlaybackInfo();
|
||||
var status = playbackInfo.PlaybackStatus;
|
||||
|
||||
// PlaybackStatus.Playing = 4
|
||||
if (status == GlobalSystemMediaTransportControlsSessionPlaybackStatus.Playing)
|
||||
{
|
||||
return 1; // Playing
|
||||
}
|
||||
|
||||
return 0; // Not playing (paused, stopped, etc.)
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0; // Error = assume not playing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<UseWindowsForms>false</UseWindowsForms>
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,33 @@
|
||||
# Check if media is playing using Windows SMTC
|
||||
Add-Type -AssemblyName System.Runtime.WindowsRuntime
|
||||
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
|
||||
|
||||
function Await($WinRtTask, $ResultType) {
|
||||
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
|
||||
$netTask = $asTask.Invoke($null, @($WinRtTask))
|
||||
$netTask.Wait(-1) | Out-Null
|
||||
$netTask.Result
|
||||
}
|
||||
|
||||
try {
|
||||
[Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager,Windows.Media,ContentType=WindowsRuntime] | Out-Null
|
||||
$sessionManager = Await ([Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager]::RequestAsync()) ([Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager])
|
||||
|
||||
$session = $sessionManager.GetCurrentSession()
|
||||
if ($null -eq $session) {
|
||||
exit 0 # No session = not playing
|
||||
}
|
||||
|
||||
$playbackInfo = $session.GetPlaybackInfo()
|
||||
$status = $playbackInfo.PlaybackStatus
|
||||
|
||||
# 4 = Playing
|
||||
if ($status -eq 4) {
|
||||
exit 1 # Playing
|
||||
}
|
||||
|
||||
exit 0 # Not playing
|
||||
}
|
||||
catch {
|
||||
exit 0 # Error = not playing
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package media
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"wis-free-v3/internal/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
user32 = syscall.NewLazyDLL("user32.dll")
|
||||
keybd_event = user32.NewProc("keybd_event")
|
||||
)
|
||||
|
||||
//go:embed check-media.ps1
|
||||
var checkMediaScript []byte
|
||||
|
||||
const (
|
||||
KEYEVENTF_KEYUP = 0x0002
|
||||
VK_MEDIA_PLAY_PAUSE = 0xB3
|
||||
)
|
||||
|
||||
// sendKey sends a Windows virtual key code
|
||||
func sendKey(key byte) {
|
||||
keybd_event.Call(
|
||||
uintptr(key),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
keybd_event.Call(
|
||||
uintptr(key),
|
||||
0,
|
||||
uintptr(KEYEVENTF_KEYUP),
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
// IsPlaying checks if media is currently playing using PowerShell SMTC query
|
||||
func IsPlaying() bool {
|
||||
// Write script to temp file
|
||||
tempDir := os.TempDir()
|
||||
scriptPath := filepath.Join(tempDir, "wis_check_media.ps1")
|
||||
|
||||
// Always write to ensure latest version
|
||||
err := os.WriteFile(scriptPath, checkMediaScript, 0644)
|
||||
if err != nil {
|
||||
logger.Error("Failed to write media check script: %v", err)
|
||||
return false
|
||||
}
|
||||
|
||||
cmd := exec.Command("powershell.exe",
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
"-WindowStyle", "Hidden",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", scriptPath,
|
||||
)
|
||||
|
||||
// Hide window completely
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
HideWindow: true,
|
||||
CreationFlags: 0x08000000, // CREATE_NO_WINDOW
|
||||
}
|
||||
|
||||
err = cmd.Run()
|
||||
|
||||
// Exit code 0 = not playing, Exit code 1 = playing
|
||||
if err == nil {
|
||||
return false // Exit code 0
|
||||
}
|
||||
|
||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||
return exitErr.ExitCode() == 1
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// TogglePlayPause sends the play/pause toggle key
|
||||
func TogglePlayPause() {
|
||||
sendKey(VK_MEDIA_PLAY_PAUSE)
|
||||
}
|
||||
|
||||
// PauseMedia checks if playing, pauses if so, returns whether we paused
|
||||
func PauseMedia() bool {
|
||||
wasPlaying := IsPlaying()
|
||||
if wasPlaying {
|
||||
TogglePlayPause()
|
||||
}
|
||||
return wasPlaying
|
||||
}
|
||||
|
||||
// ResumeMedia resumes only if we paused it
|
||||
func ResumeMedia(wasPaused bool) {
|
||||
if wasPaused {
|
||||
TogglePlayPause()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
// Package recorder provides audio capture functionality using the miniaudio library.
|
||||
// It records audio from the system's default capture device to WAV files.
|
||||
package recorder
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"math"
|
||||
"wis-free-v3/internal/logger"
|
||||
|
||||
"github.com/gen2brain/malgo"
|
||||
)
|
||||
|
||||
// Audio recording configuration
|
||||
const (
|
||||
SampleRate = 16000 // Hz - optimal for speech recognition
|
||||
NumChannels = 1 // Mono audio
|
||||
BitsPerSample = 16 // 16-bit PCM
|
||||
BytesPerSample = BitsPerSample / 8
|
||||
)
|
||||
|
||||
// MicrophoneInfo contains information about an available audio capture device.
|
||||
type MicrophoneInfo struct {
|
||||
ID string
|
||||
Name string
|
||||
IsDefault bool
|
||||
}
|
||||
|
||||
// VolumeCallback is called when new volume levels are calculated
|
||||
type VolumeCallback func(level float64)
|
||||
|
||||
// AudioRecorder handles audio capture from the system microphone.
|
||||
type AudioRecorder struct {
|
||||
ctx *malgo.AllocatedContext
|
||||
deviceConfig malgo.DeviceConfig
|
||||
device *malgo.Device
|
||||
outputFile *os.File
|
||||
dataSize uint32
|
||||
isRecording bool
|
||||
deviceID *string
|
||||
OnVolume VolumeCallback
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// NewRecorder creates a new audio recorder instance.
|
||||
// Returns an error if the audio context cannot be initialized.
|
||||
func NewRecorder() (*AudioRecorder, error) {
|
||||
ctx, err := malgo.InitContext(nil, malgo.ContextConfig{}, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to initialize audio context: %w", err)
|
||||
}
|
||||
|
||||
deviceConfig := malgo.DefaultDeviceConfig(malgo.Capture)
|
||||
deviceConfig.Capture.Format = malgo.FormatS16
|
||||
deviceConfig.Capture.Channels = NumChannels
|
||||
deviceConfig.SampleRate = SampleRate
|
||||
deviceConfig.Alsa.NoMMap = 1
|
||||
|
||||
return &AudioRecorder{
|
||||
ctx: ctx,
|
||||
deviceConfig: deviceConfig,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetMicrophones returns a list of available audio capture devices.
|
||||
func (r *AudioRecorder) GetMicrophones() ([]MicrophoneInfo, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if r.ctx == nil {
|
||||
return nil, fmt.Errorf("audio context not initialized")
|
||||
}
|
||||
|
||||
devices, err := r.ctx.Context.Devices(malgo.Capture)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to enumerate devices: %w", err)
|
||||
}
|
||||
|
||||
mics := []MicrophoneInfo{
|
||||
{ID: "", Name: "System Default", IsDefault: true},
|
||||
}
|
||||
|
||||
for _, info := range devices {
|
||||
name := info.Name()
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
mics = append(mics, MicrophoneInfo{
|
||||
ID: fmt.Sprintf("%v", info.ID),
|
||||
Name: name,
|
||||
IsDefault: false,
|
||||
})
|
||||
|
||||
logger.Info("Found microphone: %s", name)
|
||||
}
|
||||
|
||||
return mics, nil
|
||||
}
|
||||
|
||||
// SetDevice configures the recorder to use a specific device.
|
||||
// Pass an empty string to use the system default device.
|
||||
func (r *AudioRecorder) SetDevice(deviceID string) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if deviceID == "" {
|
||||
r.deviceID = nil
|
||||
} else {
|
||||
r.deviceID = &deviceID
|
||||
}
|
||||
}
|
||||
|
||||
// Start begins recording audio to the specified WAV file.
|
||||
// Returns an error if recording is already in progress or initialization fails.
|
||||
func (r *AudioRecorder) Start(filename string) error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if r.isRecording {
|
||||
return fmt.Errorf("recording already in progress")
|
||||
}
|
||||
|
||||
// Create output file
|
||||
file, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create output file: %w", err)
|
||||
}
|
||||
r.outputFile = file
|
||||
r.dataSize = 0
|
||||
|
||||
// Write placeholder WAV header
|
||||
if err := r.writeWAVHeader(0); err != nil {
|
||||
file.Close()
|
||||
return fmt.Errorf("failed to write WAV header: %w", err)
|
||||
}
|
||||
|
||||
// Configure audio callback
|
||||
callbacks := malgo.DeviceCallbacks{
|
||||
Data: r.onAudioData,
|
||||
}
|
||||
|
||||
// Use custom device if specified
|
||||
if r.deviceID != nil {
|
||||
// Enumerate devices to find the matching pointer
|
||||
devices, err := r.ctx.Context.Devices(malgo.Capture)
|
||||
if err == nil {
|
||||
for _, info := range devices {
|
||||
if fmt.Sprintf("%v", info.ID) == *r.deviceID {
|
||||
r.deviceConfig.Capture.DeviceID = info.ID.Pointer()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r.deviceConfig.Capture.DeviceID = nil
|
||||
}
|
||||
|
||||
// Initialize device
|
||||
device, err := malgo.InitDevice(r.ctx.Context, r.deviceConfig, callbacks)
|
||||
if err != nil {
|
||||
file.Close()
|
||||
return fmt.Errorf("failed to initialize audio device: %w", err)
|
||||
}
|
||||
r.device = device
|
||||
|
||||
// Start capturing
|
||||
if err := device.Start(); err != nil {
|
||||
device.Uninit()
|
||||
file.Close()
|
||||
return fmt.Errorf("failed to start audio capture: %w", err)
|
||||
}
|
||||
|
||||
r.isRecording = true
|
||||
logger.Info("Recording started: %s", filename)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop ends the current recording and finalizes the WAV file.
|
||||
func (r *AudioRecorder) Stop() error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if !r.isRecording {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop and cleanup device
|
||||
if r.device != nil {
|
||||
r.device.Uninit()
|
||||
r.device = nil
|
||||
}
|
||||
|
||||
// Finalize WAV file
|
||||
if r.outputFile != nil {
|
||||
// Rewrite header with correct data size
|
||||
r.outputFile.Seek(0, 0)
|
||||
if err := r.writeWAVHeader(r.dataSize); err != nil {
|
||||
logger.Error("Failed to update WAV header: %v", err)
|
||||
}
|
||||
r.outputFile.Close()
|
||||
r.outputFile = nil
|
||||
}
|
||||
|
||||
r.isRecording = false
|
||||
logger.Info("Recording stopped: %d bytes captured", r.dataSize)
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsRecording returns true if recording is currently in progress.
|
||||
func (r *AudioRecorder) IsRecording() bool {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
return r.isRecording
|
||||
}
|
||||
|
||||
// Cleanup releases all audio resources.
|
||||
func (r *AudioRecorder) Cleanup() {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if r.device != nil {
|
||||
r.device.Uninit()
|
||||
r.device = nil
|
||||
}
|
||||
|
||||
if r.ctx != nil {
|
||||
r.ctx.Free()
|
||||
r.ctx = nil
|
||||
}
|
||||
|
||||
logger.Info("Audio recorder cleaned up")
|
||||
}
|
||||
|
||||
// onAudioData is called by miniaudio when audio data is available.
|
||||
func (r *AudioRecorder) onAudioData(_, inputSamples []byte, _ uint32) {
|
||||
if r.outputFile != nil && len(inputSamples) > 0 {
|
||||
n, _ := r.outputFile.Write(inputSamples)
|
||||
r.dataSize += uint32(n)
|
||||
|
||||
// Calculate volume if callback is set
|
||||
if r.OnVolume != nil {
|
||||
// S16LE: 2 bytes per sample
|
||||
samples := len(inputSamples) / 2
|
||||
var maxAmplitude float64
|
||||
for i := 0; i < samples; i++ {
|
||||
// Read as int16
|
||||
val := int16(binary.LittleEndian.Uint16(inputSamples[i*2 : i*2+2]))
|
||||
absVal := math.Abs(float64(val))
|
||||
if absVal > maxAmplitude {
|
||||
maxAmplitude = absVal
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize to 0.0 - 1.0 (max for int16 is 32767)
|
||||
level := maxAmplitude / 32767.0
|
||||
r.OnVolume(level)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// writeWAVHeader writes a standard RIFF WAV header to the output file.
|
||||
func (r *AudioRecorder) writeWAVHeader(dataSize uint32) error {
|
||||
sampleRate := uint32(SampleRate)
|
||||
numChannels := uint16(NumChannels)
|
||||
bitsPerSample := uint16(BitsPerSample)
|
||||
|
||||
byteRate := sampleRate * uint32(numChannels) * uint32(bitsPerSample/8)
|
||||
blockAlign := numChannels * (bitsPerSample / 8)
|
||||
|
||||
// RIFF chunk
|
||||
r.outputFile.Write([]byte("RIFF"))
|
||||
binary.Write(r.outputFile, binary.LittleEndian, uint32(36+dataSize))
|
||||
r.outputFile.Write([]byte("WAVE"))
|
||||
|
||||
// fmt sub-chunk
|
||||
r.outputFile.Write([]byte("fmt "))
|
||||
binary.Write(r.outputFile, binary.LittleEndian, uint32(16)) // Subchunk1Size
|
||||
binary.Write(r.outputFile, binary.LittleEndian, uint16(1)) // AudioFormat (PCM)
|
||||
binary.Write(r.outputFile, binary.LittleEndian, numChannels)
|
||||
binary.Write(r.outputFile, binary.LittleEndian, sampleRate)
|
||||
binary.Write(r.outputFile, binary.LittleEndian, byteRate)
|
||||
binary.Write(r.outputFile, binary.LittleEndian, blockAlign)
|
||||
binary.Write(r.outputFile, binary.LittleEndian, bitsPerSample)
|
||||
|
||||
// data sub-chunk
|
||||
r.outputFile.Write([]byte("data"))
|
||||
binary.Write(r.outputFile, binary.LittleEndian, dataSize)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// Package config handles application configuration persistence and management.
|
||||
// Configuration is stored as JSON in the user's home directory.
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Application defaults
|
||||
const (
|
||||
DefaultShortcut = "alt+z"
|
||||
DefaultWhisperModel = "whisper-large-v3-turbo"
|
||||
DefaultAIModel = "llama-3.3-70b-versatile"
|
||||
DefaultLanguage = "en"
|
||||
ConfigFileName = "config.json"
|
||||
ConfigDirName = ".wis-free-v3"
|
||||
)
|
||||
|
||||
// DefaultAIPrompt is the system prompt used for text refinement.
|
||||
const DefaultAIPrompt = `You are a minimal text editor. Your ONLY job is to fix basic grammar and add appropriate punctuation to the transcribed speech. CRITICAL RULES: 1) NEVER answer questions - transcribe them exactly as spoken. 2) NEVER format text as lists, bullet points, or structured formats. 3) NEVER add, remove, or reorganize content. 4) NEVER interpret intent or provide helpful formatting. 5) Keep the exact same sentence structure and word order. 6) Only fix obvious grammar errors and add periods, commas, and capitalization. Return ONLY the minimally edited text, nothing else.`
|
||||
|
||||
// HistoryItem represents a single transcription history entry.
|
||||
type HistoryItem struct {
|
||||
Text string `json:"text"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
// Config represents the complete application configuration.
|
||||
type Config struct {
|
||||
APIKey string `json:"api_key"`
|
||||
Shortcut string `json:"shortcut"`
|
||||
WhisperModel string `json:"whisper_model"`
|
||||
AIModel string `json:"ai_model"`
|
||||
AIPrompt string `json:"ai_prompt"`
|
||||
Language string `json:"language"`
|
||||
MicrophoneDevice *int `json:"microphone_device"`
|
||||
History []HistoryItem `json:"history"`
|
||||
}
|
||||
|
||||
// DefaultConfig returns a new configuration with sensible default values.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
APIKey: "",
|
||||
Shortcut: DefaultShortcut,
|
||||
WhisperModel: DefaultWhisperModel,
|
||||
AIModel: DefaultAIModel,
|
||||
AIPrompt: DefaultAIPrompt,
|
||||
Language: DefaultLanguage,
|
||||
MicrophoneDevice: nil,
|
||||
History: []HistoryItem{},
|
||||
}
|
||||
}
|
||||
|
||||
// Load reads the configuration from the specified file path.
|
||||
// If the file doesn't exist, it returns a default configuration.
|
||||
func Load(configPath string) (*Config, error) {
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
return DefaultConfig(), nil
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var cfg Config
|
||||
if err := json.Unmarshal(data, &cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Apply defaults for any missing fields
|
||||
cfg.applyDefaults()
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
// Save writes the configuration to the specified file path.
|
||||
// If configPath is empty, it uses the default configuration path.
|
||||
func Save(c *Config, configPath string) error {
|
||||
if configPath == "" {
|
||||
var err error
|
||||
configPath, err = GetConfigPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the directory exists
|
||||
dir := filepath.Dir(configPath)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := json.MarshalIndent(c, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(configPath, data, 0644)
|
||||
}
|
||||
|
||||
// GetConfigPath returns the default configuration file path.
|
||||
func GetConfigPath() (string, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
configDir := filepath.Join(homeDir, ConfigDirName)
|
||||
return filepath.Join(configDir, ConfigFileName), nil
|
||||
}
|
||||
|
||||
// applyDefaults sets default values for any empty fields.
|
||||
func (c *Config) applyDefaults() {
|
||||
if c.Shortcut == "" {
|
||||
c.Shortcut = DefaultShortcut
|
||||
}
|
||||
if c.WhisperModel == "" {
|
||||
c.WhisperModel = DefaultWhisperModel
|
||||
}
|
||||
if c.AIModel == "" {
|
||||
c.AIModel = DefaultAIModel
|
||||
}
|
||||
if c.AIPrompt == "" {
|
||||
c.AIPrompt = DefaultAIPrompt
|
||||
}
|
||||
if c.Language == "" {
|
||||
c.Language = DefaultLanguage
|
||||
}
|
||||
if c.History == nil {
|
||||
c.History = []HistoryItem{}
|
||||
}
|
||||
}
|
||||
|
||||
// AddHistoryItem adds a new transcription to the history.
|
||||
func (c *Config) AddHistoryItem(text, timestamp string) {
|
||||
c.History = append(c.History, HistoryItem{
|
||||
Text: text,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
}
|
||||
|
||||
// ClearHistory removes all history items.
|
||||
func (c *Config) ClearHistory() {
|
||||
c.History = []HistoryItem{}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
// Package hotkey provides global keyboard shortcut detection and handling.
|
||||
// It uses the gohook library to capture system-wide key events.
|
||||
package hotkey
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"wis-free-v3/internal/logger"
|
||||
|
||||
hook "github.com/robotn/gohook"
|
||||
)
|
||||
|
||||
// Listener handles global hotkey events and triggers callbacks when the
|
||||
// configured shortcut is pressed and released.
|
||||
type Listener struct {
|
||||
startCallback func()
|
||||
stopCallback func()
|
||||
isListening bool
|
||||
stopChan chan struct{}
|
||||
triggerKeys []uint16
|
||||
modifiers [][]uint16
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// NewListener creates a new hotkey listener with the specified shortcut and callbacks.
|
||||
// The shortcut should be in format like "ctrl+k" or "alt+shift+space".
|
||||
// onStart is called when the shortcut is pressed, onStop when it's released.
|
||||
func NewListener(shortcut string, onStart, onStop func()) *Listener {
|
||||
trigger, mods := ParseShortcut(shortcut)
|
||||
|
||||
logger.Info("Hotkey listener created: shortcut=%s, trigger=%d, modifiers=%v",
|
||||
shortcut, trigger, mods)
|
||||
|
||||
return &Listener{
|
||||
startCallback: onStart,
|
||||
stopCallback: onStop,
|
||||
stopChan: make(chan struct{}),
|
||||
triggerKeys: trigger,
|
||||
modifiers: mods,
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateShortcut changes the shortcut without stopping the listener.
|
||||
// This allows hot-swapping the shortcut while the application is running.
|
||||
func (l *Listener) UpdateShortcut(shortcut string) {
|
||||
trigger, mods := ParseShortcut(shortcut)
|
||||
|
||||
l.mu.Lock()
|
||||
l.triggerKeys = trigger
|
||||
l.modifiers = mods
|
||||
l.mu.Unlock()
|
||||
|
||||
logger.Info("Hotkey updated: shortcut=%s, trigger=%d", shortcut, trigger)
|
||||
}
|
||||
|
||||
// Start begins listening for the configured shortcut in a background goroutine.
|
||||
// It's safe to call Start multiple times; subsequent calls are ignored.
|
||||
func (l *Listener) Start() {
|
||||
if l.isListening {
|
||||
return
|
||||
}
|
||||
l.isListening = true
|
||||
|
||||
go l.eventLoop()
|
||||
}
|
||||
|
||||
// Stop terminates the hotkey listener.
|
||||
// It's safe to call Stop multiple times.
|
||||
func (l *Listener) Stop() {
|
||||
if !l.isListening {
|
||||
return
|
||||
}
|
||||
l.isListening = false
|
||||
close(l.stopChan)
|
||||
logger.Info("Hotkey listener stopped")
|
||||
}
|
||||
|
||||
// eventLoop runs the main keyboard event processing loop.
|
||||
func (l *Listener) eventLoop() {
|
||||
logger.Info("Hotkey listener started")
|
||||
|
||||
evChan := hook.Start()
|
||||
defer hook.End()
|
||||
|
||||
var isRecording bool
|
||||
pressedKeys := make(map[uint16]bool)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-l.stopChan:
|
||||
return
|
||||
|
||||
case ev := <-evChan:
|
||||
l.handleKeyEvent(ev, pressedKeys, &isRecording)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handleKeyEvent processes a single keyboard event.
|
||||
func (l *Listener) handleKeyEvent(ev hook.Event, pressedKeys map[uint16]bool, isRecording *bool) {
|
||||
// Update pressed keys state
|
||||
switch ev.Kind {
|
||||
case hook.KeyDown, hook.KeyHold:
|
||||
pressedKeys[ev.Rawcode] = true
|
||||
case hook.KeyUp:
|
||||
delete(pressedKeys, ev.Rawcode)
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
// Read current configuration
|
||||
l.mu.RLock()
|
||||
triggerVariants := l.triggerKeys
|
||||
modGroups := l.modifiers
|
||||
l.mu.RUnlock()
|
||||
|
||||
if len(triggerVariants) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 1. Check trigger key first (fast path)
|
||||
triggerPressed := false
|
||||
for _, t := range triggerVariants {
|
||||
if pressedKeys[t] {
|
||||
triggerPressed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 2. State transition handling
|
||||
active := false
|
||||
if triggerPressed {
|
||||
active = true
|
||||
for _, group := range modGroups {
|
||||
groupPressed := false
|
||||
for _, m := range group {
|
||||
if pressedKeys[m] {
|
||||
groupPressed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !groupPressed {
|
||||
active = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if active && !*isRecording {
|
||||
logger.Info("Shortcut activated: starting recording")
|
||||
l.startCallback()
|
||||
*isRecording = true
|
||||
} else if !active && *isRecording {
|
||||
logger.Info("Shortcut released: stopping recording")
|
||||
l.stopCallback()
|
||||
*isRecording = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
// Package hotkey provides global keyboard shortcut detection and handling.
|
||||
package hotkey
|
||||
|
||||
import "strings"
|
||||
|
||||
// Windows Virtual Key Codes
|
||||
// See: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||
const (
|
||||
VK_LCTRL = 162 // Left Control
|
||||
VK_RCTRL = 163 // Right Control
|
||||
VK_LSHIFT = 160 // Left Shift
|
||||
VK_RSHIFT = 161 // Right Shift
|
||||
VK_LALT = 164 // Left Alt (Menu)
|
||||
VK_RALT = 165 // Right Alt (Menu)
|
||||
VK_LWIN = 91 // Left Windows key
|
||||
VK_RWIN = 92 // Right Windows key
|
||||
)
|
||||
|
||||
// keyMap maps human-readable key names to Windows Virtual Key Codes.
|
||||
// Each key may have multiple valid codes (e.g., left and right variants).
|
||||
var keyMap = map[string][]uint16{
|
||||
// Modifier keys
|
||||
"ctrl": {VK_LCTRL, VK_RCTRL, 17},
|
||||
"control": {VK_LCTRL, VK_RCTRL, 17},
|
||||
"shift": {VK_LSHIFT, VK_RSHIFT, 16},
|
||||
"alt": {VK_LALT, VK_RALT, 18},
|
||||
"win": {VK_LWIN, VK_RWIN, 91, 92},
|
||||
"windows": {VK_LWIN, VK_RWIN, 91, 92},
|
||||
"meta": {VK_LWIN, VK_RWIN, 91, 92},
|
||||
"super": {VK_LWIN, VK_RWIN, 91, 92},
|
||||
|
||||
// Special keys
|
||||
"backspace": {8},
|
||||
"tab": {9},
|
||||
"enter": {13},
|
||||
"escape": {27},
|
||||
"esc": {27},
|
||||
"space": {32},
|
||||
"left": {37},
|
||||
"up": {38},
|
||||
"right": {39},
|
||||
"down": {40},
|
||||
"delete": {46},
|
||||
"del": {46},
|
||||
|
||||
// Number keys (top row)
|
||||
"0": {48}, "1": {49}, "2": {50}, "3": {51}, "4": {52},
|
||||
"5": {53}, "6": {54}, "7": {55}, "8": {56}, "9": {57},
|
||||
|
||||
// Letter keys
|
||||
"a": {65}, "b": {66}, "c": {67}, "d": {68}, "e": {69},
|
||||
"f": {70}, "g": {71}, "h": {72}, "i": {73}, "j": {74},
|
||||
"k": {75}, "l": {76}, "m": {77}, "n": {78}, "o": {79},
|
||||
"p": {80}, "q": {81}, "r": {82}, "s": {83}, "t": {84},
|
||||
"u": {85}, "v": {86}, "w": {87}, "x": {88}, "y": {89},
|
||||
"z": {90},
|
||||
|
||||
// Function keys
|
||||
"f1": {112}, "f2": {113}, "f3": {114}, "f4": {115},
|
||||
"f5": {116}, "f6": {117}, "f7": {118}, "f8": {119},
|
||||
"f9": {120}, "f10": {121}, "f11": {122}, "f12": {123},
|
||||
}
|
||||
|
||||
// modifierKeys identifies which key names are modifiers.
|
||||
var modifierKeys = map[string]bool{
|
||||
"ctrl": true, "control": true,
|
||||
"shift": true,
|
||||
"alt": true,
|
||||
"win": true, "windows": true, "meta": true, "super": true,
|
||||
}
|
||||
|
||||
// ParseShortcut parses a shortcut string into a trigger key and modifier keys.
|
||||
// The shortcut format is "modifier+modifier+key" (e.g., "ctrl+shift+k").
|
||||
//
|
||||
// Returns:
|
||||
// - trigger: the primary key code that activates the shortcut
|
||||
// - modifiers: slice of modifier key code variants that must be held
|
||||
func ParseShortcut(shortcut string) (trigger []uint16, modifiers [][]uint16) {
|
||||
parts := strings.Split(strings.ToLower(strings.TrimSpace(shortcut)), "+")
|
||||
if len(parts) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Last part is always the trigger key
|
||||
triggerName := strings.TrimSpace(parts[len(parts)-1])
|
||||
if codes, ok := keyMap[triggerName]; ok && len(codes) > 0 {
|
||||
trigger = codes
|
||||
}
|
||||
|
||||
// Preceding parts are modifiers
|
||||
for i := 0; i < len(parts)-1; i++ {
|
||||
modName := strings.TrimSpace(parts[i])
|
||||
if codes, ok := keyMap[modName]; ok {
|
||||
modifiers = append(modifiers, codes)
|
||||
}
|
||||
}
|
||||
|
||||
return trigger, modifiers
|
||||
}
|
||||
|
||||
// IsModifier returns true if the given key name is a modifier key.
|
||||
func IsModifier(keyName string) bool {
|
||||
return modifierKeys[strings.ToLower(keyName)]
|
||||
}
|
||||
|
||||
// GetKeyCode returns the virtual key code(s) for a given key name.
|
||||
// Returns nil if the key name is not recognized.
|
||||
func GetKeyCode(keyName string) []uint16 {
|
||||
return keyMap[strings.ToLower(keyName)]
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// Package logger provides a simple file-based logging system for the application.
|
||||
// Logs are written to date-stamped files in the user's config directory.
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Log level constants
|
||||
const (
|
||||
logFileMode = 0644
|
||||
logDirMode = 0755
|
||||
)
|
||||
|
||||
var (
|
||||
logFile *os.File
|
||||
logMutex sync.Mutex
|
||||
isInitialized bool
|
||||
)
|
||||
|
||||
// Init initializes the logger with a new log file for today's date.
|
||||
// It creates the log directory if it doesn't exist.
|
||||
func Init() error {
|
||||
logMutex.Lock()
|
||||
defer logMutex.Unlock()
|
||||
|
||||
if isInitialized {
|
||||
return nil
|
||||
}
|
||||
|
||||
logPath, err := getLogPath()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get log path: %w", err)
|
||||
}
|
||||
|
||||
// Ensure log directory exists
|
||||
logDir := filepath.Dir(logPath)
|
||||
if err := os.MkdirAll(logDir, logDirMode); err != nil {
|
||||
return fmt.Errorf("failed to create log directory: %w", err)
|
||||
}
|
||||
|
||||
// Open or create log file
|
||||
logFile, err = os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, logFileMode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open log file: %w", err)
|
||||
}
|
||||
|
||||
isInitialized = true
|
||||
Info("Logger initialized")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close closes the log file handle.
|
||||
func Close() {
|
||||
logMutex.Lock()
|
||||
defer logMutex.Unlock()
|
||||
|
||||
if logFile != nil {
|
||||
logFile.Close()
|
||||
logFile = nil
|
||||
}
|
||||
isInitialized = false
|
||||
}
|
||||
|
||||
// Info logs an informational message with timestamp.
|
||||
// Modified to do nothing so only errors are logged.
|
||||
func Info(format string, args ...interface{}) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Error logs an error message with timestamp.
|
||||
func Error(format string, args ...interface{}) {
|
||||
log("ERROR", format, args...)
|
||||
}
|
||||
|
||||
// log writes a formatted log message to the log file.
|
||||
func log(level, format string, args ...interface{}) {
|
||||
logMutex.Lock()
|
||||
defer logMutex.Unlock()
|
||||
|
||||
// Auto-initialize if needed
|
||||
if !isInitialized {
|
||||
if err := initWithoutLock(); err != nil {
|
||||
// Fall back to stderr if logging fails
|
||||
fmt.Fprintf(os.Stderr, "[%s] %s: %s\n", level, time.Now().Format(time.RFC3339), fmt.Sprintf(format, args...))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
timestamp := time.Now().Format("2006-01-02 15:04:05")
|
||||
message := fmt.Sprintf(format, args...)
|
||||
logLine := fmt.Sprintf("[%s] %s: %s\n", timestamp, level, message)
|
||||
|
||||
if logFile != nil {
|
||||
logFile.WriteString(logLine)
|
||||
logFile.Sync()
|
||||
}
|
||||
}
|
||||
|
||||
// initWithoutLock initializes the logger without acquiring the mutex.
|
||||
// This should only be called when the lock is already held.
|
||||
func initWithoutLock() error {
|
||||
if isInitialized {
|
||||
return nil
|
||||
}
|
||||
|
||||
logPath, err := getLogPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logDir := filepath.Dir(logPath)
|
||||
if err := os.MkdirAll(logDir, logDirMode); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logFile, err = os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, logFileMode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
isInitialized = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// getLogPath returns the path to the log file.
|
||||
func getLogPath() (string, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return filepath.Join(homeDir, ".wis-free-v3", "logs"), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
// Package transcriber provides audio transcription and text refinement services
|
||||
// using the Groq API for Whisper-based speech recognition and LLM text processing.
|
||||
package transcriber
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"wis-free-v3/internal/logger"
|
||||
)
|
||||
|
||||
// API endpoints
|
||||
const (
|
||||
transcriptionEndpoint = "https://api.groq.com/openai/v1/audio/transcriptions"
|
||||
chatEndpoint = "https://api.groq.com/openai/v1/chat/completions"
|
||||
)
|
||||
|
||||
// Default configuration values
|
||||
const (
|
||||
DefaultWhisperModel = "whisper-large-v3-turbo"
|
||||
DefaultAIModel = "llama-3.3-70b-versatile"
|
||||
HTTPTimeout = 60 * time.Second
|
||||
RefinementTemp = 0.3 // Temperature for text refinement (lower = more deterministic)
|
||||
)
|
||||
|
||||
// DefaultAIPrompt provides instructions for minimal text editing.
|
||||
const DefaultAIPrompt = `You are a minimal text editor. Your ONLY job is to fix basic grammar and add appropriate punctuation to the transcribed speech. CRITICAL RULES: 1) NEVER answer questions - transcribe them exactly as spoken. 2) NEVER format text as lists, bullet points, or structured formats. 3) NEVER add, remove, or reorganize content. 4) NEVER interpret intent or provide helpful formatting. 5) Keep the exact same sentence structure and word order. 6) Only fix obvious grammar errors and add periods, commas, and capitalization. Return ONLY the minimally edited text, nothing else.`
|
||||
|
||||
// Client handles API communication with Groq services.
|
||||
type Client struct {
|
||||
apiKey string
|
||||
whisperModel string
|
||||
aiModel string
|
||||
aiPrompt string
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// NewClient creates a new transcriber client with the specified configuration.
|
||||
// Empty values for models or prompt will use sensible defaults.
|
||||
func NewClient(apiKey, whisperModel, aiModel, aiPrompt string) *Client {
|
||||
if whisperModel == "" {
|
||||
whisperModel = DefaultWhisperModel
|
||||
}
|
||||
if aiModel == "" {
|
||||
aiModel = DefaultAIModel
|
||||
}
|
||||
if aiPrompt == "" {
|
||||
aiPrompt = DefaultAIPrompt
|
||||
}
|
||||
|
||||
return &Client{
|
||||
apiKey: apiKey,
|
||||
whisperModel: whisperModel,
|
||||
aiModel: aiModel,
|
||||
aiPrompt: aiPrompt,
|
||||
httpClient: &http.Client{
|
||||
Timeout: HTTPTimeout,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// TranscribeAudio converts an audio file to text using Whisper.
|
||||
// Returns the transcribed text or an error if the operation fails.
|
||||
func (c *Client) TranscribeAudio(audioFilePath, language string) (string, error) {
|
||||
if c.apiKey == "" {
|
||||
return "", fmt.Errorf("API key is missing - please configure it in Settings")
|
||||
}
|
||||
|
||||
// Validate file exists and get size for logging
|
||||
fileInfo, err := os.Stat(audioFilePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("audio file not found: %w", err)
|
||||
}
|
||||
logger.Info("Transcribing audio: %s (%.2f KB) in %s", audioFilePath, float64(fileInfo.Size())/1024, language)
|
||||
|
||||
// Prepare the multipart request
|
||||
body, contentType, err := c.prepareAudioRequest(audioFilePath, language)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Create and send request
|
||||
req, err := http.NewRequest(http.MethodPost, transcriptionEndpoint, body)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+c.apiKey)
|
||||
req.Header.Set("Content-Type", contentType)
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("API request failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Handle response
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", c.handleAPIError(resp, "transcription")
|
||||
}
|
||||
|
||||
var result struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
||||
return "", fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
|
||||
logger.Info("Transcription complete: %d characters", len(result.Text))
|
||||
return result.Text, nil
|
||||
}
|
||||
|
||||
// RefineText uses an LLM to clean up and correct transcribed text.
|
||||
// If the AI model is set to "None" or the API key is missing, returns the original text.
|
||||
func (c *Client) RefineText(text string) (string, error) {
|
||||
if c.apiKey == "" || c.aiModel == "None" {
|
||||
return text, nil
|
||||
}
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"model": c.aiModel,
|
||||
"messages": []map[string]string{
|
||||
{"role": "system", "content": c.aiPrompt},
|
||||
{"role": "user", "content": text},
|
||||
},
|
||||
"temperature": RefinementTemp,
|
||||
}
|
||||
|
||||
// Add special parameters for OpenAI reasoning models
|
||||
if strings.Contains(c.aiModel, "gpt-oss") || strings.Contains(c.aiModel, "openai/") {
|
||||
payload["max_completion_tokens"] = 8192
|
||||
payload["top_p"] = 1
|
||||
|
||||
// Set reasoning effort based on model name
|
||||
effort := "low"
|
||||
actualModel := c.aiModel
|
||||
if strings.HasSuffix(c.aiModel, "-high") {
|
||||
effort = "high"
|
||||
actualModel = strings.TrimSuffix(c.aiModel, "-high")
|
||||
}
|
||||
payload["reasoning_effort"] = effort
|
||||
payload["model"] = actualModel
|
||||
}
|
||||
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
logger.Error("Failed to marshal refinement request: %v", err)
|
||||
return text, nil // Return original text on error
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, chatEndpoint, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
logger.Error("Failed to create refinement request: %v", err)
|
||||
return text, nil
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+c.apiKey)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
logger.Error("Refinement request failed: %v", err)
|
||||
return text, nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
c.handleAPIError(resp, "refinement")
|
||||
return text, nil
|
||||
}
|
||||
|
||||
var result struct {
|
||||
Choices []struct {
|
||||
Message struct {
|
||||
Content string `json:"content"`
|
||||
} `json:"message"`
|
||||
} `json:"choices"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
||||
logger.Error("Failed to parse refinement response: %v", err)
|
||||
return text, nil
|
||||
}
|
||||
|
||||
if len(result.Choices) > 0 && result.Choices[0].Message.Content != "" {
|
||||
logger.Info("Text refinement complete")
|
||||
return result.Choices[0].Message.Content, nil
|
||||
}
|
||||
|
||||
return text, nil
|
||||
}
|
||||
|
||||
// prepareAudioRequest creates a multipart form request body for audio transcription.
|
||||
func (c *Client) prepareAudioRequest(audioFilePath, language string) (*bytes.Buffer, string, error) {
|
||||
file, err := os.Open(audioFilePath)
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("failed to open audio file: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
body := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(body)
|
||||
|
||||
// Add audio file
|
||||
part, err := writer.CreateFormFile("file", "audio.wav")
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("failed to create form file: %w", err)
|
||||
}
|
||||
if _, err := io.Copy(part, file); err != nil {
|
||||
return nil, "", fmt.Errorf("failed to copy audio data: %w", err)
|
||||
}
|
||||
|
||||
// Add model parameter
|
||||
if err := writer.WriteField("model", c.whisperModel); err != nil {
|
||||
return nil, "", fmt.Errorf("failed to write model field: %w", err)
|
||||
}
|
||||
|
||||
// Add language parameter
|
||||
if language != "" {
|
||||
if err := writer.WriteField("language", language); err != nil {
|
||||
return nil, "", fmt.Errorf("failed to write language field: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Add temperature=0 for more consistent results
|
||||
if err := writer.WriteField("temperature", "0"); err != nil {
|
||||
return nil, "", fmt.Errorf("failed to write temperature field: %w", err)
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
return nil, "", fmt.Errorf("failed to finalize request: %w", err)
|
||||
}
|
||||
|
||||
return body, writer.FormDataContentType(), nil
|
||||
}
|
||||
|
||||
// handleAPIError logs and formats API error responses.
|
||||
func (c *Client) handleAPIError(resp *http.Response, operation string) error {
|
||||
bodyBytes, _ := io.ReadAll(resp.Body)
|
||||
logger.Error("API %s error: status=%d body=%s", operation, resp.StatusCode, string(bodyBytes))
|
||||
return fmt.Errorf("%s failed with status %d", operation, resp.StatusCode)
|
||||
}
|
||||
@@ -0,0 +1,452 @@
|
||||
// Package whisper provides local offline transcription using whisper.cpp
|
||||
package whisper
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"wis-free-v3/internal/logger"
|
||||
)
|
||||
|
||||
// Download URLs
|
||||
const (
|
||||
// Whisper.cpp Windows binary from ggml-org GitHub releases
|
||||
// Using Vulkan build to support Intel iGPU, AMD, and Nvidia
|
||||
whisperBinaryURL = "https://github.com/jerryshell/whisper.cpp-windows-vulkan-bin/releases/download/v1.0.0/whisper.cpp-windows-vulkan.zip"
|
||||
// Model URLs from Hugging Face
|
||||
modelBaseURL = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main"
|
||||
)
|
||||
|
||||
// Available models
|
||||
var Models = map[string]struct {
|
||||
Filename string
|
||||
Size string
|
||||
}{
|
||||
"tiny": {"ggml-tiny.bin", "75 MB"},
|
||||
"base": {"ggml-base.bin", "150 MB"},
|
||||
"small": {"ggml-small.bin", "500 MB"},
|
||||
"medium": {"ggml-medium.bin", "1.5 GB"},
|
||||
}
|
||||
|
||||
// InstalledInfo stores information about the installed whisper
|
||||
type InstalledInfo struct {
|
||||
Version string `json:"version"`
|
||||
Model string `json:"model"`
|
||||
InstallPath string `json:"install_path"`
|
||||
}
|
||||
|
||||
// Manager handles whisper installation and execution
|
||||
type Manager struct {
|
||||
installDir string
|
||||
}
|
||||
|
||||
// NewManager creates a new whisper manager
|
||||
func NewManager() (*Manager, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get home directory: %w", err)
|
||||
}
|
||||
|
||||
installDir := filepath.Join(homeDir, ".wis-free-v3", "whisper")
|
||||
|
||||
return &Manager{
|
||||
installDir: installDir,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// IsInstalled checks if whisper is installed
|
||||
func (m *Manager) IsInstalled() bool {
|
||||
infoPath := filepath.Join(m.installDir, "installed.json")
|
||||
if _, err := os.Stat(infoPath); os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if model exists
|
||||
info, err := m.GetInstalledInfo()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
modelPath := filepath.Join(m.installDir, Models[info.Model].Filename)
|
||||
if _, err := os.Stat(modelPath); os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetInstalledInfo returns information about the installed whisper
|
||||
func (m *Manager) GetInstalledInfo() (*InstalledInfo, error) {
|
||||
infoPath := filepath.Join(m.installDir, "installed.json")
|
||||
data, err := os.ReadFile(infoPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var info InstalledInfo
|
||||
if err := json.Unmarshal(data, &info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// Install downloads and installs whisper with the specified model
|
||||
// It opens a terminal window to show progress
|
||||
func (m *Manager) Install(model string) error {
|
||||
if _, ok := Models[model]; !ok {
|
||||
return fmt.Errorf("unknown model: %s", model)
|
||||
}
|
||||
|
||||
// Create install directory
|
||||
if err := os.MkdirAll(m.installDir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create install directory: %w", err)
|
||||
}
|
||||
|
||||
// Create install script
|
||||
scriptPath := filepath.Join(m.installDir, "install.bat")
|
||||
script := m.generateInstallScript(model)
|
||||
if err := os.WriteFile(scriptPath, []byte(script), 0755); err != nil {
|
||||
return fmt.Errorf("failed to write install script: %w", err)
|
||||
}
|
||||
|
||||
// Run install script in a visible terminal
|
||||
cmd := exec.Command("cmd", "/c", "start", "cmd", "/k", scriptPath)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("failed to start installer: %w", err)
|
||||
}
|
||||
|
||||
logger.Info("Whisper installation started in terminal")
|
||||
return nil
|
||||
}
|
||||
|
||||
// generateInstallScript creates a batch script for installation
|
||||
func (m *Manager) generateInstallScript(model string) string {
|
||||
modelInfo := Models[model]
|
||||
modelURL := fmt.Sprintf("%s/%s", modelBaseURL, modelInfo.Filename)
|
||||
modelPath := filepath.Join(m.installDir, modelInfo.Filename)
|
||||
infoPath := filepath.Join(m.installDir, "installed.json")
|
||||
zipPath := filepath.Join(m.installDir, "whisper.zip")
|
||||
|
||||
script := fmt.Sprintf(`@echo off
|
||||
title wis-free-v3 - Installing Offline Whisper
|
||||
color 0A
|
||||
echo.
|
||||
echo ===============================================
|
||||
echo wis-free-v3 - Offline Whisper Installer
|
||||
echo ===============================================
|
||||
echo.
|
||||
echo Install directory: %s
|
||||
echo Model: %s (%s)
|
||||
echo.
|
||||
|
||||
echo Checking prerequisites...
|
||||
if not exist "C:\Windows\System32\msvcp140.dll" (
|
||||
echo.
|
||||
echo ERROR: Microsoft Visual C++ Redistributable is missing.
|
||||
echo This is required for the offline model to run.
|
||||
echo.
|
||||
echo Please download and install it from:
|
||||
echo https://aka.ms/vs/17/release/vc_redist.x64.exe
|
||||
echo.
|
||||
echo After installing, restart wis-free-v3 and try again.
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo [1/4] Creating directories...
|
||||
mkdir "%s" 2>nul
|
||||
|
||||
echo.
|
||||
echo [2/4] Downloading whisper.cpp binary...
|
||||
echo URL: %s
|
||||
curl -L --retry 3 --progress-bar -o "%s" "%s"
|
||||
if %%ERRORLEVEL%% neq 0 (
|
||||
echo.
|
||||
echo ERROR: Failed to download whisper.cpp
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo [3/4] Extracting whisper.cpp...
|
||||
powershell -Command "Expand-Archive -Path '%s' -DestinationPath '%s' -Force"
|
||||
if %%ERRORLEVEL%% neq 0 (
|
||||
echo ERROR: Failed to extract whisper.cpp
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
del "%s"
|
||||
|
||||
echo.
|
||||
echo [4/4] Downloading Whisper %s model (%s)...
|
||||
echo URL: %s
|
||||
echo.
|
||||
echo This may take several minutes depending on your internet speed...
|
||||
echo.
|
||||
curl -L --retry 3 --progress-bar -o "%s" "%s"
|
||||
if %%ERRORLEVEL%% neq 0 (
|
||||
echo.
|
||||
echo ERROR: Failed to download model
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Verifying installation...
|
||||
if not exist "%s" (
|
||||
echo ERROR: Model file not found
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Creating installation info...
|
||||
echo {"version":"1.8.2","model":"%s","install_path":"%s"} > "%s"
|
||||
|
||||
echo.
|
||||
echo ===============================================
|
||||
echo Installation Complete!
|
||||
echo ===============================================
|
||||
echo.
|
||||
echo Whisper.cpp and %s model installed successfully!
|
||||
echo.
|
||||
echo NEXT STEPS:
|
||||
echo 1. Close this window
|
||||
echo 2. Restart wis-free-v3
|
||||
echo 3. Select "Local Whisper" in settings
|
||||
echo.
|
||||
pause
|
||||
exit
|
||||
`,
|
||||
m.installDir,
|
||||
model, modelInfo.Size,
|
||||
m.installDir,
|
||||
whisperBinaryURL,
|
||||
zipPath, whisperBinaryURL,
|
||||
zipPath, m.installDir,
|
||||
zipPath,
|
||||
model, modelInfo.Size,
|
||||
modelURL,
|
||||
modelPath, modelURL,
|
||||
modelPath,
|
||||
model, strings.ReplaceAll(m.installDir, `\`, `\\`), infoPath,
|
||||
model,
|
||||
)
|
||||
|
||||
return script
|
||||
}
|
||||
|
||||
// Uninstall removes whisper installation
|
||||
func (m *Manager) Uninstall() error {
|
||||
if err := os.RemoveAll(m.installDir); err != nil {
|
||||
return fmt.Errorf("failed to remove whisper directory: %w", err)
|
||||
}
|
||||
logger.Info("Whisper uninstalled")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Transcribe runs local whisper transcription
|
||||
func (m *Manager) Transcribe(audioPath string) (string, error) {
|
||||
if !m.IsInstalled() {
|
||||
return "", fmt.Errorf("whisper is not installed")
|
||||
}
|
||||
|
||||
info, err := m.GetInstalledInfo()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get installation info: %w", err)
|
||||
}
|
||||
|
||||
binaryPath := m.getBinaryPath()
|
||||
modelFilename := Models[info.Model].Filename
|
||||
|
||||
// Check for model in Release directory first, then main directory
|
||||
modelPath := filepath.Join(m.installDir, "Release", modelFilename)
|
||||
if _, err := os.Stat(modelPath); os.IsNotExist(err) {
|
||||
modelPath = filepath.Join(m.installDir, modelFilename)
|
||||
}
|
||||
|
||||
logger.Info("Running whisper: %s -m %s -f %s", binaryPath, modelPath, audioPath)
|
||||
|
||||
// Run whisper with simple arguments: ./main -m model.bin -f audio.wav
|
||||
// Vulkan build uses GPU by default, no need for -ngl
|
||||
cmd := exec.Command(binaryPath, "-m", modelPath, "-f", audioPath)
|
||||
|
||||
// Set working directory to the binary's location so it can find DLLs
|
||||
cmd.Dir = filepath.Dir(binaryPath)
|
||||
|
||||
// Hide the console window
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
HideWindow: true,
|
||||
CreationFlags: 0x08000000, // CREATE_NO_WINDOW
|
||||
}
|
||||
|
||||
output, err := cmd.CombinedOutput()
|
||||
outputStr := string(output)
|
||||
|
||||
if err != nil {
|
||||
logger.Error("Whisper failed: %v, output: %s", err, outputStr)
|
||||
return "", fmt.Errorf("transcription failed: %w", err)
|
||||
}
|
||||
|
||||
// Parse the output - whisper.cpp outputs transcribed text to stdout
|
||||
lines := strings.Split(outputStr, "\n")
|
||||
var textLines []string
|
||||
|
||||
for _, line := range lines {
|
||||
line = strings.TrimSpace(line)
|
||||
|
||||
// Skip empty lines
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Skip all system/debug info
|
||||
if strings.Contains(line, "whisper_") ||
|
||||
strings.Contains(line, "main:") ||
|
||||
strings.Contains(line, "system_info:") ||
|
||||
strings.Contains(line, "ld_") ||
|
||||
strings.Contains(line, "cuda_") ||
|
||||
strings.Contains(line, "ggml_vulkan") {
|
||||
continue
|
||||
}
|
||||
|
||||
// Handle timestamped lines like: [00:00:00.000 --> 00:00:07.280] Text
|
||||
if strings.HasPrefix(line, "[") && strings.Contains(line, "]") {
|
||||
// Extract text after the timestamp
|
||||
parts := strings.SplitN(line, "]", 2)
|
||||
if len(parts) > 1 {
|
||||
text := strings.TrimSpace(parts[1])
|
||||
if text != "" {
|
||||
textLines = append(textLines, text)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Fallback for non-prefixed text lines (if any)
|
||||
textLines = append(textLines, line)
|
||||
}
|
||||
|
||||
result := strings.Join(textLines, " ")
|
||||
result = strings.TrimSpace(result)
|
||||
|
||||
if result == "" {
|
||||
// If still no text, return simple fallback or raw output if short
|
||||
if len(outputStr) < 200 {
|
||||
return strings.TrimSpace(outputStr), nil
|
||||
}
|
||||
// Return empty string rather than spamming user with massive logs
|
||||
return "", nil
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getBinaryPath returns the path to the whisper binary
|
||||
func (m *Manager) getBinaryPath() string {
|
||||
// whisper.cpp extracts to a Release subdirectory
|
||||
releaseDir := filepath.Join(m.installDir, "Release")
|
||||
|
||||
// Try different possible binary names
|
||||
// whisper-cli.exe is the new standard (main.exe is deprecated)
|
||||
possibleNames := []string{
|
||||
"whisper-cli.exe",
|
||||
"main.exe",
|
||||
}
|
||||
|
||||
// First check in Release subdirectory
|
||||
for _, name := range possibleNames {
|
||||
path := filepath.Join(releaseDir, name)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
// Then check in main install directory
|
||||
for _, name := range possibleNames {
|
||||
path := filepath.Join(m.installDir, name)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
// Default to Release/main.exe
|
||||
return filepath.Join(releaseDir, "main.exe")
|
||||
}
|
||||
|
||||
// CheckOnline checks if internet is available
|
||||
func CheckOnline() bool {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
resp, err := client.Get("https://api.groq.com")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// DownloadProgress represents download progress
|
||||
type DownloadProgress struct {
|
||||
Downloaded int64
|
||||
Total int64
|
||||
Percent float64
|
||||
}
|
||||
|
||||
// downloadFile downloads a file with progress reporting
|
||||
func downloadFile(url, dest string, progress chan<- DownloadProgress) error {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
out, err := os.Create(dest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
total := resp.ContentLength
|
||||
var downloaded int64
|
||||
|
||||
buf := make([]byte, 32*1024)
|
||||
for {
|
||||
n, err := resp.Body.Read(buf)
|
||||
if n > 0 {
|
||||
out.Write(buf[:n])
|
||||
downloaded += int64(n)
|
||||
if progress != nil && total > 0 {
|
||||
progress <- DownloadProgress{
|
||||
Downloaded: downloaded,
|
||||
Total: total,
|
||||
Percent: float64(downloaded) / float64(total) * 100,
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// Package startup manages Windows startup registry entries for the application.
|
||||
// It allows the application to automatically start when the user logs in.
|
||||
package startup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
// Windows Registry constants
|
||||
const (
|
||||
registryPath = `SOFTWARE\Microsoft\Windows\CurrentVersion\Run`
|
||||
appName = "WISNative"
|
||||
)
|
||||
|
||||
// AddToStartup adds the current executable to Windows startup.
|
||||
// The application will start automatically when the user logs in.
|
||||
func AddToStartup() error {
|
||||
exePath, err := getExecutablePath()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get executable path: %w", err)
|
||||
}
|
||||
|
||||
key, err := registry.OpenKey(
|
||||
registry.CURRENT_USER,
|
||||
registryPath,
|
||||
registry.SET_VALUE,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open registry key: %w", err)
|
||||
}
|
||||
defer key.Close()
|
||||
|
||||
if err := key.SetStringValue(appName, exePath); err != nil {
|
||||
return fmt.Errorf("failed to set registry value: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveFromStartup removes the application from Windows startup.
|
||||
func RemoveFromStartup() error {
|
||||
key, err := registry.OpenKey(
|
||||
registry.CURRENT_USER,
|
||||
registryPath,
|
||||
registry.SET_VALUE,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open registry key: %w", err)
|
||||
}
|
||||
defer key.Close()
|
||||
|
||||
if err := key.DeleteValue(appName); err != nil {
|
||||
// Ignore error if value doesn't exist
|
||||
if err != registry.ErrNotExist {
|
||||
return fmt.Errorf("failed to delete registry value: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsInStartup checks if the application is configured to start with Windows.
|
||||
func IsInStartup() bool {
|
||||
key, err := registry.OpenKey(
|
||||
registry.CURRENT_USER,
|
||||
registryPath,
|
||||
registry.QUERY_VALUE,
|
||||
)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer key.Close()
|
||||
|
||||
_, _, err = key.GetStringValue(appName)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// getExecutablePath returns the absolute path to the current executable.
|
||||
func getExecutablePath() (string, error) {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Abs(exe)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
package overlay
|
||||
|
||||
import (
|
||||
"math"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
user32 = syscall.NewLazyDLL("user32.dll")
|
||||
gdi32 = syscall.NewLazyDLL("gdi32.dll")
|
||||
procCreateWindowEx = user32.NewProc("CreateWindowExW")
|
||||
procDefWindowProc = user32.NewProc("DefWindowProcW")
|
||||
procDispatchMessage = user32.NewProc("DispatchMessageW")
|
||||
procPeekMessage = user32.NewProc("PeekMessageW")
|
||||
procRegisterClassEx = user32.NewProc("RegisterClassExW")
|
||||
procTranslateMessage = user32.NewProc("TranslateMessage")
|
||||
procShowWindow = user32.NewProc("ShowWindow")
|
||||
procUpdateWindow = user32.NewProc("UpdateWindow")
|
||||
procGetSystemMetrics = user32.NewProc("GetSystemMetrics")
|
||||
procSetLayeredWindowAttributes = user32.NewProc("SetLayeredWindowAttributes")
|
||||
procBeginPaint = user32.NewProc("BeginPaint")
|
||||
procEndPaint = user32.NewProc("EndPaint")
|
||||
procCreateSolidBrush = gdi32.NewProc("CreateSolidBrush")
|
||||
procCreateFontW = gdi32.NewProc("CreateFontW")
|
||||
procSelectObject = gdi32.NewProc("SelectObject")
|
||||
procDeleteObject = gdi32.NewProc("DeleteObject")
|
||||
procSetBkMode = gdi32.NewProc("SetBkMode")
|
||||
procSetTextColor = gdi32.NewProc("SetTextColor")
|
||||
procDrawTextW = user32.NewProc("DrawTextW")
|
||||
procPostMessage = user32.NewProc("PostMessageW")
|
||||
procInvalidateRect = user32.NewProc("InvalidateRect")
|
||||
procLoadCursor = user32.NewProc("LoadCursorW")
|
||||
procCreatePen = gdi32.NewProc("CreatePen")
|
||||
procEllipse = gdi32.NewProc("Ellipse")
|
||||
procCreateRoundRectRgn = gdi32.NewProc("CreateRoundRectRgn")
|
||||
procSetWindowRgn = user32.NewProc("SetWindowRgn")
|
||||
procFillRgn = gdi32.NewProc("FillRgn")
|
||||
procCreateCompatibleDC = gdi32.NewProc("CreateCompatibleDC")
|
||||
procCreateCompatibleBitmap = gdi32.NewProc("CreateCompatibleBitmap")
|
||||
procBitBlt = gdi32.NewProc("BitBlt")
|
||||
procDeleteDC = gdi32.NewProc("DeleteDC")
|
||||
)
|
||||
|
||||
const (
|
||||
WS_POPUP = 0x80000000
|
||||
WS_EX_LAYERED = 0x00080000
|
||||
WS_EX_TOPMOST = 0x00000008
|
||||
WS_EX_TOOLWINDOW = 0x00000080
|
||||
WS_EX_TRANSPARENT = 0x00000020
|
||||
SW_SHOW = 5
|
||||
SW_HIDE = 0
|
||||
LWA_ALPHA = 0x00000002
|
||||
SM_CXSCREEN = 0
|
||||
SM_CYSCREEN = 1
|
||||
TRANSPARENT_BK = 1
|
||||
DT_CENTER = 0x00000001
|
||||
DT_VCENTER = 0x00000004
|
||||
DT_SINGLELINE = 0x00000020
|
||||
WM_PAINT = 0x000F
|
||||
WM_DESTROY = 0x0002
|
||||
WM_CLOSE = 0x0010
|
||||
IDC_ARROW = 32512
|
||||
PM_REMOVE = 0x0001
|
||||
PS_SOLID = 0
|
||||
WM_ERASEBKGND = 0x0014
|
||||
)
|
||||
|
||||
const (
|
||||
COLOR_BG_DARK = 0x1A0F0B // Deep dark background (BGR for #0b0f1a)
|
||||
COLOR_MIC_RED = 0x4545FF // Red for recording (BGR)
|
||||
COLOR_MIC_GREEN = 0x50C850 // Green for ready
|
||||
COLOR_MIC_ORANGE = 0x00A5FF // Orange for processing
|
||||
COLOR_WHITE = 0xFFFFFF
|
||||
COLOR_GRAY = 0x808080
|
||||
)
|
||||
|
||||
// Overlay manages a transparent overlay window
|
||||
type Overlay struct {
|
||||
hwnd syscall.Handle
|
||||
text string
|
||||
isShowing bool
|
||||
running bool
|
||||
mu sync.RWMutex
|
||||
stopCh chan struct{}
|
||||
bgBrush syscall.Handle
|
||||
hFont syscall.Handle
|
||||
volume float64 // Current raw volume (0.0 - 1.0)
|
||||
smoothedVolume float64 // Moving average volume for smoother animations
|
||||
}
|
||||
|
||||
var globalOverlay *Overlay
|
||||
|
||||
// NewOverlay creates a new overlay instance
|
||||
func NewOverlay() *Overlay {
|
||||
o := &Overlay{
|
||||
text: "Ready",
|
||||
stopCh: make(chan struct{}),
|
||||
}
|
||||
globalOverlay = o
|
||||
go o.run()
|
||||
return o
|
||||
}
|
||||
|
||||
// Show displays the overlay with the given message
|
||||
func (o *Overlay) Show(message string) {
|
||||
o.mu.Lock()
|
||||
o.text = message
|
||||
o.isShowing = true
|
||||
o.mu.Unlock()
|
||||
|
||||
if o.hwnd != 0 {
|
||||
procInvalidateRect.Call(uintptr(o.hwnd), 0, 1)
|
||||
procShowWindow.Call(uintptr(o.hwnd), SW_SHOW)
|
||||
}
|
||||
}
|
||||
|
||||
// Hide hides the overlay
|
||||
func (o *Overlay) Hide() {
|
||||
o.mu.Lock()
|
||||
o.isShowing = false
|
||||
o.mu.Unlock()
|
||||
|
||||
if o.hwnd != 0 {
|
||||
procShowWindow.Call(uintptr(o.hwnd), SW_HIDE)
|
||||
}
|
||||
}
|
||||
|
||||
// SetVolume updates the current audio volume level
|
||||
func (o *Overlay) SetVolume(level float64) {
|
||||
o.mu.Lock()
|
||||
o.volume = level
|
||||
// Stronger smoothing: 10% new value, 90% old value to reduce jitter/flicker
|
||||
o.smoothedVolume = (o.smoothedVolume * 0.9) + (level * 0.1)
|
||||
o.mu.Unlock()
|
||||
}
|
||||
|
||||
// Close stops the overlay
|
||||
func (o *Overlay) Close() {
|
||||
if o.hwnd != 0 {
|
||||
procPostMessage.Call(uintptr(o.hwnd), WM_CLOSE, 0, 0)
|
||||
}
|
||||
if o.bgBrush != 0 {
|
||||
procDeleteObject.Call(uintptr(o.bgBrush))
|
||||
}
|
||||
if o.hFont != 0 {
|
||||
procDeleteObject.Call(uintptr(o.hFont))
|
||||
}
|
||||
close(o.stopCh)
|
||||
}
|
||||
|
||||
func (o *Overlay) run() {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
o.running = true
|
||||
defer func() { o.running = false }()
|
||||
|
||||
className := syscall.StringToUTF16Ptr("wis-free-v3Overlay")
|
||||
|
||||
var wc wndClassEx
|
||||
wc.cbSize = uint32(unsafe.Sizeof(wc))
|
||||
wc.lpfnWndProc = syscall.NewCallback(overlayWndProc)
|
||||
wc.lpszClassName = className
|
||||
|
||||
// Pre-create resources
|
||||
o.bgBrush = syscall.Handle(uintptr(0))
|
||||
brushRec, _, _ := procCreateSolidBrush.Call(COLOR_BG_DARK)
|
||||
o.bgBrush = syscall.Handle(brushRec)
|
||||
|
||||
fontName := syscall.StringToUTF16Ptr("Segoe UI")
|
||||
fontRec, _, _ := procCreateFontW.Call(
|
||||
18, 0, 0, 0, 600,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
uintptr(unsafe.Pointer(fontName)),
|
||||
)
|
||||
o.hFont = syscall.Handle(fontRec)
|
||||
|
||||
cursor, _, _ := procLoadCursor.Call(0, uintptr(IDC_ARROW))
|
||||
wc.hCursor = syscall.Handle(cursor)
|
||||
wc.hbrBackground = o.bgBrush
|
||||
|
||||
procRegisterClassEx.Call(uintptr(unsafe.Pointer(&wc)))
|
||||
|
||||
// Get screen dimensions
|
||||
screenWidth, _, _ := procGetSystemMetrics.Call(SM_CXSCREEN)
|
||||
screenHeight, _, _ := procGetSystemMetrics.Call(SM_CYSCREEN)
|
||||
|
||||
// Pill dimensions
|
||||
width := 120
|
||||
height := 46
|
||||
x := (int(screenWidth) - width) / 2
|
||||
y := int(screenHeight) - height - 80 // 80px from bottom
|
||||
|
||||
hwnd, _, _ := procCreateWindowEx.Call(
|
||||
WS_EX_LAYERED|WS_EX_TOPMOST|WS_EX_TOOLWINDOW|WS_EX_TRANSPARENT,
|
||||
uintptr(unsafe.Pointer(className)),
|
||||
0,
|
||||
WS_POPUP,
|
||||
uintptr(x), uintptr(y), uintptr(width), uintptr(height),
|
||||
0, 0, 0, 0,
|
||||
)
|
||||
|
||||
if hwnd == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
o.hwnd = syscall.Handle(hwnd)
|
||||
|
||||
// Create a rounded region to clip the window (true pill shape, no corners)
|
||||
// The corner radius should be half the height for a perfect pill
|
||||
rgn, _, _ := procCreateRoundRectRgn.Call(0, 0, uintptr(width+1), uintptr(height+1), uintptr(height), uintptr(height))
|
||||
procSetWindowRgn.Call(hwnd, rgn, 1)
|
||||
|
||||
// Set window transparency
|
||||
procSetLayeredWindowAttributes.Call(uintptr(hwnd), 0, 240, LWA_ALPHA)
|
||||
procShowWindow.Call(uintptr(hwnd), SW_HIDE)
|
||||
procUpdateWindow.Call(uintptr(hwnd))
|
||||
|
||||
// Message loop
|
||||
ticker := time.NewTicker(16 * time.Millisecond) // ~60 FPS
|
||||
defer ticker.Stop()
|
||||
|
||||
var msg msg
|
||||
for {
|
||||
select {
|
||||
case <-o.stopCh:
|
||||
return
|
||||
case <-ticker.C:
|
||||
if o.hwnd != 0 && o.isShowing {
|
||||
// Only invalidate if we are in a state that needs animation
|
||||
o.mu.RLock()
|
||||
needsAnimation := strings.HasPrefix(o.text, "Recording") || strings.HasPrefix(o.text, "Transcribing") || strings.HasPrefix(o.text, "Processing")
|
||||
o.mu.RUnlock()
|
||||
|
||||
if needsAnimation {
|
||||
procInvalidateRect.Call(uintptr(o.hwnd), 0, 0)
|
||||
}
|
||||
}
|
||||
default:
|
||||
ret, _, _ := procPeekMessage.Call(
|
||||
uintptr(unsafe.Pointer(&msg)),
|
||||
0, 0, 0,
|
||||
PM_REMOVE,
|
||||
)
|
||||
|
||||
if ret != 0 {
|
||||
if msg.message == WM_CLOSE {
|
||||
return
|
||||
}
|
||||
procTranslateMessage.Call(uintptr(unsafe.Pointer(&msg)))
|
||||
procDispatchMessage.Call(uintptr(unsafe.Pointer(&msg)))
|
||||
} else {
|
||||
// Higher resolution sleep for better responsiveness while keeping CPU low
|
||||
time.Sleep(2 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func overlayWndProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr {
|
||||
switch msg {
|
||||
case WM_ERASEBKGND:
|
||||
return 1 // Prevent white flash by handling erase ourselves
|
||||
|
||||
case WM_PAINT:
|
||||
var ps paintStruct
|
||||
hdc, _, _ := procBeginPaint.Call(uintptr(hwnd), uintptr(unsafe.Pointer(&ps)))
|
||||
|
||||
// Double buffering: Create a memory DC to draw off-screen first
|
||||
memDC, _, _ := procCreateCompatibleDC.Call(hdc)
|
||||
memBitmap, _, _ := procCreateCompatibleBitmap.Call(hdc, 120, 46)
|
||||
oldBitmap, _, _ := procSelectObject.Call(memDC, memBitmap)
|
||||
|
||||
// Access global state safely
|
||||
var text string
|
||||
var bgBrush syscall.Handle
|
||||
var hFont syscall.Handle
|
||||
var volume float64
|
||||
|
||||
if globalOverlay != nil {
|
||||
globalOverlay.mu.RLock()
|
||||
text = globalOverlay.text
|
||||
bgBrush = globalOverlay.bgBrush
|
||||
hFont = globalOverlay.hFont
|
||||
volume = globalOverlay.smoothedVolume
|
||||
globalOverlay.mu.RUnlock()
|
||||
}
|
||||
|
||||
// 1. Clear memory DC with background
|
||||
rgn, _, _ := procCreateRoundRectRgn.Call(0, 0, 121, 47, 46, 46)
|
||||
if bgBrush != 0 {
|
||||
procFillRgn.Call(memDC, rgn, uintptr(bgBrush))
|
||||
}
|
||||
procDeleteObject.Call(rgn)
|
||||
|
||||
// 2. Draw content to memory DC
|
||||
if strings.HasPrefix(text, "Recording") {
|
||||
// Draw animated waves for recording
|
||||
// Slowed down from 10.0 to 6.0
|
||||
t := float64(time.Now().UnixNano()) / 1e9 * 6.0
|
||||
|
||||
barCount := 7 // Reduced from 9 for shorter pill
|
||||
barWidth := 4
|
||||
barGap := 4
|
||||
totalWidth := barCount*barWidth + (barCount-1)*barGap
|
||||
startX := (120 - totalWidth) / 2
|
||||
centerY := 46 / 2
|
||||
|
||||
// Use colors for waves? The user said "instead of... the color... it's just like waves"
|
||||
// But maybe a subtle red pulse is nice? Let's use WHITE as requested.
|
||||
barBrush, _, _ := procCreateSolidBrush.Call(uintptr(COLOR_WHITE))
|
||||
|
||||
for i := 0; i < barCount; i++ {
|
||||
// Different phases for each bar
|
||||
phase := float64(i) * 0.8
|
||||
|
||||
// Base height from animation
|
||||
animH := 4.0 * math.Abs(math.Sin(t+phase))
|
||||
|
||||
// Scale height based on real-time volume
|
||||
// Boosted sensitivity from 40.0 to 120.0 for better response to normal speech
|
||||
volH := volume * 120.0
|
||||
|
||||
// Total height: slow background wave + responsive voice spikes
|
||||
h := 6.0 + animH + volH
|
||||
|
||||
// Cap height to 38 (max pill center space)
|
||||
if h > 38 {
|
||||
h = 38
|
||||
}
|
||||
|
||||
x := int32(startX + i*(barWidth+barGap))
|
||||
y1 := int32(float64(centerY) - h/2)
|
||||
y2 := int32(float64(centerY) + h/2)
|
||||
|
||||
barRgn, _, _ := procCreateRoundRectRgn.Call(uintptr(x), uintptr(y1), uintptr(x+int32(barWidth)), uintptr(y2), 4, 4)
|
||||
procFillRgn.Call(memDC, barRgn, barBrush)
|
||||
procDeleteObject.Call(barRgn)
|
||||
}
|
||||
procDeleteObject.Call(barBrush)
|
||||
|
||||
} else if strings.HasPrefix(text, "Transcribing") || strings.HasPrefix(text, "Processing") {
|
||||
// Different animation for processing/transcribing (more uniform, pulsing)
|
||||
// Slowed down from 5.0 to 3.0
|
||||
t := float64(time.Now().UnixNano()) / 1e9 * 3.0
|
||||
|
||||
barCount := 5 // Reduced from 7 for shorter pill
|
||||
barWidth := 4
|
||||
barGap := 6
|
||||
totalWidth := barCount*barWidth + (barCount-1)*barGap
|
||||
startX := (120 - totalWidth) / 2
|
||||
centerY := 46 / 2
|
||||
|
||||
barBrush, _, _ := procCreateSolidBrush.Call(uintptr(COLOR_MIC_ORANGE)) // Orange for processing
|
||||
|
||||
for i := 0; i < barCount; i++ {
|
||||
// Subtler oscillation
|
||||
h := 10.0 + 10.0*math.Abs(math.Sin(t+float64(i)*0.3))
|
||||
|
||||
x := int32(startX + i*(barWidth+barGap))
|
||||
y1 := int32(float64(centerY) - h/2)
|
||||
y2 := int32(float64(centerY) + h/2)
|
||||
|
||||
barRgn, _, _ := procCreateRoundRectRgn.Call(uintptr(x), uintptr(y1), uintptr(x+int32(barWidth)), uintptr(y2), 4, 4)
|
||||
procFillRgn.Call(memDC, barRgn, barBrush)
|
||||
procDeleteObject.Call(barRgn)
|
||||
}
|
||||
procDeleteObject.Call(barBrush)
|
||||
} else {
|
||||
// Show text for errors or "Ready" (though Ready is rarely shown in overlay)
|
||||
// This keeps the user informed if something went wrong
|
||||
procSetBkMode.Call(memDC, TRANSPARENT_BK)
|
||||
|
||||
textColor := COLOR_WHITE
|
||||
if text == "Error" || strings.Contains(text, "Key") || strings.Contains(text, "Err") {
|
||||
textColor = COLOR_MIC_RED
|
||||
}
|
||||
|
||||
procSetTextColor.Call(memDC, uintptr(textColor))
|
||||
|
||||
if hFont != 0 {
|
||||
oldFont, _, _ := procSelectObject.Call(memDC, uintptr(hFont))
|
||||
// Centered text across the whole pill since there's no circle anymore
|
||||
textRect := rect{0, 0, 120, 46}
|
||||
textPtr := syscall.StringToUTF16Ptr(text)
|
||||
procDrawTextW.Call(memDC, uintptr(unsafe.Pointer(textPtr)), ^uintptr(0), uintptr(unsafe.Pointer(&textRect)), DT_CENTER|DT_VCENTER|DT_SINGLELINE)
|
||||
procSelectObject.Call(memDC, oldFont)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Copy everything from memory DC to screen (prevents flicker)
|
||||
procBitBlt.Call(hdc, 0, 0, 120, 46, memDC, 0, 0, 0x00CC0020) // SRCCOPY
|
||||
|
||||
// Cleanup memory DC
|
||||
procSelectObject.Call(memDC, oldBitmap)
|
||||
procDeleteObject.Call(memBitmap)
|
||||
procDeleteDC.Call(memDC)
|
||||
|
||||
procEndPaint.Call(uintptr(hwnd), uintptr(unsafe.Pointer(&ps)))
|
||||
return 0
|
||||
|
||||
case WM_DESTROY:
|
||||
return 0
|
||||
}
|
||||
|
||||
ret, _, _ := procDefWindowProc.Call(uintptr(hwnd), uintptr(msg), wParam, lParam)
|
||||
return ret
|
||||
}
|
||||
|
||||
// Structs for Windows API
|
||||
type wndClassEx struct {
|
||||
cbSize uint32
|
||||
style uint32
|
||||
lpfnWndProc uintptr
|
||||
cbClsExtra int32
|
||||
cbWndExtra int32
|
||||
hInstance syscall.Handle
|
||||
hIcon syscall.Handle
|
||||
hCursor syscall.Handle
|
||||
hbrBackground syscall.Handle
|
||||
lpszMenuName *uint16
|
||||
lpszClassName *uint16
|
||||
hIconSm syscall.Handle
|
||||
}
|
||||
|
||||
type msg struct {
|
||||
hwnd syscall.Handle
|
||||
message uint32
|
||||
wParam uintptr
|
||||
lParam uintptr
|
||||
time uint32
|
||||
pt point
|
||||
}
|
||||
|
||||
type point struct {
|
||||
x, y int32
|
||||
}
|
||||
|
||||
type paintStruct struct {
|
||||
hdc syscall.Handle
|
||||
fErase int32
|
||||
rcPaint rect
|
||||
fRestore int32
|
||||
fIncUpdate int32
|
||||
rgbReserved [32]byte
|
||||
}
|
||||
|
||||
type rect struct {
|
||||
left, top, right, bottom int32
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"wis-free-v3/internal/config"
|
||||
)
|
||||
|
||||
// ShowSettings displays current settings
|
||||
func ShowSettings(cfg *config.Config) {
|
||||
fmt.Println("\n=== wis-free-v3 Settings ===")
|
||||
fmt.Printf("API Key: %s...%s\n", cfg.APIKey[:8], cfg.APIKey[len(cfg.APIKey)-4:])
|
||||
fmt.Printf("Whisper Model: %s\n", cfg.WhisperModel)
|
||||
fmt.Printf("AI Model: %s\n", cfg.AIModel)
|
||||
fmt.Printf("Shortcut: %s\n", cfg.Shortcut)
|
||||
fmt.Println("===========================")
|
||||
}
|
||||
|
||||
// EditSettings provides a simple way to modify settings
|
||||
func EditSettings(cfg *config.Config) error {
|
||||
// For now, just return the config
|
||||
// In a full implementation, this would open a dialog or prompt
|
||||
fmt.Println("To edit settings, modify: ~/.wis-free-v3/config.json")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,131 @@
|
||||
// Package tray provides system tray functionality for the application.
|
||||
// It displays an icon in the Windows notification area with a context menu.
|
||||
package tray
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
|
||||
"wis-free-v3/internal/config"
|
||||
"wis-free-v3/internal/logger"
|
||||
"wis-free-v3/internal/system/startup"
|
||||
|
||||
"github.com/getlantern/systray"
|
||||
)
|
||||
|
||||
//go:embed icon.ico
|
||||
var iconData []byte
|
||||
|
||||
// App defines the interface required by the tray package to interact with the main application.
|
||||
type App interface {
|
||||
Quit()
|
||||
GetConfig() *config.Config
|
||||
ShowSettings()
|
||||
}
|
||||
|
||||
// Menu item references for dynamic updates
|
||||
var statusMenuItem *systray.MenuItem
|
||||
|
||||
// Start initializes and runs the system tray.
|
||||
// This function blocks until the tray is terminated.
|
||||
func Start(app App) {
|
||||
systray.Run(
|
||||
func() { onReady(app) },
|
||||
onExit,
|
||||
)
|
||||
}
|
||||
|
||||
// onReady is called when the system tray is ready to be configured.
|
||||
func onReady(app App) {
|
||||
// Configure tray icon and tooltip
|
||||
systray.SetIcon(iconData)
|
||||
systray.SetTitle("wis-free-v3")
|
||||
systray.SetTooltip(buildTooltip(app))
|
||||
|
||||
// Build menu structure
|
||||
statusMenuItem = systray.AddMenuItem("Status: Ready", "Current application status")
|
||||
statusMenuItem.Disable()
|
||||
|
||||
systray.AddSeparator()
|
||||
|
||||
menuSettings := systray.AddMenuItem("Settings", "Open settings window")
|
||||
menuStartup := systray.AddMenuItemCheckbox(
|
||||
"Start with Windows",
|
||||
"Automatically start when Windows boots",
|
||||
startup.IsInStartup(),
|
||||
)
|
||||
|
||||
systray.AddSeparator()
|
||||
|
||||
menuExit := systray.AddMenuItem("Exit", "Close the application")
|
||||
|
||||
// Handle menu events in background
|
||||
go handleMenuEvents(app, menuSettings, menuStartup, menuExit)
|
||||
}
|
||||
|
||||
// handleMenuEvents processes menu item click events.
|
||||
func handleMenuEvents(app App, settings, startupItem, exit *systray.MenuItem) {
|
||||
for {
|
||||
select {
|
||||
case <-settings.ClickedCh:
|
||||
app.ShowSettings()
|
||||
|
||||
case <-startupItem.ClickedCh:
|
||||
toggleStartup(startupItem)
|
||||
|
||||
case <-exit.ClickedCh:
|
||||
handleExit(app)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// toggleStartup handles the startup toggle menu item.
|
||||
func toggleStartup(item *systray.MenuItem) {
|
||||
if item.Checked() {
|
||||
if err := startup.RemoveFromStartup(); err != nil {
|
||||
logger.Error("Failed to remove from startup: %v", err)
|
||||
} else {
|
||||
item.Uncheck()
|
||||
logger.Info("Removed from Windows startup")
|
||||
}
|
||||
} else {
|
||||
if err := startup.AddToStartup(); err != nil {
|
||||
logger.Error("Failed to add to startup: %v", err)
|
||||
} else {
|
||||
item.Check()
|
||||
logger.Info("Added to Windows startup")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handleExit cleanly shuts down the application.
|
||||
func handleExit(app App) {
|
||||
logger.Info("User requested application exit")
|
||||
app.Quit()
|
||||
systray.Quit()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// buildTooltip creates the tray icon tooltip text.
|
||||
func buildTooltip(app App) string {
|
||||
shortcut := "Ctrl+K"
|
||||
if cfg := app.GetConfig(); cfg != nil && cfg.Shortcut != "" {
|
||||
shortcut = cfg.Shortcut
|
||||
}
|
||||
return "wis-free-v3 - " + shortcut + " to record"
|
||||
}
|
||||
|
||||
// UpdateStatus updates the status text displayed in the tray menu.
|
||||
func UpdateStatus(status string) {
|
||||
if statusMenuItem != nil {
|
||||
statusMenuItem.SetTitle("Status: " + status)
|
||||
systray.SetTooltip("wis-free-v3 - " + status)
|
||||
}
|
||||
}
|
||||
|
||||
// onExit is called when the system tray is shutting down.
|
||||
func onExit() {
|
||||
logger.Info("System tray terminated")
|
||||
}
|
||||
|
||||
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,151 @@
|
||||
// Package main is the entry point for wis-free-v3, a voice dictation application
|
||||
// that provides global hotkey-triggered audio recording and transcription.
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"wis-free-v3/internal/logger"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
)
|
||||
|
||||
// Application constants
|
||||
const (
|
||||
appName = "wis-free-v3"
|
||||
appTitle = "wis-free-v3 Settings"
|
||||
appWidth = 800
|
||||
appHeight = 700
|
||||
lockFile = "wis-free-v3.lock"
|
||||
configDir = ".wis-free-v3"
|
||||
)
|
||||
|
||||
// Background color for the application window (matches new deep dark theme #0b0f1a)
|
||||
var windowBackground = &options.RGBA{R: 11, G: 15, B: 26, A: 255}
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
// Global lock file handle for single instance management
|
||||
var instanceLock *os.File
|
||||
|
||||
func main() {
|
||||
// Ensure only one instance of the application is running
|
||||
if !acquireInstanceLock() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Initialize the application
|
||||
app := NewApp()
|
||||
|
||||
// Configure and run the Wails application
|
||||
err := wails.Run(&options.App{
|
||||
Title: appTitle,
|
||||
Width: appWidth,
|
||||
Height: appHeight,
|
||||
AssetServer: &assetserver.Options{Assets: assets},
|
||||
BackgroundColour: windowBackground,
|
||||
OnStartup: app.startup,
|
||||
OnShutdown: app.Shutdown,
|
||||
OnBeforeClose: app.beforeClose,
|
||||
StartHidden: true,
|
||||
Bind: []interface{}{app},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
logger.Error("Application error: %v", err)
|
||||
}
|
||||
|
||||
// Clean up resources on exit
|
||||
releaseInstanceLock()
|
||||
}
|
||||
|
||||
// acquireInstanceLock attempts to acquire an exclusive lock to prevent multiple instances.
|
||||
// It stores the current process ID in the lock file and checks if any existing lock
|
||||
// belongs to a still-running process.
|
||||
//
|
||||
// Returns true if the lock was acquired successfully, false if another instance is running.
|
||||
func acquireInstanceLock() bool {
|
||||
lockPath, err := getLockPath()
|
||||
if err != nil {
|
||||
logger.Error("Failed to get lock path: %v", err)
|
||||
return true // Allow running if we can't determine the path
|
||||
}
|
||||
|
||||
// Ensure the config directory exists
|
||||
if err := os.MkdirAll(filepath.Dir(lockPath), 0755); err != nil {
|
||||
logger.Error("Failed to create config directory: %v", err)
|
||||
return true
|
||||
}
|
||||
|
||||
// Check for existing lock file
|
||||
if data, err := os.ReadFile(lockPath); err == nil {
|
||||
if pid, err := strconv.Atoi(string(data)); err == nil {
|
||||
if isProcessRunning(pid) {
|
||||
logger.Info("Another instance is already running (PID: %d)", pid)
|
||||
return false
|
||||
}
|
||||
}
|
||||
// Stale lock file from a crashed process - remove it
|
||||
os.Remove(lockPath)
|
||||
}
|
||||
|
||||
// Create new lock file with our PID
|
||||
instanceLock, err = os.OpenFile(lockPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
logger.Error("Failed to create lock file: %v", err)
|
||||
return true
|
||||
}
|
||||
|
||||
// Write current process ID
|
||||
pid := os.Getpid()
|
||||
if _, err := instanceLock.WriteString(strconv.Itoa(pid)); err != nil {
|
||||
logger.Error("Failed to write PID to lock file: %v", err)
|
||||
}
|
||||
instanceLock.Sync()
|
||||
|
||||
logger.Info("Instance lock acquired (PID: %d)", pid)
|
||||
return true
|
||||
}
|
||||
|
||||
// releaseInstanceLock removes the lock file and closes the file handle.
|
||||
func releaseInstanceLock() {
|
||||
if instanceLock != nil {
|
||||
instanceLock.Close()
|
||||
instanceLock = nil
|
||||
}
|
||||
|
||||
if lockPath, err := getLockPath(); err == nil {
|
||||
os.Remove(lockPath)
|
||||
logger.Info("Instance lock released")
|
||||
}
|
||||
}
|
||||
|
||||
// getLockPath returns the full path to the instance lock file.
|
||||
func getLockPath() (string, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(homeDir, configDir, lockFile), nil
|
||||
}
|
||||
|
||||
// isProcessRunning checks if a process with the given PID exists on Windows.
|
||||
func isProcessRunning(pid int) bool {
|
||||
const PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
||||
|
||||
handle, err := syscall.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
syscall.CloseHandle(handle)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
pushd "%~dp0\.."
|
||||
|
||||
REM Build script for wis-free-v3 Voice Dictation App
|
||||
REM Builds a production-ready Windows executable with icon
|
||||
|
||||
echo ========================================
|
||||
echo wis-free-v3 - Build Script
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
REM Check if wails is installed
|
||||
where wails >nul 2>&1
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo [ERROR] Wails CLI not found. Please install it first:
|
||||
echo go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/2] Cleaning old build...
|
||||
if exist build\bin\wis-free-v3.exe del build\bin\wis-free-v3.exe
|
||||
|
||||
echo [2/2] Building with Wails...
|
||||
echo (This includes the app icon and frontend)
|
||||
echo.
|
||||
|
||||
REM Ensure CGO is enabled for native dependencies
|
||||
set CGO_ENABLED=1
|
||||
|
||||
REM Check if GCC is in the PATH
|
||||
where gcc >nul 2>&1
|
||||
if %ERRORLEVEL% EQU 0 goto :gcc_check_done
|
||||
echo [WARNING] GCC compiler not found in PATH.
|
||||
echo A compiler is required for native Windows features.
|
||||
echo You can download MinGW-w64 from: https://winlibs.com/
|
||||
echo.
|
||||
set /p MINGW_PATH="Paste your MinGW/bin folder path here (or press Enter to skip): "
|
||||
echo.
|
||||
if "!MINGW_PATH!"=="" goto :gcc_check_done
|
||||
|
||||
REM Remove quotes if the user provided them
|
||||
set MINGW_PATH=!MINGW_PATH:"=!
|
||||
|
||||
REM Check if the path exists
|
||||
if not exist "!MINGW_PATH!" (
|
||||
echo [ERROR] Path "!MINGW_PATH!" does not exist.
|
||||
goto :gcc_check_done
|
||||
)
|
||||
|
||||
REM Look for gcc.exe in 3 places: provided path, path\bin, and path\..\bin
|
||||
if not exist "!MINGW_PATH!\gcc.exe" (
|
||||
if exist "!MINGW_PATH!\bin\gcc.exe" (
|
||||
set "MINGW_PATH=!MINGW_PATH!\bin"
|
||||
) else if exist "!MINGW_PATH!\..\bin\gcc.exe" (
|
||||
set "MINGW_PATH=!MINGW_PATH!\..\bin"
|
||||
)
|
||||
)
|
||||
|
||||
set "PATH=!MINGW_PATH!;%PATH%"
|
||||
echo [INFO] Detected GCC at: "!MINGW_PATH!"
|
||||
|
||||
:gcc_check_done
|
||||
|
||||
REM Final check for GCC
|
||||
where gcc >nul 2>&1
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo [ERROR] GCC is still not found. Native compilation will fail.
|
||||
echo Please install MinGW-w64 e.g., from https://winlibs.com/
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
wails build -clean -ldflags="-linkmode internal" -skipbindings
|
||||
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo.
|
||||
echo [ERROR] Build failed!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo BUILD SUCCESSFUL!
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Output: build\bin\wis-free-v3.exe
|
||||
echo.
|
||||
echo NOTE: Close any running instance before
|
||||
echo replacing wis-free-v3.exe in this folder.
|
||||
echo.
|
||||
dir build\bin\wis-free-v3.exe | find "wis-free-v3.exe"
|
||||
echo.
|
||||
|
||||
pause
|
||||
@@ -0,0 +1,34 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
pushd "%~dp0\.."
|
||||
|
||||
echo Setting up wis-free-v3...
|
||||
|
||||
REM Create config directory
|
||||
if not exist "%USERPROFILE%\.wis-free-v3" mkdir "%USERPROFILE%\.wis-free-v3"
|
||||
|
||||
REM Copy config if it exists
|
||||
if exist "config.json" (
|
||||
copy /Y "config.json" "%USERPROFILE%\.wis-free-v3\config.json" >nul
|
||||
echo Config copied successfully.
|
||||
)
|
||||
|
||||
echo Starting wis-free-v3...
|
||||
echo.
|
||||
echo Press 'k' to start/stop recording.
|
||||
echo Check this console for transcription output.
|
||||
echo.
|
||||
|
||||
REM Add Go and GCC to PATH and run
|
||||
set PATH=%PATH%;C:\Program Files\Go\bin;C:\TDM-GCC-64\bin
|
||||
|
||||
if exist "build\bin\wis-free-v3.exe" (
|
||||
build\bin\wis-free-v3.exe
|
||||
) else if exist "wis-free-v3.exe" (
|
||||
wis-free-v3.exe
|
||||
) else (
|
||||
echo [ERROR] wis-free-v3.exe not found. Please run scripts/build.bat first.
|
||||
)
|
||||
|
||||
popd
|
||||
pause
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://wails.io/schemas/config.v2.json",
|
||||
"name": "wis-free-v3",
|
||||
"outputfilename": "wis-free-v3",
|
||||
"frontend:install": "npm install",
|
||||
"frontend:build": "npm run build",
|
||||
"frontend:dev:watcher": "npm run dev",
|
||||
"frontend:dev:serverUrl": "auto"
|
||||
}
|
||||
Reference in New Issue
Block a user