Settings commands handle application configuration, including hotkeys, models, audio devices, and UI preferences.
Settings Management
get_settings
Retrieve current application settings.
#[tauri::command]
pub async fn get_settings(
app: AppHandle,
) -> Result<Settings, String>
Returns: Complete settings object
Usage:
import { invoke } from '@tauri-apps/api/core';
const settings = await invoke<AppSettings>('get_settings');
console.log('Current model:', settings.current_model);
console.log('Hotkey:', settings.hotkey);
save_settings
Save updated application settings.
#[tauri::command]
pub async fn save_settings(
app: AppHandle,
settings: Settings,
) -> Result<(), String>
Complete settings object to save
Usage:
const settings = await invoke<AppSettings>('get_settings');
// Update a setting
settings.language = 'es';
settings.theme = 'dark';
// Save changes
await invoke('save_settings', { settings });
Side Effects:
- Model Change: Preloads new model and updates tray menu
- Recording Mode Change: Updates PTT shortcut registration
- Pill Indicator Mode Change: Shows/hides pill widget
- Pill Position Change: Recreates pill window at new location
- Onboarding Complete: Starts device watcher
- Emits Event:
settings-changed to all windows
AppSettings Interface
interface AppSettings {
// Recording
hotkey: string; // Global hotkey (e.g., "CommandOrControl+Shift+Space")
recording_mode?: 'toggle' | 'push_to_talk'; // Recording mode
use_different_ptt_key?: boolean; // Use separate PTT key
ptt_hotkey?: string; // Push-to-talk hotkey
// Speech Recognition
current_model: string; // Selected model name
current_model_engine?: 'whisper' | 'parakeet' | 'soniox';
language: string; // Language code (e.g., "en")
translate_to_english?: boolean; // Translate to English
// Audio
selected_microphone?: string | null; // Microphone device name
play_sound_on_recording?: boolean; // Play sound on start
play_sound_on_recording_end?: boolean; // Play sound on stop
pause_media_during_recording?: boolean; // Pause system media
// UI
theme: string; // "light", "dark", or "system"
pill_indicator_mode?: 'never' | 'always' | 'when_recording';
pill_indicator_position?: string; // "top-center", "bottom-center", etc.
pill_indicator_offset?: number; // Offset from edge (10-50 pixels)
// Transcription
keep_transcription_in_clipboard?: boolean; // Keep in clipboard after paste
transcription_cleanup_days?: number | null; // Auto-delete after N days (null = keep forever)
// System
launch_at_startup?: boolean; // Launch on login
check_updates_automatically?: boolean; // Auto-check for updates
onboarding_completed?: boolean; // Onboarding finished
}
Shortcut Management
set_global_shortcut
Update the global recording shortcut.
#[tauri::command]
pub async fn set_global_shortcut(
app: AppHandle,
shortcut: String,
) -> Result<(), String>
Keyboard shortcut (e.g., "CommandOrControl+Shift+Space")
Usage:
try {
await invoke('set_global_shortcut', {
shortcut: 'CommandOrControl+Shift+R'
});
console.log('Hotkey updated successfully');
} catch (error) {
console.error('Failed to set hotkey:', error);
// Error: "Hotkey is already in use by another application"
}
Validation:
- Checks format validity
- Normalizes key names (e.g.,
Space → space)
- Attempts registration with OS
- Returns error if hotkey is already in use
Supported Modifiers:
CommandOrControl (Cmd on macOS, Ctrl on Windows/Linux)
Shift
Alt / Option
Control
Command (macOS only)
Errors:
"Hotkey is already in use by another application" - Conflict detected
"Invalid hotkey combination" - Invalid format
"Invalid shortcut format" - Parsing error
Language Settings
get_supported_languages
Get list of supported transcription languages.
#[tauri::command]
pub async fn get_supported_languages() -> Result<Vec<LanguageInfo>, String>
Returns:
interface LanguageInfo {
code: string; // ISO 639-1 code (e.g., "en")
name: string; // Display name (e.g., "English")
}
Usage:
const languages = await invoke<LanguageInfo[]>('get_supported_languages');
// Build language selector
languages.forEach(lang => {
console.log(`${lang.code}: ${lang.name}`);
});
Example Response:
[
{ "code": "en", "name": "English" },
{ "code": "es", "name": "Spanish" },
{ "code": "fr", "name": "French" },
{ "code": "de", "name": "German" },
{ "code": "ja", "name": "Japanese" },
{ "code": "zh", "name": "Chinese" }
]
Audio Device Settings
set_audio_device
Set the selected microphone device.
#[tauri::command]
pub async fn set_audio_device(
app: AppHandle,
device_name: Option<String>,
) -> Result<(), String>
Device name or null for system default
Usage:
// Set specific device
await invoke('set_audio_device', {
deviceName: 'External USB Microphone'
});
// Use system default
await invoke('set_audio_device', {
deviceName: null
});
Side Effects:
- Stops any active recording
- Updates settings
- Refreshes tray menu
- Emits
audio-device-changed event
validate_microphone_selection
Validate that the selected microphone still exists.
#[tauri::command]
pub async fn validate_microphone_selection(
app: AppHandle,
) -> Result<bool, String>
Returns: true if microphone was reset, false if valid or using default
Usage:
const wasReset = await invoke<boolean>('validate_microphone_selection');
if (wasReset) {
console.log('Selected microphone no longer available, using default');
}
Behavior:
- Checks if selected microphone exists in device list
- If missing, resets to system default
- Returns
true if reset occurred
Model Settings
set_model_from_tray
Set the active model from tray menu selection.
#[tauri::command]
pub async fn set_model_from_tray(
app: AppHandle,
model_name: String,
) -> Result<(), String>
Usage:
await invoke('set_model_from_tray', {
modelName: 'base.en'
});
Behavior:
- Determines model engine (Whisper/Parakeet/Soniox)
- Updates settings
- Preloads model (if Whisper)
- Updates tray menu
- Emits
model-changed event
Refresh the tray menu (called automatically after model/device changes).
#[tauri::command]
pub async fn update_tray_menu(
app: AppHandle,
) -> Result<(), String>
Usage:
await invoke('update_tray_menu');
Frontend Logging
frontend_log
Log a message from frontend to backend logs.
#[tauri::command]
pub async fn frontend_log(
message: String,
) -> Result<(), String>
Usage:
await invoke('frontend_log', {
message: 'User clicked download button'
});
Output: Appears in backend logs as [FRONTEND] User clicked download button
Settings Constants
// Recording indicator offset bounds
pub const MIN_INDICATOR_OFFSET: u32 = 10; // pixels
pub const MAX_INDICATOR_OFFSET: u32 = 50; // pixels
pub const DEFAULT_INDICATOR_OFFSET: u32 = 10;
Default Settings
impl Default for Settings {
fn default() -> Self {
Self {
hotkey: "CommandOrControl+Shift+Space".to_string(),
current_model: "".to_string(), // Auto-select
current_model_engine: "whisper".to_string(),
language: "en".to_string(),
translate_to_english: false,
theme: "system".to_string(),
transcription_cleanup_days: None, // Keep forever
launch_at_startup: false,
onboarding_completed: false,
check_updates_automatically: true,
selected_microphone: None, // System default
recording_mode: "toggle".to_string(),
use_different_ptt_key: false,
ptt_hotkey: Some("Alt+Space".to_string()),
keep_transcription_in_clipboard: false,
play_sound_on_recording: true,
play_sound_on_recording_end: true,
pill_indicator_mode: "when_recording".to_string(),
pill_indicator_position: "bottom-center".to_string(),
pill_indicator_offset: DEFAULT_INDICATOR_OFFSET,
pause_media_during_recording: true,
}
}
}
Example: Complete Settings Update
import { invoke } from '@tauri-apps/api/core';
import type { AppSettings } from '@/types';
// Load current settings
const settings = await invoke<AppSettings>('get_settings');
// Update multiple settings
const updatedSettings: AppSettings = {
...settings,
// Change model
current_model: 'large-v3',
current_model_engine: 'whisper',
// Update UI preferences
theme: 'dark',
pill_indicator_mode: 'always',
pill_indicator_position: 'top-center',
// Configure audio
selected_microphone: 'AirPods Pro',
play_sound_on_recording: false,
// Set language
language: 'es',
translate_to_english: false,
};
// Save all changes
try {
await invoke('save_settings', { settings: updatedSettings });
console.log('Settings saved successfully');
} catch (error) {
console.error('Failed to save settings:', error);
}
See Also