1
0

feat: enhance Whisper language selection in onboarding with auto-detect option and switch Wayland paste shortcut to Ctrl+V.

This commit is contained in:
2026-03-03 12:28:09 +01:00
parent 9bf72169db
commit 91638940ff
2 changed files with 27 additions and 18 deletions

View File

@@ -120,18 +120,29 @@ public static class OnboardCommand
.UseConverter(c => c == "whisper-large-v3" ? "whisper-large-v3 (Accurate)" : "whisper-large-v3-turbo (Fast)")); .UseConverter(c => c == "whisper-large-v3" ? "whisper-large-v3 (Accurate)" : "whisper-large-v3-turbo (Fast)"));
} }
config.WhisperLanguage = AnsiConsole.Prompt( var langChoice = AnsiConsole.Prompt(
new TextPrompt<string>("Microphone Spoken Language (e.g. en, es, zh):") new SelectionPrompt<string>()
.DefaultValue(string.IsNullOrWhiteSpace(config.WhisperLanguage) ? "en" : config.WhisperLanguage) .Title("Select [green]Spoken Language[/] for Whisper:")
.AllowEmpty() .AddChoices(new[] { "Auto-detect (multilingual)", "Specify language code" })
.Validate(lang => .UseConverter(c => c));
{
if (string.IsNullOrWhiteSpace(lang)) return ValidationResult.Success(); if (langChoice == "Specify language code")
if (lang.Contains(",") || lang.Contains(" ")) {
return ValidationResult.Error("[red]Please provide only one language code (e.g., 'en' not 'en, es')[/]"); config.WhisperLanguage = AnsiConsole.Prompt(
new TextPrompt<string>("Language code (e.g. en, es, zh, de):")
.DefaultValue(string.IsNullOrWhiteSpace(config.WhisperLanguage) ? "en" : config.WhisperLanguage)
.Validate(lang =>
{
if (lang.Contains(",") || lang.Contains(" "))
return ValidationResult.Error("[red]Please provide only one language code (e.g., 'en' not 'en, es')[/]");
return ValidationResult.Success();
}));
}
else
{
config.WhisperLanguage = string.Empty;
}
return ValidationResult.Success();
}));
var sessionType = Environment.GetEnvironmentVariable("XDG_SESSION_TYPE")?.ToLowerInvariant(); var sessionType = Environment.GetEnvironmentVariable("XDG_SESSION_TYPE")?.ToLowerInvariant();
var typingBackends = sessionType == "wayland" ? new[] { "wtype", "wl-clipboard", "ydotool" } : new[] { "xdotool", "ydotool" }; var typingBackends = sessionType == "wayland" ? new[] { "wtype", "wl-clipboard", "ydotool" } : new[] { "xdotool", "ydotool" };

View File

@@ -6,9 +6,7 @@ namespace Toak.IO.Injectors;
/// <summary> /// <summary>
/// Text injector that writes text to the Wayland clipboard via <c>wl-copy</c> /// Text injector that writes text to the Wayland clipboard via <c>wl-copy</c>
/// and then pastes it using Shift+Insert via <c>wtype</c>. /// and then pastes it using Ctrl+V via <c>wtype</c>.
/// Whitespace-only content is typed directly with <c>wtype</c> to avoid
/// wl-copy silently stripping leading/trailing spaces from clipboard content.
/// </summary> /// </summary>
public class WlClipboardTextInjector(INotifications notifications) : ITextInjector public class WlClipboardTextInjector(INotifications notifications) : ITextInjector
{ {
@@ -39,11 +37,11 @@ public class WlClipboardTextInjector(INotifications notifications) : ITextInject
Task.Delay(100).Wait(); Task.Delay(100).Wait();
// Simulate Shift+Insert to paste into the focused window // Simulate Ctrl+V to paste into the focused window
var pasteInfo = new ProcessStartInfo var pasteInfo = new ProcessStartInfo
{ {
FileName = Constants.Commands.TypeWayland, FileName = Constants.Commands.TypeWayland,
Arguments = "-M shift -k Insert -m shift", Arguments = "-M ctrl -k v -m ctrl",
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true CreateNoWindow = true
}; };
@@ -91,11 +89,11 @@ public class WlClipboardTextInjector(INotifications notifications) : ITextInject
await Task.Delay(100); await Task.Delay(100);
// Simulate Shift+Insert to paste into the focused window // Simulate Ctrl+V to paste into the focused window
var pasteInfo = new ProcessStartInfo var pasteInfo = new ProcessStartInfo
{ {
FileName = Constants.Commands.TypeWayland, FileName = Constants.Commands.TypeWayland,
Arguments = "-M shift -k Insert -m shift", Arguments = "-M ctrl -k v -m ctrl",
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true CreateNoWindow = true
}; };